Added debugging support

Added --enable-debug flag to configure.ac. It currently only enables the
DebugContext macro in main.c
This commit is contained in:
Gergely Polonkai 2012-03-10 18:24:23 +01:00
parent 3ae05dd663
commit 44a5a07874
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,12 @@ AM_INIT_AUTOMAKE([wMUD], [0.1.0])
AC_PROG_CC
PKG_PROG_PKG_CONFIG
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debugging support (default: disabled)]), [enable_debug=yes; CFLAGS="$CFLAGS -g -Wall"], [enable_debug=no])
AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = "yes"])
if test "$enable_debug" = "yes"; then
AC_DEFINE([DEBUG], [1], [Define to compile with debugging support])
fi
AC_ARG_ENABLE([memcached], AS_HELP_STRING([--disable-memcached], [Disable Memcached support (default: enabled)]), [], [enable_memcached=yes])
AM_CONDITIONAL([ENABLE_MEMCACHED], [test "$enable_memcached" = "yes"])
if test "$enable_memcached" = "yes"; then

View File

@ -1,5 +1,8 @@
#include <glib.h>
#include <gio/gio.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
struct {
char *file;
@ -27,6 +30,7 @@ rl_sec_elapsed(gpointer user_data)
return TRUE;
}
#ifdef DEBUG
void
debug_context(char *file, int line)
{
@ -37,6 +41,9 @@ debug_context(char *file, int line)
debug_context_loc.line = line;
}
#define DebugContext debug_context(__FILE__, __LINE__)
#else
#define DebugContext
#endif
int
main(int argc, char **argv)