views:

312

answers:

1

I'm using GNU make, and including a 3rd party library in a project that has a build system that goes berserk if CFLAGS is defined in the environment when it is called. I like to have CFLAGS defined in my environment for other reasons. The library's build is being invoked from another makefile, so that I say e.g.:

3rdparty: $(MAKE) -f Makefile.3rdparty

But I would like to be sure that CFLAGS is unset when I invoke make on the 3rd party Makefile. The nearest thing I can find is to say:

CFLAGS:=

But this still leaves CFLAGS set in the environment, it's just an empty string. Apart from doing something hideous like saying:

3rdparty: bash -c "unset CFLAGS; $(MAKE) -f Makefile.3rdparty"

Is there an easy way to "unset" the CFLAGS variable from within my primary makefile, so that it isn't present at all in the environment when the third party library is invoked?

+3  A: 

Doesn't the following work for you?

unexport CFLAGS
3rdparty:
        $(MAKE) -f Makefile.3rdparty
Pavel Shved
It does! I didn't know about the "unexport" keyword, now I do. Thanks!
Jay Walker