When editing the makefile is not an option
Using environment variables
If changing the original makefile is not an option, you can use environment variables to override the values set by the makefile. You can then use the --environment-overrides (-e) option of GNU make or MS nmake.
UNIX example, using make and gcc
... building on UNIX $ cd zlib-1.2.2 ... build $ ./configure ... $ CC="kwwrap -o /path/to/kwwrap.trace gcc" $ AR="kwwrap -o /path/to/kwwrap.trace ar rc" $ LDSHARED="kwwrap -o /path/to/kwwrap.trace gcc" $ export CC AR LDSHARED ... build using wrapped compiler/linker; kwwrap.trace will be generated $ make -e ... convert build trace to build specification $ kwinject -t /path/to/kwwrap.trace -o kwinject.out
Windows example
On the Windows platform, zlib is built with Microsoft's nmake and cl-compiler. The Microsoft-specific makefile uses a slightly different set of variables: CC, AR and LD.
... building on Windows > cd d:\path\to\zlib-1.2.2 ... set up environment variables > set CC=kwwrap -o d:\path\to\kwwrap.trace cl > set AR=kwwrap -o d:\path\to\kwwrap.trace lib > set LD=kwwrap -o d:\path\to\kwwrap.trace link ... build uses wrapped compiler/linker; kwwrap.trace will be generated > nmake -e -f win32\Makefile.msc ... convert build trace to a build specification > kwinject -t d:\path\to\kwwrap.trace -o kwinject.out
Creating wrapper scripts
xerces is a medium-sized open-source project that uses GNU make to build on UNIX. The simple approach of editing the makefile does not apply here, because xerces uses a custom configuration script that does not accept a compiler name that includes spaces, such as "kwwrap gcc". Instead, we can create wrapper scripts.
Example
$ cd /path/to/xerces-c-src_2_6_0 ... create a directory for shell-wrappers $ mkdir kw-wrappers ... create several simple wrapper scripts and save them into the kw-wrappers directory: -- file: kw-wrappers/kwwrap-gcc #!/bin/sh exec kwwrap -o /path/to/kwwrap.trace gcc "$@" -- file: kw-wrappers/kwwrap-g++ #!/bin/sh exec kwwrap -o /path/to/kwwrap.trace g++ "$@" -- file: kw-wrappers/kwwrap-ar #!/bin/sh exec kwwrap -o /path/to/kwwrap.trace ar "$@" -- cut ... don’t forget to set the execute permissions on the created scripts $ chmod +x kw-wrappers/* ... set up PATH and other environment variables $ PATH=$PWD/kw-wrappers:$PATH $ CC=kwwrap-gcc $ CXX=kwwrap-g++ $ AR=kwwrap-ar $ export CC CXX AR ... configure xerces $ XERCESCROOT=$PWD $ cd $XERCESCROOT/src/xercesc $ ./runConfigure -p linux -c $CC -x $CXX ... build using the wrapper scripts; build trace will be generated $ make ... generate a build specification from the build trace $ kwinject -t /path/to/kwwrap/trace -o kwinject.out