just some fixes to the autoconf stuff
[mikachu/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     # these special builds are always debug
22     CVS=""
23     test "${PACKAGE_VERSION%*cvs*}" != "$PACKAGE_VERSION" && CVS="yes"
24     test "$CVS" = "yes" && DEBUG="yes"
25
26     TEST=""
27     test "${PACKAGE_VERSION%*alpha*}" != "$PACKAGE_VERSION" && TEST="yes"
28     test "${PACKAGE_VERSION%*beta*}" != "$PACKAGE_VERSION" && TEST="yes"
29     test "$TEST" = "yes" && DEBUG="yes"
30
31     if test "$DEBUG" = "yes"; then
32         MSG="DEBUG"
33     else
34         MSG="RELEASE"
35     fi
36     if test "$CVS" = "yes"; then
37         MSG="$MSG (CVS build)"
38     fi
39     if test "$TEST" = "yes"; then
40         MSG="$MSG (test release)"
41     fi
42     if test "$STRICT" = "yes"; then
43         MSG="$MSG with strict ANSI compliance"
44     fi
45     AC_MSG_RESULT([$MSG])
46     
47     test "$DEBUG" = "yes" && \
48         AC_DEFINE([DEBUG], [1], [Creating a debug build])
49 ])
50
51
52 # OB_COMPILER_FLAGS()
53 #
54 # Check what compiler is being used for compilation.
55 # It sets the CFLAGS variable appropriately for the compiler, including flags
56 # for debug builds.
57 AC_DEFUN([OB_COMPILER_FLAGS],
58 [
59     AC_REQUIRE([AC_PROG_CPP])
60     AC_REQUIRE([AC_PROG_CC])
61
62     FLAGS=""
63
64     if test "$DEBUG" = "yes"; then
65         FLAGS="-DDEBUG"
66     else
67         FLAGS="-DNDEBUG -DG_DISABLE_ASSERT"
68     fi
69
70     # Check what compiler we are using
71     AC_MSG_CHECKING([for GNU CC])
72     if test "$GCC" = "yes"; then
73         AC_MSG_RESULT([yes])
74         if test "$DEBUG" = "yes"; then
75             FLAGS="$FLAGS -g -fno-inline"
76             FLAGS="$FLAGS -Wall -Wsign-compare -Waggregate-return"
77             FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith"
78             # for Python.h
79             #FLAGS="$FLAGS -Wno-long-long"
80         fi
81         if test "$STRICT" = "yes"; then
82             FLAGS="$FLAGS -ansi -pedantic -D_XOPEN_SOURCE"
83         fi
84     fi
85     AC_MSG_CHECKING([for compiler specific flags])
86     AC_MSG_RESULT([$FLAGS])
87     CFLAGS="$CFLAGS $FLAGS"
88 ])
89
90 AC_DEFUN([OB_NLS],
91 [
92     AC_ARG_ENABLE([nls],
93     AC_HELP_STRING([--enable-nls],[Enable NLS translations [[default=yes]]]),
94     [NLS=$enableval], [NLS="yes"])
95
96     if test "$NLS" = yes; then
97         DEFS="$DEFS -DENABLE_NLS"
98     fi
99 ])
100