]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* tests/atspecific.m4: Really added to the CVS repository.
authorAkim Demaille <akim@epita.fr>
Fri, 11 Feb 2000 09:01:24 +0000 (09:01 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 11 Feb 2000 09:01:24 +0000 (09:01 +0000)
ChangeLog
tests/atspecific.m4 [new file with mode: 0644]

index 216ccfd977dcd2658a979de7f1263614b248f009..d0b33e7018c662abc9bcb5da077de71ffe281706 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2000-02-11  Akim Demaille  <akim@epita.fr>
+
+       * tests/atspecific.m4: Really added to the CVS repository.
+
 2000-02-11  Akim Demaille  <akim@epita.fr>
 
        Don't use `cat -s' to single out new-lines, it is not portable.
diff --git a/tests/atspecific.m4 b/tests/atspecific.m4
new file mode 100644 (file)
index 0000000..7560c31
--- /dev/null
@@ -0,0 +1,181 @@
+divert(-1)                                             -*- Autoconf -*-
+# `m4' macros used in building Autoconf test suites.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+## ------------------------------ ##
+## Setting up base layer macros.  ##
+## ------------------------------ ##
+
+include(atgeneral.m4)divert(-1)
+
+# Until the day Autotest, Ad'HoC and Autoconf share the same libm4, we
+# have to reinstall some m4 builtins that atgeneral.m4 undefined.
+AT_DEFINE([m4_shift],
+[builtin([shift], $@)])
+AT_DEFINE([define],
+[builtin([define], $@)])
+
+# m4_for(VARIABLE, FROM, TO, EXPRESSION)
+# --------------------------------------
+# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO.
+# Both limits are included.
+AT_DEFINE([m4_for],
+[pushdef([$1], [$2])_m4_for([$1], [$2], [$3], [$4])popdef([$1])])
+
+AT_DEFINE([_m4_for],
+[$4[]ifelse($1, [$3], [],
+            [define([$1], incr($1))_m4_for([$1], [$2], [$3], [$4])])])
+
+
+
+# m4_foreach(VARIABLE, LIST, EXPRESSION)
+# --------------------------------------
+# Expand EXPRESSION assigning to VARIABLE each value of the LIST
+# (LIST should have the form `[(item_1, item_2, ..., item_n)]'),
+# i.e. the whole list should be *quoted*.  Quote members too if
+# you don't want them to be expanded.
+#
+# This macro is robust to active symbols:
+#    define(active, ACTIVE)
+#    m4_foreach([Var], [([active], [b], [active])], [-Var-])end
+#    => -active--b--active-end
+define(m4_foreach,
+[pushdef([$1], [])_m4_foreach($@)popdef([$1])])
+
+dnl Low level macros used to define m4_foreach
+define(m4_car, [[$1]])
+define(_m4_foreach,
+[ifelse($2, [()], ,
+        [define([$1], [m4_car$2])$3[]_m4_foreach([$1],
+                                                 [(m4_shift$2)],
+                                                 [$3])])])
+
+# m4_match(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)
+# ----------------------------------------------------
+# m4 equivalent of
+#
+# if (SWITCH =~ RE1)
+#   VAL1;
+# elif (SWITCH =~ RE2)
+#   VAL2;
+# elif ...
+#   ...
+# else
+#   DEFAULT
+#
+# All the values are optional, and the macro is robust to active symbols
+# properly quoted.
+AT_DEFINE(m4_match,
+[ifelse([$#], 0, [],
+       [$#], 1, [],
+       [$#], 2, [$2],
+        regexp([$1], [$2]), -1, [m4_match([$1],
+                                          m4_shift(m4_shift(m4_shift($@))))],
+        [$3])])
+
+
+
+
+## ---------------------------------------- ##
+## Macros specialized in testing Autoconf.  ##
+## ---------------------------------------- ##
+
+
+
+# AT_TEST_MACRO(NAME-OF-THE-MACRO, [MACRO-USE], [ADDITIONAL-CMDS])
+# ----------------------------------------------------------------
+# Create a minimalist configure.in running the macro named
+# NAME-OF-THE-MACRO, check that autoconf runs on that script,
+# and that the shell runs correctly the configure.
+AT_DEFINE(AT_TEST_MACRO,
+[AT_SETUP([$1])
+
+dnl Produce the configure.in
+AT_DATA(configure.in,
+[AC_INCLUDE(actest.m4)
+AC_INIT
+AC_CONFIG_HEADER(config.h:config.hin)
+AC_ENV_SAVE(expout)
+ifelse([$2],,[$1], [$2])
+AC_ENV_SAVE(env-after)
+AC_OUTPUT
+])
+
+dnl FIXME: Here we just don't consider the stderr from Autoconf.
+dnl Maybe some day we could be more precise and filter out warnings.
+dnl The problem is that currently some warnings are spread on several
+dnl lines, so grepping -v warning is not enough.
+AT_CHECK([../autoconf -m .. -l $at_srcdir], 0,, ignore)
+AT_CHECK([../autoheader -m .. -l $at_srcdir], 0,, ignore)
+AT_CHECK([./configure], 0, ignore, ignore)
+AT_CHECK([cat env-after], 0, expout)
+$3
+AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+])dnl AT_TEST_MACRO
+
+
+
+
+# TEST_MACRO(NAME-OF-THE-MACRO)
+# -----------------------------
+# Run AT_TEST_MACRO(NAME-OF-THE-MACRO) on selected macros only.
+# There are macros which require arguments.  We cannot run them without.
+# Below are some macros directly used with other macros.  It is
+# therefore useless to test them several times.
+# - AC_CHECK decls, files, funcs, members, types, headers
+#   Already performed in the semantical tests.
+# - AC_CONFIG
+#   They fail when the source does not exist.
+# - AC_INIT
+#   AC_INIT includes all the AC_INIT macros.  Note that there is an
+#   infinite m4 recursion if AC_INIT it used twice.
+# - AC_PROG_(CC|CXX|F77)_(GNU|WORKS)
+#   are used in AC_PROG_CC etc.
+# - AC_TRY
+#   Used in many places.
+# - _AC_
+#   Internal macros are used elsewhere.
+AT_DEFINE(TEST_MACRO,
+[m4_match([$1],
+         [^AC_ARG_VAR$],,
+         [^AC_CHECK_\(DECL\|FILE\|FUNC\|HEADER\|MEMBER\|SIZEOF\|TYPE\)S?$],,
+         [^AC_CHECK_PROGS$],,
+         [^AC_CONFIG],,
+         [^AC_INIT],,
+         [^AC_LINKER_OPTION$],,
+         [^AC_LINK_FILES$],,
+         [^AC_LIST_MEMBER_OF$],,
+         [^AC_PATH_PROGS$],,
+         [^AC_PROG_\(CC\|CXX\|F77\)_\(GNU\|WORKS\)$],,
+         [^AC_REPLACE_FUNCS$],,
+         [^AC_SEARCH_LIBS$],,
+         [^AC_TRY],,
+         [^_AC_],,
+
+         [AT_TEST_MACRO([$1])])])
+
+
+# AT_CHECK_DEFINES(CONTENT)
+# -------------------------
+# Verify that config.h, once stripped is CONTENT.
+# Stripping consists of keeping CPP lines (i.e. containing a hash),
+# but those of automatically checked features (STDC_HEADERS etc.).
+# AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
+AT_DEFINE(AT_CHECK_DEFINES,
+[AT_CHECK([fgrep '#' config.h |  grep -v 'STDC_HEADERS'],, [$1])])
+
+divert(0)dnl