[PATCH] Makefile fixes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Makefile fixes

Daniel Richard G.
Hello list,

I have a series of patches to contribute to pthreads-win32. This is the
first one.

The attached patch, against the CVS source, does the following:

* Factors out the long lists of object and source files and object
   dependencies into common.mk (also attached as I can't do "cvs add"),
   which is now included by Bmakefile, GNUmakefile and Makefile. Variables
   are used to address the different object/resource file extensions.

   I had noticed inconsistencies among the lists of objects/sources in each
   of the three makefiles, so this approach will put an end to that.

* Fixes incorrect flags/objects used for building the static library

* Adjusts some compiler flags to facilitate building and testing the
   library

* Adds targets (all-tests, all-tests-cflags) to run the test suite on all
   of the library's build configurations, as these tend to have different
   codepaths that can significantly affect correctness

* "Make" syntax tweaks


Below is a more detailed walk-through of the changes:

++ Bmakefile

@ Factored out common variable definitions into common.mk

@ Use new RESOURCE_OBJS variable instead of a literal "version.res"

@ Factored out common dependencies into common.mk

   Added end-of-file comment

++ GNUmakefile

@ I had trouble with test programs not running because DLLs for
   libgcc/libstdc++/libgomp were not in the PATH, so these flags will link
   them statically. (As MinGW is intended to produce "standalone" binaries,
   this is what most people will probably want to do anyway)

@ MAKE is already set by the Make program

   Factored out common variable definitions into common.mk

   As GNU Make supports "+=", use this to add RESOURCE_OBJS to the three
   object-file-list variables

@ Use $(MAKE), not "make" in the help text (e.g. MAKE could be "gmake")

   New all-tests and all-tests-cflags targets (note that the latter is less
   useful for MinGW compared to MSVC)

@ Static builds use small objects, not inlined/aggregate ones, so
   -DPTW32_BUILD_INLINED doesn't belong here

@ Likewise, static builds should use SMALL_STATIC_OBJS, not
   DLL_INLINED_OBJS

@ Factored out common dependencies into common.mk

   Added end-of-file comment

++ Makefile

@ Factored out common variable definitions into common.mk

@ Removed "@" prefix from $(MAKE) invocations in the "all" target, as that
   suppressed useful information (e.g. if you're redirecting terminal output
   to a file for later review)

   New all-tests and all-tests-cflags targets (the latter covers both /MD
   and /MT configurations)

@ Static builds use small objects, not inlined/aggregate ones, so
   -DPTW32_BUILD_INLINED doesn't belong here

@ Fixed "install" rule for static builds (no *.dll file)

@ Added new RESOURCE_OBJS variable where needed

   Static builds should use SMALL_STATIC_OBJS, not DLL_INLINED_OBJS

@ Factored out common dependencies into common.mk

   Added end-of-file comment

++ tests/GNUmakefile

@ ECHO should be defined without the "@", as that is already given in the
   target recipes

   Define TOUCH so that it uses ECHO

   Define ECHO before TOUCH, for ordering

   Don't define MAKE, because that should be set by the Make program itself

@ New variable XLIBS, to specify system/third-party libraries needed by
   some tests

   Only a couple of tests need -lws2_32 -lgomp; don't add these libs to
   everything if we can help it

   Use -static-libgcc and PTW32_FLAGS in CFLAGS, to avoid a dynamic
   dependency on libgcc and build with the same flags as the ptw32 library

@ Replaced "make" with $(MAKE), and a nice straight margin for the target
   descriptions

@ Only one test needs -fopenmp; don't add it to everything

   Added -static-libstdc++ where useful

@ Normalized use of $(ECHO): prefixed by "@", and argument is double-quoted

   Add -lws2_32, -fopenmp et al. only to the tests that need them, using GNU
   Make magic

@ Show the compiler invocations directly

   The -lsupc++ bit only caused errors on my system

   XLIBS is used here

@ idem

++ tests/Makefile

@ Define TOUCH so that it uses ECHO

   Define ECHO before TOUCH, for ordering

@ Use $(MAKE), not "nmake" in the help text

@ Use /nologo in the various $(MAKE) invocations to get rid of annoying
   Microsoft boilerplate

   Show the compiler invocations directly


--Daniel


--
Daniel Richard G. || [hidden email] || Software Developer
Teragram Linguistic Technologies (a division of SAS)
http://www.teragram.com/

ptw32-makefiles.patch (64K) Download Attachment
common.mk (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Makefile fixes

Ross Johnson-2
After some off-list collaboration pretty much all of these changes have
been applied now, although some are optional, e.g. by way of
uncommenting the makefiles in places etc., in particular the static
linking of libgcc etc. with the rationale being to maintain consistency
with existing use.

In addition to these, static linked builds have been fixed with patches
again from Daniel. The autostatic.c code was not being linked in.

Thanks.

On 11/07/2012 6:56 AM, Daniel Richard G. wrote:

> Hello list,
>
> I have a series of patches to contribute to pthreads-win32. This is
> the first one.
>
> The attached patch, against the CVS source, does the following:
>
> * Factors out the long lists of object and source files and object
>   dependencies into common.mk (also attached as I can't do "cvs add"),
>   which is now included by Bmakefile, GNUmakefile and Makefile. Variables
>   are used to address the different object/resource file extensions.
>
>   I had noticed inconsistencies among the lists of objects/sources in
> each
>   of the three makefiles, so this approach will put an end to that.
>
> * Fixes incorrect flags/objects used for building the static library
>
> * Adjusts some compiler flags to facilitate building and testing the
>   library
>
> * Adds targets (all-tests, all-tests-cflags) to run the test suite on all
>   of the library's build configurations, as these tend to have different
>   codepaths that can significantly affect correctness
>
> * "Make" syntax tweaks
>
>
> Below is a more detailed walk-through of the changes:
>
> ++ Bmakefile
>
> @ Factored out common variable definitions into common.mk
>
> @ Use new RESOURCE_OBJS variable instead of a literal "version.res"
>
> @ Factored out common dependencies into common.mk
>
>   Added end-of-file comment
>
> ++ GNUmakefile
>
> @ I had trouble with test programs not running because DLLs for
>   libgcc/libstdc++/libgomp were not in the PATH, so these flags will link
>   them statically. (As MinGW is intended to produce "standalone"
> binaries,
>   this is what most people will probably want to do anyway)
>
> @ MAKE is already set by the Make program
>
>   Factored out common variable definitions into common.mk
>
>   As GNU Make supports "+=", use this to add RESOURCE_OBJS to the three
>   object-file-list variables
>
> @ Use $(MAKE), not "make" in the help text (e.g. MAKE could be "gmake")
>
>   New all-tests and all-tests-cflags targets (note that the latter is
> less
>   useful for MinGW compared to MSVC)
>
> @ Static builds use small objects, not inlined/aggregate ones, so
>   -DPTW32_BUILD_INLINED doesn't belong here
>
> @ Likewise, static builds should use SMALL_STATIC_OBJS, not
>   DLL_INLINED_OBJS
>
> @ Factored out common dependencies into common.mk
>
>   Added end-of-file comment
>
> ++ Makefile
>
> @ Factored out common variable definitions into common.mk
>
> @ Removed "@" prefix from $(MAKE) invocations in the "all" target, as
> that
>   suppressed useful information (e.g. if you're redirecting terminal
> output
>   to a file for later review)
>
>   New all-tests and all-tests-cflags targets (the latter covers both /MD
>   and /MT configurations)
>
> @ Static builds use small objects, not inlined/aggregate ones, so
>   -DPTW32_BUILD_INLINED doesn't belong here
>
> @ Fixed "install" rule for static builds (no *.dll file)
>
> @ Added new RESOURCE_OBJS variable where needed
>
>   Static builds should use SMALL_STATIC_OBJS, not DLL_INLINED_OBJS
>
> @ Factored out common dependencies into common.mk
>
>   Added end-of-file comment
>
> ++ tests/GNUmakefile
>
> @ ECHO should be defined without the "@", as that is already given in the
>   target recipes
>
>   Define TOUCH so that it uses ECHO
>
>   Define ECHO before TOUCH, for ordering
>
>   Don't define MAKE, because that should be set by the Make program
> itself
>
> @ New variable XLIBS, to specify system/third-party libraries needed by
>   some tests
>
>   Only a couple of tests need -lws2_32 -lgomp; don't add these libs to
>   everything if we can help it
>
>   Use -static-libgcc and PTW32_FLAGS in CFLAGS, to avoid a dynamic
>   dependency on libgcc and build with the same flags as the ptw32 library
>
> @ Replaced "make" with $(MAKE), and a nice straight margin for the target
>   descriptions
>
> @ Only one test needs -fopenmp; don't add it to everything
>
>   Added -static-libstdc++ where useful
>
> @ Normalized use of $(ECHO): prefixed by "@", and argument is
> double-quoted
>
>   Add -lws2_32, -fopenmp et al. only to the tests that need them,
> using GNU
>   Make magic
>
> @ Show the compiler invocations directly
>
>   The -lsupc++ bit only caused errors on my system
>
>   XLIBS is used here
>
> @ idem
>
> ++ tests/Makefile
>
> @ Define TOUCH so that it uses ECHO
>
>   Define ECHO before TOUCH, for ordering
>
> @ Use $(MAKE), not "nmake" in the help text
>
> @ Use /nologo in the various $(MAKE) invocations to get rid of annoying
>   Microsoft boilerplate
>
>   Show the compiler invocations directly
>
>
> --Daniel
>
>