tests: work around strangeness in MSYS
[automake.git] / tests / backcompat2.test
blob57badf38e823b5f796be5bfaed20ec3b729d0886
1 #! /bin/sh
2 # Copyright (C) 2010, 2011 Free Software Foundation, Inc.
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.
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, see <http://www.gnu.org/licenses/>.
17 # Backward-compatibility test: check that AM_INIT_AUTOMAKE with two or
18 # three arguments does AC_DEFINE the symbols PACKAGE and VERSION iff the
19 # third argument is empty or non-existent.
21 . ./defs || Exit 1
23 # A trick to make the test run muuuch faster, by avoiding repeated
24 # runs of aclocal (one order of magnitude improvement in speed!).
25 echo 'AC_INIT(x,0) AM_INIT_AUTOMAKE' > configure.in
26 $ACLOCAL
27 rm -rf configure.in autom4te.*
29 cat > config.h.in <<'END'
30 #undef PACKAGE
31 #undef VERSION
32 END
34 for am_arg3 in ':' 'false' '#' ' '; do
35 unindent > configure.in <<END
36 AC_INIT
37 AC_CONFIG_HEADERS([config.h])
38 AM_INIT_AUTOMAKE([pkgname], [pkgversion], [$am_arg3])
39 AC_OUTPUT
40 END
41 cat configure.in # For debugging.
42 $AUTOCONF
43 ./configure
44 cat config.h # For debugging.
45 # The non-empty third argument should prevent PACKAGE and VERSION
46 # from being AC_DEFINE'd.
47 $EGREP 'pkg(name|version)' config.h && Exit 1
48 # This is required because even relatively-recent versions of the
49 # BSD shell wrongly exit when the `errexit' shell flag is active if
50 # the last command of a compound statement fails, even if it should
51 # be protected by the use of "&&".
53 done
55 for am_extra_args in '' ',' ', []'; do
56 unindent > configure.in <<END
57 AC_INIT
58 AC_CONFIG_HEADERS([config.h])
59 AM_INIT_AUTOMAKE([pkgname], [pkgversion]$am_extra_args)
60 AC_OUTPUT
61 END
62 cat configure.in # For debugging.
63 $AUTOCONF
64 ./configure
65 cat config.h # For debugging.
66 grep '^ *# *define *PACKAGE *"pkgname" *$' config.h
67 grep '^ *# *define *VERSION *"pkgversion" *$' config.h
68 done