On 2014-02-18 13:03, Philippe Michel wrote:
> This doesn't look right. Only -I is a preprocessor flag. The others
> are compiler (or linker) flags :
> CFLAGS="-O3 -funroll-loops -march=native -mtune=native"
> CPPFLAGS="-I/usr/local/include"
> LDFLAGS="-L/usr/local/lib" 

It is correct as any flag the preprocessor doesn't handle will get
passed to the back end program using it (C, C++, Ada compilers etc).

In single language C environment CPPFLAGS and CFLAGS are effectively the
same thing. No matter what language backend the preprocessor will pass
the other parameters that it may not use to the backend when using CPPFLAGS.

If you start mixing languages like C and C++ then there is more of a
distinction. CPPFLAGS will be passed to both compilers (g++ and gcc). So
if I want to enable debugging or simd instructions to both the C and C++
compilers I can use CPPFLAGS. If I want the flags to be different then I
can can specifically use CFLAGS for C, and CXXFLAGS for C++.

Example:

CPPFLAGS="-g"
CFLAGS="-O3"
CXXFLAGS="-O0"

Would produce compiled code with no (-O0) optimizations for C++ and more
optimizations for C (-O3). Both C++ and C will be built with debug
information (-g)

The default GNU make rules for C++ and C look like this:
$(CC) $(CPPFLAGS) $(CFLAGS) -c
and
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c

If you call the pre-processor directly with extra flags you should find
it accepts them (but doesn't use them of course). For as long as I can
remember (at least back to 2.x of gcc) the pre-processor will also
complain about flags that are not supported.

cpp -O3 -g -I/path/to/includes filename.xxx

You should find it it doesn't choke on the known compile flags, even
though it can't do anything useful with them. It will of course know
about and use the -I flag.

-- 
Michael Petch
GNU Backgammon Maintainer / Developer
OpenPGP FingerPrint=D81C 6A0D 987E 7DA5 3219 6715 466A 2ACE 5CAE 3304


_______________________________________________
Bug-gnubg mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-gnubg

Reply via email to