darwin*) AC_MSG_WARN([Disabling smart preprocessing])
           EXTRA_CFLAGS="-no-cpp-precomp";;
 esac
+
+AC_ARG_ENABLE(debug,
+[  --enable-debug          Compilation flags to allow debugging [default=yes]],
+  if test $enableval == "yes"
+  then
+    EXTRA_CFLAGS="-g $EXTRA_CFLAGS"
+  fi,
+  EXTRA_CFLAGS="-g $EXTRA_CFLAGS"
+)
+
 AC_SUBST(EXTRA_CFLAGS)
 
 dnl =============================================================
 
            -DPKGDATADIR=\"$(pkgdatadir)\" -DLOCALEDIR=\"$(localedir)\"
 YFLAGS   = --debug --defines
 LFLAGS   = -8
-CFLAGS   = -g -O2 -W -Wall -pedantic -Wno-long-long @EXTRA_CFLAGS@
+CFLAGS   = -O2 -W -Wall -pedantic -Wno-long-long @EXTRA_CFLAGS@
 
 lib_LTLIBRARIES = libgedcom.la
 libgedcom_la_SOURCES = lex.gedcom_1byte_.c \
 
 # $Name$
 
 INCLUDES = -I $(srcdir)/../intl -I $(srcdir)/../include -I $(srcdir)/../utf8
-CFLAGS   = -g -O2 -W -Wall -pedantic -Wno-long-long @EXTRA_CFLAGS@
+CFLAGS   = -O2 -W -Wall -pedantic -Wno-long-long @EXTRA_CFLAGS@
 
 lib_LTLIBRARIES = libgedcom_gom.la
 libgedcom_gom_la_SOURCES = gom.c \
 
 ## Process this file with automake to produce Makefile.in
 # $Id$
 # $Name$
-CFLAGS  = -g -O2
+CFLAGS  = -O2 @EXTRA_CFLAGS@
 INCLUDES = -I$(srcdir)/..
 libdir  = $(pkgdatadir)
 
 
 
 INCLUDES = -DPKGDATADIR=\"$(pkgdatadir)\" -I $(srcdir)/../../include \
            -I $(srcdir)/../../utf8
-CFLAGS   = -g -O2 @EXTRA_CFLAGS@
+CFLAGS   = -O2 @EXTRA_CFLAGS@
 
 noinst_PROGRAMS = testgedcom pathtest gomtest updatetest testintl updategomtest \
                  writegomtest
 
 SUBDIRS = @LCS_SUBDIRS@ .
 
 INCLUDES = @LCS_INCLUDES@
-CFLAGS   = -g -O2 -W -Wall -pedantic -Wno-long-long
+CFLAGS   = -O2 -W -Wall -pedantic -Wno-long-long @EXTRA_CFLAGS@
 
 noinst_LTLIBRARIES = libutf8.la
 libutf8_la_SOURCES = utf8-locale.c utf8.c utf8-convert.c