3 AS_HELP_STRING([--enable-debug[[=no/some/yes/checks]]], [turn on debugging [[default=some]]]),
4 [case "${enableval}" in
5 yes) enable_debug=yes ;;
6 some) enable_debug=some ;;
7 checks) enable_debug=checks ;;
9 *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
10 esac], [enable_debug=some])
12 dnl -g is added by AC_PROG_CC if the compiler understands it
14 dnl ==========================================================================
16 FC_C_FLAGS([-Wno-tautological-compare -Wno-nonnull-compare],
17 [], [EXTRA_DEBUG_CFLAGS])
18 if test "x$cxx_works" = "xyes" ; then
19 FC_CXX_FLAGS([-Wno-tautological-compare -Wno-nonnull-compare],
20 [], [EXTRA_DEBUG_CXXFLAGS])
23 dnl ==========================================================================
25 if test "x$enable_debug" = "xno"; then
26 AC_DEFINE([NDEBUG], [1], [No debugging support at all])
27 AC_DEFINE([FREECIV_NDEBUG], [1], [No freeciv specific debugging support at all])
28 FC_C_FLAGS([-O3 -fomit-frame-pointer], [], [EXTRA_DEBUG_CFLAGS])
29 if test "x$cxx_works" = "xyes" ; then
30 FC_CXX_FLAGS([-O3 -fomit-frame-pointer], [], [EXTRA_DEBUG_CXXFLAGS])
34 dnl ==========================================================================
35 dnl debug level >= some
36 if test "x$enable_debug" = "xsome" -o "x$enable_debug" = "xyes" -o \
37 "x$enable_debug" = "xchecks"; then
38 FC_C_FLAGS([-Wall -Wpointer-arith -Wcast-align ],
39 [], [EXTRA_DEBUG_CFLAGS])
40 if test "x$cxx_works" = "xyes" ; then
41 FC_CXX_FLAGS([-Wall -Wpointer-arith -Wcast-align ],
42 [], [EXTRA_DEBUG_CXXFLAGS])
46 dnl ==========================================================================
47 dnl debug level >= yes
48 if test "x$enable_debug" = "xyes" -o "x$enable_debug" = "xchecks"; then
49 AC_DEFINE([FREECIV_DEBUG], [1], [Extra debugging support])
50 AC_DEFINE([DEBUG], [1], [Extra debugging support, backward compatibility macro])
51 AC_DEFINE([LUA_USE_APICHECK], [1], [Lua Api checks])
53 FC_C_FLAGS([-Werror -Wmissing-prototypes -Wmissing-declarations \
54 -Wformat -Wformat-security -Wnested-externs \
56 [], [EXTRA_DEBUG_CFLAGS])
57 if test "x$cxx_works" = "xyes" ; then
58 FC_CXX_FLAGS([-Werror -Wmissing-prototypes -Wmissing-declarations \
59 -Wformat -Wformat-security],
60 [], [EXTRA_DEBUG_CXXFLAGS])
63 dnl backtrace log callback needs "-rdynamic" in order to work well.
64 FC_LD_FLAGS([-rdynamic -Wl,--no-add-needed], [], [EXTRA_DEBUG_LDFLAGS])
67 dnl ==========================================================================
68 dnl debug level >= checks
69 if test "x$enable_debug" = "xchecks"; then
70 dnl Add additional flags as stated in ./doc/HACKING. Compiling the
71 dnl server is OK but there are problems in a external library (gtk2)
72 dnl which prevent the compilation of the client using this extended
73 dnl flags (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=148766)
74 dnl temporary fixing the problem by patching this file to compile freeciv
75 dnl with this option set
76 FC_C_FLAGS([-Wstrict-prototypes], [], [EXTRA_DEBUG_CFLAGS])