Debian Codegraph @

tests/atspecific.m4

raw
1 include(atgeneral.m4) -*- Autoconf -*-
2 # M4 macros used in building Autoconf test suites.
3
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)
7 # any later version.
8 #
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.
13 #
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
17 # 02111-1307, USA.
18
19
20 ## ---------------------------------------- ##
21 ## Macros specialized in testing Autoconf. ##
22 ## ---------------------------------------- ##
23
24
25 # AT_CONFIGURE_AC(BODY)
26 # ---------------------
27 # Create a full configure.ac running BODY, with a config header set up,
28 # AC_OUTPUT, and environment checking hooks.
29 m4_define([AT_CONFIGURE_AC],
30 [AT_CLEANUP_FILES(env-after state*)dnl
31 AT_DATA([configure.ac],
32 [[AC_INIT
33 AC_CONFIG_AUX_DIR($top_srcdir/config)
34 AC_CONFIG_HEADER(config.h:config.hin)
35 AC_STATE_SAVE(before)]
36 $1
37 [AC_OUTPUT
38 AC_STATE_SAVE(after)
39 ]])])
40
41
42 # AT_CHECK_AUTOCONF(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
43 # -----------------------------------------------------------
44 # Also remove `configure.in', just in case one remained from a previous
45 # run.
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])])
50
51
52 # AT_CHECK_AUTOHEADER
53 # -------------------
54 m4_define([AT_CHECK_AUTOHEADER],
55 [AT_CLEANUP_FILES(config.hin)dnl
56 AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])])
57
58
59 # AT_CHECK_CONFIGURE(END-COMMAND,
60 # [EXIT-STATUS = 0],
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],
70 [$2],
71 m4_default([$3], [ignore]), [$4],
72 [test $at_verbose = echo && echo "$srcdir/AT_LINE: config.log" && cat config.log])])
73
74
75 # AT_CHECK_ENV
76 # ------------
77 # Check that the full configure run remained in its variable name space,
78 # and cleaned up tmp files.
79 # The 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 expout; then chmod +w expout; fi
83 if test -f state-env.before -a -f state-env.after; then
84 mv state-env.before expout
85 AT_CHECK([cat state-env.after], 0, expout)
86 fi
87 if test -f state-ls.before -a -f state-ls.after; then
88 mv state-ls.before expout
89 AT_CHECK([cat state-ls.after], 0, expout)
90 fi
91 ])
92
93
94 # AT_CHECK_DEFINES(CONTENT)
95 # -------------------------
96 # Verify that config.h, once stripped is CONTENT.
97 # Stripping consists of keeping CPP lines (i.e. containing a hash),
98 # but those of automatically checked features (STDC_HEADERS etc.).
99 # AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
100 m4_define([AT_CHECK_DEFINES],
101 [AT_CHECK([[$FGREP '#' config.h |
102 $EGREP -v 'STDC_HEADERS|STD(INT|LIB)|INTTYPES|MEMORY|STRING|UNISTD|SYS_(TYPES|STAT)']],,
103 [$1])])
104
105
106 # AT_CHECK_AUTOUPDATE
107 # -------------------
108 m4_define([AT_CHECK_AUTOUPDATE],
109 [AT_CHECK([autoupdate --version || exit 77], ignore, ignore, ignore)
110 AT_CHECK([autoupdate --autoconf-dir $at_top_srcdir], 0,
111 [], [autoupdate: `configure.ac' is updated
112 ])])
113
114
115 # _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS)
116 # --------------------------------------
117 # Create a minimalist configure.ac running the macro named
118 # NAME-OF-THE-MACRO, check that autoconf runs on that script,
119 # and that the shell runs correctly the configure.
120 # TOP_SRCDIR is needed to set the auxdir (some macros need `install-sh',
121 # `config.guess' etc.).
122 m4_define([_AT_CHECK_AC_MACRO],
123 [AT_CONFIGURE_AC([$1])
124 $2
125 AT_CHECK_AUTOCONF
126 AT_CHECK_AUTOHEADER
127 AT_CHECK_CONFIGURE
128 AT_CHECK_ENV
129 ])# _AT_CHECK_AC_MACRO
130
131
132 # AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS], [AUTOCONF-FLAGS])
133 # -----------------------------------------------------------------------
134 # Create a minimalist configure.ac running the macro named
135 # NAME-OF-THE-MACRO, check that autoconf runs on that script,
136 # and that the shell runs correctly the configure.
137 # TOP_SRCDIR is needed to set the auxdir (some macros need `install-sh',
138 # `config.guess' etc.).
139 #
140 # New macros are not expected to depend upon obsolete macros.
141 m4_define([AT_CHECK_MACRO],
142 [AT_SETUP([$1])
143 AT_CONFIGURE_AC([m4_default([$2], [$1])])
144
145 AT_CHECK_AUTOCONF([m4_default([$4], [-W obsolete])])
146 AT_CHECK_AUTOHEADER
147 AT_CHECK_CONFIGURE
148 AT_CHECK_ENV
149 $3
150 AT_CLEANUP()dnl
151 ])# AT_CHECK_MACRO
152
153
154 # AT_CHECK_AU_MACRO(MACRO)
155 # ------------------------
156 # Create a minimalist configure.ac running the macro named
157 # NAME-OF-THE-MACRO, autoupdate this script, check that autoconf runs
158 # on that script, and that the shell runs correctly the configure.
159 # TOP_SRCDIR is needed to set the auxdir (some macros need
160 # `install-sh', `config.guess' etc.).
161 #
162 # Updated configure.ac shall not depend upon obsolete macros, which votes
163 # in favor of `-W obsolete', but since many of these macros leave a message
164 # to be removed by the user once her code is adjusted, let's not check.
165 #
166 # Remove config.hin to avoid `autoheader: config.hin is unchanged'.
167 m4_define([AT_CHECK_AU_MACRO],
168 [AT_SETUP([$1])
169 AT_CONFIGURE_AC([$1])
170
171 AT_CHECK_AUTOCONF
172 AT_CHECK_AUTOHEADER
173 AT_CHECK_CONFIGURE
174 AT_CHECK_ENV
175
176 rm config.hin
177 AT_CHECK_AUTOUPDATE
178
179 AT_CHECK_AUTOCONF
180 AT_CHECK_AUTOHEADER
181 AT_CHECK_CONFIGURE
182 AT_CHECK_ENV
183
184 AT_CLEANUP()dnl
185 ])# AT_CHECK_UPDATE