diff options
| -rw-r--r-- | Makefile.am | 7 | ||||
| -rw-r--r-- | configure.ac | 18 | ||||
| -rw-r--r-- | src/main.c | 13 |
3 files changed, 38 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 07ef516..f586e21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,11 @@ AM_CFLAGS = -std=c99 -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=1 +AM_CFLAGS += -Wall + +if DEBUG +AM_CFLAGS += -O0 -g +else +AM_CFLAGS += -O2 +endif bin_PROGRAMS = skonfig skonfig_SOURCES = src/main.c diff --git a/configure.ac b/configure.ac index ff589cf..6fead6d 100644 --- a/configure.ac +++ b/configure.ac @@ -13,12 +13,30 @@ AM_INIT_AUTOMAKE([subdir-objects]) # Checks for programs. AC_PROG_CC +AC_LANG([C]) + # Checks for libraries. # Checks for header files. +AC_CHECK_HEADERS([stdio.h]) # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. +# Add debug support +AC_ARG_ENABLE( + [debug], + AS_HELP_STRING([--enable-debug], [enable debugging, default: no]), + [case ${enableval} in + (yes) debug=true ;; + (no) debug=false ;; + (*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; + esac], + [debug=false]) +AM_CONDITIONAL(DEBUG, [test "x${debug}" = xtrue]) +AM_COND_IF(DEBUG, + AC_DEFINE(DEBUG, 1, [Define to 0 if this is a release build]), + AC_DEFINE(DEBUG, 0, [Define to 1 or higher if this is a debug build])) + AC_OUTPUT @@ -1,3 +1,16 @@ +#include <stdio.h> + +#ifdef HAVE_CONFIG_H +#include "../config.h" +#else +#error no config.h +#endif + +#include "config.h" + int main(int argc, char *argv[]) { +#if DEBUG + printf("Debugging enabled.\n"); +#endif return 0; } |
