Merge branch 'backport' into work
[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
14     AC_ARG_ENABLE([debug],
15     AC_HELP_STRING([--enable-debug],[build a debug version [[default=no]]]),
16     [DEBUG=$enableval], [DEBUG="no"])
17
18     AC_ARG_ENABLE([gprof],
19     AC_HELP_STRING([--enable-gprof],[Enable gprof profiling output [[default=no]]]),
20     [PROF=$enableval], [PROF="no"])
21
22     AC_ARG_ENABLE([gprof-libc],
23     AC_HELP_STRING([--enable-gprof-libc],[Link against libc with profiling support [[default=no]]]),
24     [PROFLC=$enableval], [PROFLC="no"])
25
26     if test "$PROFLC" = "yes"; then
27         PROF="yes" # always enable profiling then
28     fi
29
30     TEST=""
31     test "${PACKAGE_VERSION%*alpha*}" != "$PACKAGE_VERSION" && TEST="yes"
32     test "${PACKAGE_VERSION%*beta*}" != "$PACKAGE_VERSION" && TEST="yes"
33     test "$TEST" = "yes" && DEBUG="yes"
34
35     if test "$DEBUG" = "yes"; then
36         MSG="DEBUG"
37     else
38         MSG="RELEASE"
39     fi
40     if test "$TEST" = "yes"; then
41         MSG="$MSG (test release)"
42     fi
43     if test "$STRICT" = "yes"; then
44         MSG="$MSG with strict ANSI compliance"
45     fi
46     AC_MSG_RESULT([$MSG])
47     
48     test "$DEBUG" = "yes" && \
49         AC_DEFINE([DEBUG], [1], [Creating a debug build])
50 ])
51
52
53 # OB_COMPILER_FLAGS()
54 #
55 # Check what compiler is being used for compilation.
56 # It sets the CFLAGS variable appropriately for the compiler, including flags
57 # for debug builds.
58 AC_DEFUN([OB_COMPILER_FLAGS],
59 [
60     AC_REQUIRE([AC_PROG_CPP])
61     AC_REQUIRE([AC_PROG_CC])
62
63     FLAGS=""
64     L=""
65
66     if test "$DEBUG" = "yes"; then
67         FLAGS="-DDEBUG"
68     else
69         FLAGS="-DNDEBUG -DG_DISABLE_ASSERT"
70     fi
71
72     # Check what compiler we are using
73     AC_MSG_CHECKING([for GNU CC])
74     if test "$GCC" = "yes"; then
75         AC_MSG_RESULT([yes])
76         if test "$DEBUG" = "yes"; then
77             FLAGS="$FLAGS -O0 -ggdb -fno-inline -Wwrite-strings"
78             FLAGS="$FLAGS -Wall -Wsign-compare -Waggregate-return"
79             FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith"
80             # for Python.h
81             #FLAGS="$FLAGS -Wno-long-long"
82         fi
83         if test "$STRICT" = "yes"; then
84             FLAGS="$FLAGS -ansi -pedantic -D_XOPEN_SOURCE"
85         fi
86         if test "$PROF" = "yes"; then
87             FLAGS="$FLAGS -pg -fno-inline"
88         fi
89         if test "$PROFLC" = "yes"; then
90             L="$L -lc_p -lm_p"
91         fi
92         FLAGS="$FLAGS -fno-strict-aliasing"
93     fi
94     AC_MSG_CHECKING([for compiler specific flags])
95     AC_MSG_RESULT([$FLAGS])
96     CFLAGS="$CFLAGS $FLAGS"
97     LIBS="$LIBS $L"
98 ])
99
100 AC_DEFUN([OB_NLS],
101 [
102     AC_ARG_ENABLE([nls],
103     AC_HELP_STRING([--enable-nls],[Enable NLS translations [[default=yes]]]),
104     [NLS=$enableval], [NLS="yes"])
105
106     if test "$NLS" = yes; then
107         DEFS="$DEFS -DENABLE_NLS"
108     fi
109 ])
110