From: Daniel Drake gamin ignores user-supplied CFLAGS. http://bugzilla.gnome.org/show_bug.cgi?id=450262 https://bugs.gentoo.org/show_bug.cgi?id=178266 Index: configure.in =================================================================== --- configure.in (revision 325) +++ configure.in (working copy) @@ -1,13 +1,12 @@ dnl Process this file with autoconf to produce a configure script. - -# get any external flags setting before we start playing with the CFLAGS variable -ENV_CFLAGS=$CFLAGS - AC_PREREQ(2.52) AC_INIT(libgamin) AM_CONFIG_HEADER(config.h) AC_CANONICAL_SYSTEM +# get any external flags setting before we start playing with the CFLAGS variable +ENV_CFLAGS="$CFLAGS" + GAMIN_MAJOR_VERSION=0 GAMIN_MINOR_VERSION=1 GAMIN_MICRO_VERSION=9 @@ -37,6 +36,12 @@ AC_PROG_INSTALL AC_PROG_MAKE_SET +dnl If the user set no CFLAGS, then don't assume the autotools defaults of +dnl "-g -O2". We set default CFLAGS later based on the --disable-debug flag. +if test -z "$ENV_CFLAGS"; then + CFLAGS="" +fi + dnl for the spec file RELDATE=`date +'%a %b %e %Y'` AC_SUBST(RELDATE) @@ -506,44 +511,45 @@ AC_MSG_CHECKING(for more compiler warnings) if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then AC_MSG_RESULT(yes) - CFLAGS="\ + warning_cflags="\ -Wall\ -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes\ -Wnested-externs\ -Wsign-compare" + SAVE_CFLAGS="$CFLAGS" for option in -Wno-sign-compare; do - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $option" + CFLAGS="$option" AC_MSG_CHECKING([whether gcc understands $option]) AC_TRY_COMPILE([], [], has_option=yes, has_option=no,) - if test $has_option = no; then - CFLAGS="$SAVE_CFLAGS" + if test "$has_option" != "no"; then + warning_cflags="$warning_cflags $option" fi AC_MSG_RESULT($has_option) unset has_option - unset SAVE_CFLAGS done + CFLAGS="$SAVE_CFLAGS" unset option else AC_MSG_RESULT(no) - unset CFLAGS fi if test "$GCC" = "yes"; then if test "$debug" = "yes"; then - CFLAGS="$CFLAGS -g" + debug_cflags="-g" else - #don't optimise with -g + # autotools defaults to "-O2 -g" for cflags, but we don't + # want -g in non-debug builds if test -z "$ENV_CFLAGS"; then - ENV_CFLAGS="-O2" + CFLAGS="-O2" fi fi fi -CFLAGS="$CFLAGS $ENV_CFLAGS" +AM_CFLAGS="$warning_cflags $debug_cflags" +AC_SUBST(AM_CFLAGS) dnl ========================================================================== @@ -569,7 +575,7 @@ prefix: ${prefix} source code location: ${srcdir} compiler: ${CC} - compiler flags: ${CFLAGS} + compiler flags: ${AM_CFLAGS} ${CFLAGS} backends: ${backends} build documentation: ${build_docs}