From ae4bdc32ce0d686d8b2e9ed4c7019e98688302a5 Mon Sep 17 00:00:00 2001 From: darkcoven Date: Sat, 28 Sep 2013 00:50:29 +0200 Subject: [PATCH] Add debug mode support --- Makefile.am | 8 -------- configure.ac | 23 ++++++++++++++++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index 939d0ff..efaba3e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,11 +7,3 @@ SUBDIRS = raw lib cli #SUBDIRS += dump #endif - -#if ENABLE_DEBUG -#CFLAGS += -g -#else -#CFLAGS += -fomit-frame-pointer -#LDFLAGS+= -s -#endif - diff --git a/configure.ac b/configure.ac index 27ed829..ed7bdaf 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE -# Checks for programs +# check for programs AC_PROG_CC AM_PROG_CC_C_O AC_PROG_LIBTOOL @@ -40,9 +40,7 @@ fi AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) -CFLAGS="-Wall -Wextra -Os" - -# Checks for libraries +# check for libraries if test "x${with_readline}" != xno; then AC_CHECK_LIB([readline], [readline], [], [ if test "x${with_readline}" = xyes; then @@ -54,6 +52,20 @@ Unable to find readline library ]) fi +AC_ARG_ENABLE(debug, + [AS_HELP_STRING([--enable-debug], [enable debug mode [default=no]])], + [enable_debug=yes], [enable_debug=no]) + +CFLAGS="-Wall -Wextra -Os" + +if test "x${enable_debug}" = xyes; then + CFLAGS="$CFLAGS -g" +else + CFLAGS="$CFLAGS -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -s" +fi + + # check for header files AC_CHECK_HEADERS([arpa/inet.h stdlib.h string.h sys/ioctl.h termios.h unistd.h]) AC_HEADER_STDBOOL @@ -86,8 +98,9 @@ AC_OUTPUT echo " ${PACKAGE_NAME} version ${PACKAGE_VERSION} Prefix.............: ${prefix} -Debug..............: +Debug..............: ${enable_debug} Compiler...........: ${CC} ${CFLAGS} ${CPPFLAGS} +Readline suppport..: ${with_readline} " -- 2.39.2