Imported Upstream version 3.2.0
[debian/amanda] / config / amanda / debugging.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_WITH_ASSERTIONS
4 #
5 # OVERVIEW
6 #
7 #   Handles the --with-assertions flag.  Defines and substitutes ASSERTIONS
8 #   if the flag is given.
9 #
10 AC_DEFUN([AMANDA_WITH_ASSERTIONS],
11 [
12     ASSERTIONS=
13     AC_ARG_WITH(assertions,
14         AS_HELP_STRING([--with-assertions],
15             [compile assertions into code]),
16         [
17             case "$withval" in
18                 n | no) : ;;
19                 y |  ye | yes)
20                     ASSERTIONS=1
21                     AC_DEFINE(ASSERTIONS,1,
22                         [Define if you want assertion checking. ])
23                   ;;
24                 *) AC_MSG_ERROR([*** You must not supply an argument to --with-assertions option.])
25                   ;;
26             esac
27         ]
28     )
29     AC_SUBST(ASSERTIONS)
30 ])
31
32 # SYNOPSIS
33 #
34 #   AMANDA_WITH_DEBUGGING
35 #
36 # OVERVIEW
37 #
38 #   Handles the --with[out]-debugging flag.  If debugging is not disabled, then define
39 #   DEBUG_CODE, and define and substitute AMANDA_DBGDIR to either the location the
40 #   user gave, or AMANDA_TMPDIR.
41 #
42 AC_DEFUN([AMANDA_WITH_DEBUGGING],
43 [
44     AC_REQUIRE([AMANDA_WITH_TMPDIR])
45     AC_ARG_WITH(debugging,
46         AS_HELP_STRING([--with-debugging=DIR]
47             [put debug logs in DIR (default same as --with-tmpdir)]), 
48         [ debugging="$withval" ],
49         [ debugging="yes" ]
50     )
51
52     case "$debugging" in
53         n | no) AC_MSG_ERROR([Amanda no longer supports building with debugging disabled]);;
54         y | ye | yes) AMANDA_DBGDIR="$AMANDA_TMPDIR";;
55         *) AMANDA_DBGDIR="$debugging";;
56     esac
57
58     # evaluate any extra variables in the directory
59     AC_DEFINE_DIR([AMANDA_DBGDIR], [AMANDA_DBGDIR],
60         [Location of Amanda directories and files. ])
61 ])
62
63 # SYNOPSIS
64 #
65 #   AMANDA_GLIBC_BACKTRACE
66 #
67 # OVERVIEW
68 #
69 #   Check for glibc's backtrace support, and define HAVE_GLIBC_BACKTRACE if it is present.
70 AC_DEFUN([AMANDA_GLIBC_BACKTRACE],
71 [
72     AC_CHECK_HEADER([execinfo.h], [
73         AC_CHECK_FUNC([backtrace_symbols_fd], [
74             AC_DEFINE(HAVE_GLIBC_BACKTRACE, 1,
75                 [Define this if glibc's backtrace functionality (execinfo.h) is present])
76         ])
77     ])
78 ])
79
80 # SYNOPSIS
81 #
82 #   AMANDA_WITH_DEBUG_DAYS
83 #
84 # OVERVIEW
85 #
86 #   Handles the --with-debug-days flag.  Defines and substitutes AMANDA_DEBUG_DAYS.
87 #
88 AC_DEFUN([AMANDA_WITH_DEBUG_DAYS],
89 [
90     AC_ARG_WITH(debug_days,
91         AS_HELP_STRING([--with-debug-days=NN],
92             [number of days to keep debugging files (default: 4)]),
93         [
94             debug_days="$withval"
95         ], [
96             debug_days="yes"
97         ]
98     )
99     case "$debug_days" in
100         n | no) 
101             AMANDA_DEBUG_DAYS=0 ;;
102         y |  ye | yes) 
103             AMANDA_DEBUG_DAYS=4 ;;
104         [[0-9]] | [[0-9]][[0-9]] | [[0-9]][[0-9]][[0-9]]) 
105             AMANDA_DEBUG_DAYS="$debug_days" ;;
106         *) AC_MSG_ERROR([*** --with-debug-days value not numeric or out of range.])
107           ;;
108     esac
109     AC_DEFINE_UNQUOTED(AMANDA_DEBUG_DAYS,$AMANDA_DEBUG_DAYS,
110         [Number of days to keep debugging files. ])
111     AC_SUBST(AMANDA_DEBUG_DAYS)
112 ])
113
114 # SYNOPSIS
115 #
116 #   AMANDA_WITH_TESTING
117 #
118 # OVERVIEW
119 #
120 #   Handles the --with-testing flag.  Defines and substitutes SERVICE_SUFFIX, and
121 #   defines AMANDA_SERVICE_NAME and KAMANDA_SERVICE_NAME.
122 #
123 AC_DEFUN([AMANDA_WITH_TESTING],
124 [
125     AC_ARG_WITH(testing,
126         AS_HELP_STRING([--with-testing@<:@=SUFFIX@:>@],
127             [use alternate service names with suffix (default 'test')]),
128         [
129             TESTING="$withval"
130         ], [
131             TESTING="no"
132         ]
133     )
134     case "$TESTING" in
135         n | no) SERVICE_SUFFIX="";;
136         y |  ye | yes) SERVICE_SUFFIX="-test";;
137         *) SERVICE_SUFFIX="-$TESTING";;
138     esac
139
140     AMANDA_SERVICE_NAME="amanda$SERVICE_SUFFIX"
141     KAMANDA_SERVICE_NAME="kamanda$SERVICE_SUFFIX"
142
143     AC_SUBST(SERVICE_SUFFIX)
144     AC_DEFINE_UNQUOTED(SERVICE_SUFFIX, "$SERVICE_SUFFIX",
145         [A suffix that will be appended to service names.
146      * Useful for testing in parallel with a working version. ])
147     AC_DEFINE_UNQUOTED(AMANDA_SERVICE_NAME,  "$AMANDA_SERVICE_NAME", 
148         [The name for the Amanda service. ])
149     AC_DEFINE_UNQUOTED(KAMANDA_SERVICE_NAME, "$KAMANDA_SERVICE_NAME", 
150         [The name for the Kerberized Amanda service. ])
151 ])
152
153 # SYNOPSIS
154 #
155 #   AMANDA_ENABLE_SYNTAX_CHECKS
156 #
157 # OVERVIEW
158 #
159 #   Handles the --enable-syntax-checks flag, which triggers syntax checks
160 #   for most 'make' targets, but causes spurious errors in all but the most
161 #   carefully-constructed build environments.
162
163 AC_DEFUN([AMANDA_DISABLE_SYNTAX_CHECKS],
164 [
165     AC_ARG_ENABLE(syntax-checks,
166         AS_HELP_STRING([--enable-syntax-checks],
167             [Perform syntax checks when installing - developers only]),
168         [
169             case "$enableval" in
170                 no) SYNTAX_CHECKS=false;;
171                 *)
172                     SYNTAX_CHECKS=true
173                     AMANDA_MSG_WARN([--enable-syntax-checks can cause build failures and should only be used by developers])
174                     ;;
175             esac
176         ], [
177             SYNTAX_CHECKS=false
178         ])
179
180     AM_CONDITIONAL(SYNTAX_CHECKS, $SYNTAX_CHECKS)
181 ])