Removing non-necessary calls for delete email addresses
[libgcal.git] / m4 / auxdevel.m4
blobca934429b75851fef39e0f8a98f7ceb4bd677b3c
1 # this is my first m4 script, the style is probably completely wrong
2 # TODO: read carefully the docs about quotation, quote and indent properly
4 # Make a path absolute and remove "..", ".", "//", final slash.
6 # If you find a bug, please fix it also in the sanitize_path bash script
7 # (and test with the test-sanitize script).
8 # AC_SANITIZE_PATH([/path/to/be/sanitized], [output_variable_name])
10 # remember that `@<:@' = `[' and `@:>@' = `]'
11 # TODO: change AC_MSG_NOTICEs with a proper debug macro
12 AC_DEFUN([AC_SANITIZE_PATH],
15 # AC_MSG_NOTICE([Sanitize: called with <$1>, <$2>]) # <-
17 ac_nomiddledot='s;/\./;/;g'
18 ac_noenddot='s;/\./\?$;;'
19 ac_noslashslash='s;//\+;/;g'
20 ac_nodotdot='s;@<:@^/@:>@*/\.\.\(/\|$\);;' # note: this removes only one foo/..
21 ac_nofinalslash='s;\(.\)/$;\1;g'
23 # absolutize
24 if echo "$1" | grep '^/' >/dev/null 2>&1 ; then
25 #    AC_MSG_NOTICE([Sanitize: I think <$1> is an absolute directory]) # <-
26     $2="$1"
27 else
28 #    AC_MSG_NOTICE([Sanitize: I think <$1> is a relative directory]) # <-
29     $2="`pwd -P`/$1"
30 #    AC_MSG_NOTICE([Sanitize: Absolutized to <${$2}>]) # <-
33 # remove single dots
34 for ac_transform in "$ac_nomiddledot" "$ac_noenddot"; do
35     $2="`echo "${$2}" | sed -e "$ac_transform"`"
36 #    AC_MSG_NOTICE([Sanitize: Removed dots to <${$2}>]) # <-
37 done
39 # remove spurious slashes
40 $2=`echo "${$2}" | sed -e "$ac_noslashslash"`
41 # AC_MSG_NOTICE([Sanitize: Removed slashes to <${$2}>]) # <-
43 # one while to remove them all
44 while echo "${$2}" | grep '\.\.\(/\|$\)' >/dev/null 2>&1; do
45     $2=`echo "${$2}" | sed -e "$ac_nodotdot"`
46 #    AC_MSG_NOTICE([Sanitize: Removed dotdots to <${$2}>]) # <-
47 done
49 # remove final slash
50 $2=`echo "${$2}" | sed -e "$ac_nofinalslash"`
51 # AC_MSG_NOTICE([Sanitize: Removed final slash to <${$2}>]) # <-
53 if ! test "${$2}" ; then
54 # Got an empty path, I hope it's root...
55 #    AC_MSG_NOTICE([Sanitize: After all that, I think it is / ]) # <-
56     $2=/
58 # AC_MSG_NOTICE([Sanitize: from $1, defined $2 to <${$2}>])
61 # create and AC_SUBS sanitized abs_ versions of the following variables:
62 # - csourcedir
63 # - headerdir
64 # - utestdir
65 # - docdir
66 # - mytestdir
67 AC_DEFUN([AC_DEVEL_ABSDIRS], [
69 if test "$csourcedir"; then
70   AC_SANITIZE_PATH([$csourcedir], abs_csourcedir)
71   AC_SUBST(abs_csourcedir)
73 if test "$headerdir"; then
74   AC_SANITIZE_PATH([$headerdir], abs_headerdir)
75   AC_SUBST(abs_headerdir)
77 if test "$utestdir"; then
78   AC_SANITIZE_PATH([$utestdir], abs_utestdir)
79   AC_SUBST(abs_utestdir)
81 if test "$docdir"; then
82   AC_SANITIZE_PATH([$docdir], abs_docdir)
83   AC_SUBST(abs_docdir)
85 if test "$mytestdir"; then
86   AC_SANITIZE_PATH([$mytestdir], abs_mytestdir)
87   AC_SUBST(abs_mytestdir)
89 if test "$lcov_ignore_dirs"; then
90   AC_SANITIZE_PATH([$lcov_ignore_dirs], abs_lcov_ignore_dirs)
91   AC_SUBST(abs_lcov_ignore_dirs)
96 # This macro gives configure options for enabling Check unit testing, debugging
97 # symbols, efence, LCOV, and a standard set of warnings.  It also provides the
98 # --enable-devel, which sets all five options.
100 # For each option foo, if --enable-foo was asked, AM_AUX_DEVEL sets
101 # shell variable $ac_foo_enabled to 'yes' and Automake conditional FOO to
102 # true.
104 # --enable-check calls AM_PATH_CHECK.  Note that if check.m4 was
105 #   not found in the *maintainer's* machine (when autoconf is run), the
106 #   resulting configure script will not have check support!
108 # --enable-debug is somewhat intrusive.  It defines DEBUG and
109 #   forces CFLAGS to "-g -O0", overriding the user environment variable.
111 # --enable-efence checks for the efence library.
113 # --enable-lcov checks for gcov and lcov.
115 # --enable-warnings adds a lot of extra gcc warnings flags in the
116 #   variable ac_devel_default_warnings.
118 # See also the file auxdevel.am, with Makefile usage of the conditionals set by
119 # these options.
121 # TODO: check for Doxygen binary
123 AC_DEFUN([AC_DEVEL_MACROS],
126 ac_isodate="`date +%Y-%m-%d`"
127 AC_SUBST(ac_isodate)
129 AC_ARG_ENABLE(warnings,
130   AS_HELP_STRING([--enable-warnings], [Enable extra GCC warnings flags]),
131     [ac_warnings_enabled=$enableval], [ac_warnings_enabled=no])
132 AC_ARG_ENABLE(efence,
133   AS_HELP_STRING([--enable-efence], [Enable EletricFence]),
134     [ac_efence_enabled=$enableval], [ac_efence_enabled=no])
135 AC_ARG_ENABLE(debug,
136   AS_HELP_STRING([--enable-debug],
137     [Define DEBUG, force CFLAGS to "-g -O0" (overrides environment variable)]),
138   [ac_debug_enabled=$enableval], [ac_debug_enabled=no])
139 AC_ARG_ENABLE(lcov,
140   AS_HELP_STRING([--enable-lcov], [Enable gcov/lcov support]),
141     [ac_lcov_enabled=$enableval], [ac_lcov_enabled=no])
143 AC_ARG_WITH(buildversion,
144   AS_HELP_STRING([--with-buildversion=BUILDVERSION],
145     [Build version string (default: ISO date of configuration]),
146   [ac_buildversion=$withval],
147   [ac_buildversion="$ac_isodate"])
150 # Unfortunately this m4_ifdef doesn't work with older versions of autotools, so
151 # if you want to support them, you should distribute check.m4 with your package.
152 # Failing to do that will result in a cryptic error message if the user don't
153 # have Check installed.
155 # Also note that if you use this feature and don't have Check when calling
156 # autoconf, the resulting `configure' script will lack Check support.  This is
157 # probably not what you want, so make sure that the maintainer has Check
158 # installed when running `make dist'.
159 m4_ifdef([AM_PATH_CHECK],
160   [
161     AC_ARG_ENABLE(check,
162       AS_HELP_STRING([--enable-check], [Enables unit testing with Check]),
163                      [ac_check_enabled=$enableval], [ac_check_enabled=no])
164     AC_ARG_ENABLE(devel,
165       AS_HELP_STRING([--enable-devel],
166        [Equivalent to --enable-warnings --enable-efence --enable-debug
167        --enable-check --enable-lcov]),
168     [ac_warnings_enabled=$enableval
169      ac_efence_enabled=$enableval
170      ac_debug_enabled=$enableval
171      ac_check_enabled=$enableval
172      ac_lcov_enabled=$enableval])
173  ],
175     AC_DIAGNOSE([syntax], [Could not find check.m4, no support for unit testing.])
176     AC_ARG_ENABLE(devel,
177       AS_HELP_STRING([--enable-devel],
178        [Equivalent to --enable-warnings --enable-efence --enable-debug
179        --enable-lcov]),
180     [ac_warnings_enabled=$enableval
181      ac_efence_enabled=$enableval
182      ac_debug_enabled=$enableval
183      ac_lcov_enabled=$enableval])
184  ])
186 if test "$ac_warnings_enabled" = yes; then
187   AC_SUBST(ac_devel_default_warnings, ["-Wall -W \
188 -Wmissing-declarations -Wmissing-prototypes \
189 -Wredundant-decls -Wshadow -Wbad-function-cast \
190 -Wcast-qual -Wno-pointer-sign"])
191 else
192   AC_SUBST(ac_devel_default_warnings, ["-Wall -W -Wno-pointer-sign"])
195 if test "$ac_efence_enabled" = yes; then
196   AC_CHECK_LIB(efence, malloc, [],
197     [AC_MSG_ERROR([Linking to efence asked, but could not find the library])])
200 m4_ifdef([AM_PATH_CHECK],
201   [if test "$ac_check_enabled" = yes; then
202     AM_PATH_CHECK
203    fi])
205 # TODO: find unobtrusive way of disabling optimization and enabling debug
206 if test "$ac_debug_enabled" = yes; then
207   CFLAGS="-g -O0"
208   AC_MSG_WARN([Using --enable-debug, overriding user CFLAGS.])
209   AC_DEFINE([DEBUG], [1], [Set if in debug mode])
210 else
211   AC_DEFINE([NDEBUG], [1], [Set if not in debug mode])
214 # TODO: support --with-lcov, --with-gcov
215 # TODO: check also for lcov.pl, genhtml.pl, etc.
216 if test "$ac_lcov_enabled" = yes; then
217   AC_CHECK_PROGS(gcov, gcov)
218   if ! test "$gcov"; then
219     AC_MSG_ERROR([Could not find gcov utility, check your gcc instalation])
220   fi
221   AC_CHECK_LIB(gcov, __gcov_init, [], [])
222   AC_CHECK_PROGS(lcov, lcov)
223   AC_CHECK_PROGS(genhtml, genhtml)
224   AC_CHECK_PROGS(gendesc, gendesc)
225   AC_CHECK_PROGS(geninfo, geninfo)
226   if ! test "$lcov" || ! test "$genhtml" || ! test "$gendesc" || 
227      ! test "$geninfo"; then
228     AC_MSG_ERROR([Could not find lcov utilities, do you have lcov installed?])
229   fi
232 AM_CONDITIONAL(CHECK, [test "$ac_check_enabled" = yes])
233 AM_CONDITIONAL(DEBUG, [test "$ac_debug_enabled" = yes])
234 AM_CONDITIONAL(EFENCE, [test "$ac_efence_enabled" = yes])
235 AM_CONDITIONAL(LCOV, [test "$ac_lcov_enabled" = yes])
236 AM_CONDITIONAL(WARNINGS, [test "$ac_warnings_enabled" = yes])
238 # these allow us to append to possibly empty variables in auxdevel.am
239 AC_SUBST([AM_CFLAGS],[''])
240 AC_SUBST([LDADD],[''])
241 AC_SUBST([EXTRA_DIST],[''])
242 AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],[''])
243 AC_SUBST([CLEANFILES],[''])
244 AC_SUBST([MOSTLYCLEANFILES],[''])
246 AC_DEFINE_UNQUOTED(BUILDVERSION, "$ac_buildversion", [Tag or version of build])
248 # we need to support autoconf 2.58, in which abs_builddir/abs_srcdir are not
249 # absolute at all
250 # these are also used in auxdevel.am
251 AC_SUBST(ac_devel_abs_builddir, `pwd -P`) # builddir is defined as '.'
253 AC_SANITIZE_PATH([$srcdir], ac_devel_abs_srcdir)
254 AC_SUBST(ac_devel_abs_srcdir)