From 98b0eeaeba3ff140c06850c45b2ae359d0841da7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 19 Jul 2013 18:08:34 +0100 Subject: [PATCH 2/3] configure.ac: use AC_DEFINE instead of appending to CFLAGS In build systems that put CFLAGS in an environment variable rather than a configure command-line argument (e.g. RPM, I think?), what we put in CFLAGS will potentially take precedence, and the external build system's chosen CFLAGS won't necessarily be used. Meanwhile, if the build system puts CFLAGS on the make command line, it will take precedence: in particular, debug logging could be disabled, which is bad for debuggability. If we move to AC_DEFINE, they'll interact properly. There is one remaining use of CFLAGS in configure.ac, for code coverage. RPMs and other production-quality builds shouldn't have coverage instrumentation, so this doesn't really conflict. Also use AS_IF instead of if/fi, while I'm touching these lines anyway: it's better Autoconf style. --- configure.ac | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index fe10dd5..ef7985e 100644 --- a/configure.ac +++ b/configure.ac @@ -94,24 +94,23 @@ AC_MSG_RESULT([$mc_want_twisted_tests]) AM_CONDITIONAL([WANT_TWISTED_TESTS], test yes = "$mc_want_twisted_tests") AC_ARG_ENABLE(debug, [ --disable-debug compile without debug code],[enable_debug=${enableval}], enable_debug=yes ) -if test "x$enable_debug" = "xyes"; then - CFLAGS="$CFLAGS -DENABLE_DEBUG" -fi +AS_IF([test "x$enable_debug" = "xyes"], + [AC_DEFINE([ENABLE_DEBUG], [1], [Define to compile in debug messages])]) AC_ARG_ENABLE(cast-checks, [ --disable-cast-checks compile with GLIB cast checks disabled],[cchecks=${enableval}],cchecks=yes) -if test "x$cchecks" = "xno"; then - CFLAGS="$CFLAGS -DG_DISABLE_CAST_CHECKS" -fi +AS_IF([test "x$cchecks" = "xno"], + [AC_DEFINE([G_DISABLE_CAST_CHECKS], [1], + [Define to disable checked casts (not recommended)])]) AC_ARG_ENABLE(asserts, [ --disable-asserts compile with GLIB assertions disabled],[asserts=${enableval}],asserts=yes) -if test "x$asserts" = "xno"; then - CFLAGS="$CFLAGS -DG_DISABLE_ASSERTS" -fi +AS_IF([test "x$asserts" = "xno"], + [AC_DEFINE([G_DISABLE_ASSERTS], [1], + [Define to disable assertions (not recommended)])]) AC_ARG_ENABLE(checks, [ --disable-checks compile with GLIB checks disabled],[checks=${enableval}],checks=yes) -if test "x$checks" = "xno"; then - CFLAGS="$CFLAGS -DG_DISABLE_CHECKS" -fi +AS_IF([test "x$checks" = "xno"], + [AC_DEFINE([G_DISABLE_CHECKS], [1], + [Define to disable checks (not recommended)])]) AC_ARG_ENABLE(coverage, [ --enable-coverage compile with coverage info],[enable_coverage=${enableval}],enable_coverage=no) if test "x$enable_coverage" = "xyes"; then -- 1.8.4.rc3