How to override environment variables when running configure?

Sam picture Sam · Apr 27, 2010 · Viewed 17.6k times · Source

In any major package for Linux, running ./configure --help will output at the end:

Some influential environment variables:
      CC          C compiler command
      CFLAGS      C compiler flags
      LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
                  nonstandard directory <lib dir>
      CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
                  headers in a nonstandard directory <include dir>
      CPP         C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

How do I use these variables to include a directory? I tried running ./configure --CFLAGS="-I/home/package/custom/" and ./configure CFLAGS="-I/home/package/custom/", however these do not work. Any suggestions?

Answer

ptomato picture ptomato · Apr 27, 2010

The variable you need to use for -I is CPPFLAGS, not CFLAGS. (As it says right there in the help message you copied.) CPP stands for "C preprocessor", not C++. So:

./configure CPPFLAGS='-I/home/package/custom'