which flags to pass to gcc/g++
* Serge <firstname.lastname@example.org> [120624 00:15]:
> Or you mean that they should run `gcc`/`g++` with CPPFLAGS?
> If you do, then... How should they do that?
gcc $(CPPFLAGS) $(CFLAGS) -c -o foo.o foo.c
gcc $(CFLAGS) $(LDFLAGS) -o foo foo.o
gcc $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o foo foo.c
g++ $(CPPFLAGS) $(CXXFLAGS) -c -o foo.o foo.cpp
g++ $(CXXFLAGS) $(LDFLAGS) -o foo foo.o
g++ $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o foo foo.cpp
I.e: the rules are:
* whenever calling gcc pass CFLAGS,
* whenever calling g++ pass CXXFLAGS.
* Whenever it links (i.e. without -c, -E or -S) pass LDFLAGS.
* Whenever it will preprocess anything, pass CPPFLAGS.
Note that CPPFLAGS and LDFLAGS are in the format as you need to
give them to gcc/g++, i.e. every ld option not understood by
gcc needs a -Wl, and so on...
Bernhard R. Link