Friday, January 11, 2013

How to tweak CFLAGS globally when configure is in use, such as a gcc build

I plan to use this to pass down "-save-temps=obj" to force temporary assembly files to be preserved in a place where they can be found for reference.  Wish me luck (or tell me where I go astray)!  :-)    C.
---------------------------------------------------------------------------------------- - automake: "2.2.5 Overriding Default Configuration Setting with

When installing several packages using the same setup, it can be convenient to create a file to capture common settings. If a file named prefix/share/ exists, configure will source it at the beginning of its execution.

Recall the command from the previous section:

~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \
CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
Assuming we are installing many package in ~/usr, and will always want to use these definitions of CC, CPPFLAGS, and LDFLAGS, we can automate this by creating the following ~/usr/share/ file:

test -z "$CC" && CC=gcc-3
test -z "$CPPFLAGS" && CPPFLAGS=-I$HOME/usr/include
test -z "$LDFLAGS" && LDFLAGS=-L$HOME/usr/lib
Now, any time a configure script is using the ~/usr prefix, it will execute the above and define these three variables.

~/amhello-1.0 % ./configure --prefix ~/usr
configure: loading site script /home/adl/usr/share/
See Setting Site Defaults, for more information about this feature."

Also, thanks to this site for the following:

You want a file. Try:
$ mkdir -p ~/local/share
$ cat << EOF > ~/local/share/
Whenever you invoke an autoconf generated configure script with --prefix=$HOME/local, the will be read and all the assignments will be made for you. CPPFLAGS and LDFLAGS should be all you need, but you can make any other desired assignments as well (hence the ... in the sample above). Note that -I flags belong in CPPFLAGS and not in CFLAGS, as -I is intended for the pre-processor and not the compiler."

'via Blog this'

No comments:

Post a Comment