Skip to content
Browse files

Don't set CPPFLAGS, CFLAGS, LDFLAGS in configure.

Instead set debug preproc/compile/link options locally in Makefile.am.
  • Loading branch information...
1 parent b667658 commit 02112e40a722d0603fd6d728a5d5f4ceb3a2b540 @mschuerig committed Jan 22, 2009
Showing with 28 additions and 21 deletions.
  1. +0 −1 TODO
  2. +2 −19 configure.ac
  3. +23 −1 src/Makefile.am
  4. +3 −0 src/hangon.c
View
1 TODO
@@ -1,7 +1,6 @@
* Don't restart command if exited with a specific set of status codes
* Listen to multiple streams (stderr)?
-* Don't set CLAGS and LDFLAGS in configure.ac
* USE the flags set in config.h!
Packaging
View
21 configure.ac
@@ -7,27 +7,10 @@ AC_CONFIG_SRCDIR([src/hangon.c])
AC_CONFIG_HEADERS([config.h])
# Options
-
-# -Wextra enables additional checks not included in -Wall
-# AM_INIT_AUTOMAKE doesn't accept -Wextra so it is added
-# manually. See gcc(1).
-#
-# _FORTIFY_SOURCE adds some checking against buffer overflows.
-# See feature_test_macros(7).
-CFLAGS="$CFLAGS -Wextra -D_FORTIFY_SOURCE=2"
-
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug], [enable debugging]),
- enable_debug="yes", [])
-if test "x$enable_debug" = "xyes"; then
- # Add some heavy-weight pointer checking using mudflap
- # See gcc(1) and <http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging>.
- CPPFLAGS="$CPPFLAGS -DDEBUG"
- CFLAGS="$CFLAGS -O0 -g -fmudflap"
- LDFLAGS="$LDFLAGS -lmudflap"
-else
- CPPFLAGS="$CPPFLAGS -DNDEBUG"
-fi
+ enable_debug="true")
+AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
# Checks for programs.
AC_PROG_CC
View
24 src/Makefile.am
@@ -4,4 +4,26 @@ hangon_SOURCES = hangon.c
hangon_LDADD = @LIBINTL@ ../gnulib/lib/libgnu.a
localedir = $(datadir)/locale
-AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
+
+AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" \
+ -I$(top_srcdir)/gnulib/lib \
+ -I$(top_builddir)/gnulib/lib \
+ -D_FORTIFY_SOURCE=2
+# _FORTIFY_SOURCE adds some checking against buffer overflows.
+# See feature_test_macros(7).
+
+AM_CFLAGS = -std=c99 \
+ -Wall -Wextra \
+ -Wwrite-strings \
+ -Wunused -Wno-unused-parameter \
+ -Werror
+
+if DEBUG
+ # Add some heavy-weight pointer checking using mudflap
+ # See gcc(1) and <http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging>.
+ AM_CPPFLAGS += -DDEBUG
+ AM_CFLAGS += -O0 -g -fmudflap
+ AM_LDFLAGS = -lmudflap
+else
+ AM_CPPFLAGS += -DNDEBUG
+endif
View
3 src/hangon.c
@@ -7,6 +7,7 @@
*/
#include <errno.h>
#include <getopt.h>
+#include <libintl.h>
#include <locale.h>
#include <signal.h>
#include <stdbool.h>
@@ -59,7 +60,9 @@ static char **command_args;
static int timeout_secs = 60;
static int max_retries = 0;
static bool quiet = false;
+#ifdef DEBUG
static bool debugging = false;
+#endif
static void
usage(int status)

0 comments on commit 02112e4

Please sign in to comment.
Something went wrong with that request. Please try again.