You can can modify CFLAGS
by adding a line like this to your configure.ac
file:
CFLAGS="$CFLAGS -D_GNU_SOURCE"
then regenerate your configure script (this adds to the existing CFLAGS
rather than replacing it, which it what you should do - so users can specify their own CFLAGS
options when compiling and your script won't overwrite them).
However, for the specific case of _GNU_SOURCE
, you should instead use the builtin autoconf macro:
AC_GNU_SOURCE
Place this early in your configure.ac
file, before any rules that invoke the C compiler. Note that this doesn't add -D_GNU_SOURCE
to CFLAGS
, though - if you're using a configuration header (set with AC_CONFIG_HEADER
) then it adds a definition for _GNU_SOURCE
to that, and if you're not then it adds -D_GNU_SOURCE=1
to DEFS
, which you can add to CFLAGS
in your Makefile.
If you're using a configuration header (which for any non-trivial autoconf project, you probably should be) then it should be included before any system headers.