1 include(atgeneral.m4) -*- Autoconf -*-
2 # M4 macros used in building Autoconf test suites.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 ## ---------------------------------------- ##
21 ## Macros specialized in testing Autoconf. ##
22 ## ---------------------------------------- ##
25 # AT_CONFIGURE_AC(BODY)
26 # ---------------------
27 # Create a full configure.ac running BODY, with a config header set up,
28 # AC_OUTPUT, and environement checking hooks.
29 m4_define([AT_CONFIGURE_AC],
30 [AT_CLEANUP_FILES(env-after state*)dnl
31 AT_DATA([configure.ac],
33 AC_CONFIG_AUX_DIR($top_srcdir/config)
34 AC_CONFIG_HEADER(config.h:config.hin)
35 AC_STATE_SAVE(before)]
42 # AT_CHECK_AUTOCONF(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
43 # -----------------------------------------------------------
44 # Also remove `configure.in', just in case one remained from a previous
46 m4_define([AT_CHECK_AUTOCONF],
47 [AT_CLEANUP_FILES(configure.in configure)dnl
48 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir $1],
49 m4_default([$2], [0]), [$3], [$4])])
54 m4_define([AT_CHECK_AUTOHEADER],
55 [AT_CLEANUP_FILES(config.hin)dnl
56 AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])])
59 # AT_CHECK_CONFIGURE(END-COMMAND,
61 # [SDOUT = IGNORE], STDERR)
62 # --------------------------------------------
63 # `top_srcdir' is needed so that `./configure' finds install-sh.
64 # Using --srcdir is more expensive.
65 m4_define([AT_CHECK_CONFIGURE],
66 [AT_CLEANUP_FILE_IFELSE([config.hin], [AT_CLEANUP_FILE(config.h)])dnl
67 AT_CLEANUP_FILE_IFELSE([defs.in], [AT_CLEANUP_FILE(defs)])dnl
68 AT_CLEANUP_FILES(config.log config.status config.cache)dnl
69 AT_CHECK([top_srcdir=$top_srcdir ./configure $1],
71 m4_default([$3], [ignore]), [$4],
72 [test $at_verbose = echo && echo "$srcdir/AT_LINE: config.log" && cat config.log])])
77 # Check that the full configure run remained in its variable name space,
78 # and cleaned up tmp files.
79 # me tests might exit prematurely when they find a problem, in
80 # which case `env-after' is probably missing. Don't check it then.
81 m4_define([AT_CHECK_ENV],
82 [if test -f state-env.before -a -f state-env.after; then
83 mv -f state-env.before expout
84 AT_CHECK([cat state-env.after], 0, expout)
86 if test -f state-ls.before -a -f state-ls.after; then
87 mv -f state-ls.before expout
88 AT_CHECK([cat state-ls.after], 0, expout)
93 # AT_CHECK_DEFINES(CONTENT)
94 # -------------------------
95 # Verify that config.h, once stripped is CONTENT.
96 # Stripping consists of keeping CPP lines (i.e. containing a hash),
97 # but those of automatically checked features (STDC_HEADERS etc.).
98 # AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
99 m4_define([AT_CHECK_DEFINES],
100 [AT_CHECK([[fgrep '#' config.h |
101 egrep -v 'STDC_HEADERS|STD(INT|LIB)|INTTYPES|MEMORY|STRING|UNISTD|SYS_(TYPES|STAT)']],,
105 # AT_CHECK_AUTOUPDATE
106 # -------------------
107 m4_define([AT_CHECK_AUTOUPDATE],
108 [AT_CHECK([autoupdate --version || exit 77], ignore, ignore, ignore)
109 AT_CHECK([autoupdate --autoconf-dir $at_top_srcdir], 0,
110 [], [autoupdate: `configure.ac' is updated
114 # _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS)
115 # --------------------------------------
116 # Create a minimalist configure.ac running the macro named
117 # NAME-OF-THE-MACRO, check that autoconf runs on that script,
118 # and that the shell runs correctly the configure.
119 # TOP_SRCDIR is needed to set the auxdir (some macros need `install-sh',
120 # `config.guess' etc.).
121 m4_define([_AT_CHECK_AC_MACRO],
122 [AT_CONFIGURE_AC([$1])
128 ])# _AT_CHECK_AC_MACRO
131 # AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS], [AUTOCONF-FLAGS])
132 # -----------------------------------------------------------------------
133 # Create a minimalist configure.ac running the macro named
134 # NAME-OF-THE-MACRO, check that autoconf runs on that script,
135 # and that the shell runs correctly the configure.
136 # TOP_SRCDIR is needed to set the auxdir (some macros need `install-sh',
137 # `config.guess' etc.).
139 # New macros are not expected to depend upon obsolete macros.
140 m4_define([AT_CHECK_MACRO],
142 AT_CONFIGURE_AC([m4_default([$2], [$1])])
144 AT_CHECK_AUTOCONF([m4_default([$4], [-W obsolete])])
153 # AT_CHECK_AU_MACRO(MACRO)
154 # ------------------------
155 # Create a minimalist configure.ac running the macro named
156 # NAME-OF-THE-MACRO, autoupdate this script, check that autoconf runs
157 # on that script, and that the shell runs correctly the configure.
158 # TOP_SRCDIR is needed to set the auxdir (some macros need
159 # `install-sh', `config.guess' etc.).
161 # Updated configure.ac shall not depend upon obsolete macros, which votes
162 # in favor of `-W obsolete', but since many of these macros leave a message
163 # to be removed by the user once her code ajusted, let's not check.
165 # Remove config.hin to avoid `autoheader: config.hin is unchanged'.
166 m4_define([AT_CHECK_AU_MACRO],
168 AT_CONFIGURE_AC([$1])