3216235305c26e174f092f964917a08f7961ec6a
[dana/openbox.git] / m4 / openbox.m4
1 # OB_DEBUG()
2 #
3 # Check if the user has requested a debug build.
4 # Sets the DEBUG or NDEBUG variables as appropriate
5 # Sets the CVS environment variable when building CVS sources.
6 AC_DEFUN([OB_DEBUG],
7 [
8     AC_MSG_CHECKING([build type])
9
10     AC_ARG_ENABLE([strict-ansi],
11     AC_HELP_STRING([--enable-strict-ansi],[Enable strict ANSI compliance build [[default=no]]]),
12     [STRICT=$enableval], [STRICT="no"])
13     if test "$GCC" = "yes" && test "$STRICT" = "yes"; then
14         CFLAGS="$CFLAGS -ansi -pedantic -D_XOPEN_SOURCE"
15     fi
16
17     AC_ARG_ENABLE([debug],
18     AC_HELP_STRING([--enable-debug],[build a debug version [[default=no]]]),
19     [DEBUG=$enableval], [DEBUG="no"])
20
21     TEST=""
22     test "${PACKAGE_VERSION%*alpha*}" != "$PACKAGE_VERSION" && TEST="yes"
23     test "${PACKAGE_VERSION%*beta*}" != "$PACKAGE_VERSION" && TEST="yes"
24     test "$TEST" = "yes" && DEBUG="yes"
25
26     if test "$DEBUG" = "yes"; then
27         MSG="DEBUG"
28     else
29         MSG="RELEASE"
30     fi
31     if test "$TEST" = "yes"; then
32         MSG="$MSG (test release)"
33     fi
34     if test "$STRICT" = "yes"; then
35         MSG="$MSG with strict ANSI compliance"
36     fi
37     AC_MSG_RESULT([$MSG])
38     
39     test "$DEBUG" = "yes" && \
40         AC_DEFINE([DEBUG], [1], [Creating a debug build])
41 ])
42
43
44 # OB_COMPILER_FLAGS()
45 #
46 # Check what compiler is being used for compilation.
47 # It sets the CFLAGS variable appropriately for the compiler, including flags
48 # for debug builds.
49 AC_DEFUN([OB_COMPILER_FLAGS],
50 [
51     AC_REQUIRE([AC_PROG_CPP])
52     AC_REQUIRE([AC_PROG_CC])
53
54     FLAGS=""
55
56     if test "$DEBUG" = "yes"; then
57         FLAGS="-DDEBUG"
58     else
59         FLAGS="-DNDEBUG -DG_DISABLE_ASSERT"
60     fi
61
62     # Check what compiler we are using
63     AC_MSG_CHECKING([for GNU CC])
64     if test "$GCC" = "yes"; then
65         AC_MSG_RESULT([yes])
66         if test "$DEBUG" = "yes"; then
67             FLAGS="$FLAGS -g -fno-inline -fno-strict-aliasing"
68             FLAGS="$FLAGS -Wall -Wsign-compare -Waggregate-return"
69             FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith"
70             # for Python.h
71             #FLAGS="$FLAGS -Wno-long-long"
72         fi
73         if test "$STRICT" = "yes"; then
74             FLAGS="$FLAGS -ansi -pedantic -D_XOPEN_SOURCE"
75         fi
76     fi
77     AC_MSG_CHECKING([for compiler specific flags])
78     AC_MSG_RESULT([$FLAGS])
79     CFLAGS="$CFLAGS $FLAGS"
80 ])
81
82 AC_DEFUN([OB_NLS],
83 [
84     AC_ARG_ENABLE([nls],
85     AC_HELP_STRING([--enable-nls],[Enable NLS translations [[default=yes]]]),
86     [NLS=$enableval], [NLS="yes"])
87
88     if test "$NLS" = yes; then
89         DEFS="$DEFS -DENABLE_NLS"
90     fi
91 ])
92