Allow using things that were deprecated in gtk+-3.22.
[freeciv.git] / m4 / debug.m4
blob48c3d65df4a08316e585e6c7b310243ba5dd6480
1 AC_DEFUN([FC_DEBUG], [
2 AC_ARG_ENABLE(debug,
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 ;;
8   no)     enable_debug=no ;;
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 ==========================================================================
15 dnl Always
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 ==========================================================================
24 dnl debug level == no
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     AC_DEFINE([QT_NO_DEBUG], [1], [Qt debugging support disabled])
31     FC_CXX_FLAGS([-O3 -fomit-frame-pointer], [], [EXTRA_DEBUG_CXXFLAGS])
32   fi
35 dnl ==========================================================================
36 dnl debug level >= some
37 if test "x$enable_debug" = "xsome" -o "x$enable_debug" = "xyes" -o \
38         "x$enable_debug" = "xchecks"; then
39   FC_C_FLAGS([-Wall -Wpointer-arith -Wcast-align ],
40              [], [EXTRA_DEBUG_CFLAGS])
41   if test "x$cxx_works" = "xyes" ; then
42     AC_DEFINE([QT_NO_DEBUG], [1], [Qt debugging support disabled])
43     FC_CXX_FLAGS([-Wall -Wpointer-arith -Wcast-align],
44                  [], [EXTRA_DEBUG_CXXFLAGS])
45   fi
48 dnl ==========================================================================
49 dnl debug level >= yes
50 if test "x$enable_debug" = "xyes" -o "x$enable_debug" = "xchecks"; then
51   AC_DEFINE([FREECIV_DEBUG], [1], [Extra debugging support])
52   AC_DEFINE([DEBUG], [1], [Extra debugging support, backward compatibility macro])
53   AC_DEFINE([LUA_USE_APICHECK], [1], [Lua Api checks])
55   FC_C_FLAGS([-Werror -Wmissing-prototypes -Wmissing-declarations \
56               -Wformat -Wformat-security -Wnested-externs \
57               -Wshadow],
58              [], [EXTRA_DEBUG_CFLAGS])
59   if test "x$cxx_works" = "xyes" ; then
60     FC_CXX_FLAGS([-Werror -Wmissing-prototypes -Wmissing-declarations \
61                   -Wformat -Wformat-security],
62                  [], [EXTRA_DEBUG_CXXFLAGS])
63   fi
65   dnl backtrace log callback needs "-rdynamic" in order to work well.
66   FC_LD_FLAGS([-rdynamic -Wl,--no-add-needed], [], [EXTRA_DEBUG_LDFLAGS])
69 dnl ==========================================================================
70 dnl debug level >= checks
71 if test "x$enable_debug" = "xchecks"; then
72   dnl Add additional flags as stated in ./doc/HACKING. Compiling the
73   dnl server is OK but there are problems in a external library (gtk2)
74   dnl which prevent the compilation of the client using this extended
75   dnl flags (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=148766)
76   dnl temporary fixing the problem by patching this file to compile freeciv
77   dnl with this option set
78   FC_C_FLAGS([-Wstrict-prototypes], [], [EXTRA_DEBUG_CFLAGS])