0

I read documents about CPPFLAGS. Shortly, I understand that CPPFLAGS used for pass parameter to compiler. Sample usage CPPFLAGS in makefile is below.

gcc $(CPPFLAGS) main.c -o main.o

Execute make

make CPPFLAGS=-I../header

What is special CPPFLAGS text? It can be interchangable any other text like "FOO". What is the differences between FOO variable and CPPFLAGS variable? Replace all CPPFLAGS text with FOO text build is success again, nothing changes.

Main problem that actually need to solve. There are lots of makefiles. There is no include CPPFLAGS variable in these makefiles. Is there a way to pass compiler options without change makefiles.

Thanks.

1 Answer 1

1

What is special CPPFLAGS text? It can be interchangable any other text like "FOO"

Three things are special about CPPFLAGS:

  1. It is a convention that many tools follow. Most notably GNU autoconf/automake.
  2. GNU Make provides implicit rules to build many target types. These implicit rules use CPPFLAGS variable when compiling .o from C and C++ sources. These rules can be replaced with one's own rules if necessary.
  3. When you use CPPFLAGS for preprocessor flags you follow the principle of least astonishment.

There is no include CPPFLAGS variable in these makefiles

If you meant that there are no occurrences of CPPFLAGS in the makefiles that may be because the implicit rules are used which I mentioned above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.