Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / acloca14.test
1 #! /bin/sh
2 # Copyright (C) 2004, 2008, 2010 Free Software Foundation, Inc.
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, see <http://www.gnu.org/licenses/>.
16
17 # Make sure m4_included files are also scanned for definitions.
18 # Report from Phil Edwards.
19
20 required=GNUmake
21 . ./defs || Exit 1
22
23 set -e
24
25 cat >> configure.in << 'END'
26 AM_PROG_LIBTOOL
27 AC_OUTPUT
28 END
29
30 echo 'm4_include([a.m4])' > acinclude.m4
31 echo 'm4_include([b.m4])' > a.m4
32
33 cat >b.m4 <<EOF
34 m4_include([c.m4])
35 AC_DEFUN([AM_PROG_LIBTOOL],
36 [AC_REQUIRE([SOMETHING])dnl
37 AC_REQUIRE([SOMETHING_ELSE])dnl
38 ])
39
40 AC_DEFUN([SOMETHING])
41 EOF
42
43 echo 'm4_include([d.m4])' > c.m4
44 echo 'AC_DEFUN([SOMETHING_ELSE])' >d.m4
45
46 mkdir defs
47 echo 'AC_DEFUN([SOMETHING_ELSE])' >defs/e.m4
48 echo 'AC_DEFUN([ANOTHER_MACRO])' >defs/f.m4
49
50 cat >>Makefile.am<<\EOF
51 ACLOCAL_AMFLAGS = -I defs
52 testdist1: distdir
53         test -f $(distdir)/acinclude.m4
54         test -f $(distdir)/a.m4
55         test -f $(distdir)/b.m4
56         test -f $(distdir)/c.m4
57         test -f $(distdir)/d.m4
58         test ! -d $(distdir)/defs
59 testdist2: distdir
60         test -f $(distdir)/acinclude.m4
61         test -f $(distdir)/a.m4
62         test -f $(distdir)/b.m4
63         test -f $(distdir)/c.m4
64         test -f $(distdir)/d.m4
65         test ! -f $(distdir)/defs/e.m4
66         test -f $(distdir)/defs/f.m4
67 EOF
68
69 $ACLOCAL -I defs
70
71 $FGREP acinclude.m4 aclocal.m4
72 # None of the following macro should be included.  acinclude.m4
73 # includes the first four, and the last two are not needed at all.
74 $FGREP a.m4 aclocal.m4 && Exit 1
75 $FGREP b.m4 aclocal.m4 && Exit 1
76 $FGREP c.m4 aclocal.m4 && Exit 1
77 $FGREP d.m4 aclocal.m4 && Exit 1
78 $FGREP defs/e.m4 aclocal.m4 && Exit 1
79 $FGREP defs/f.m4 aclocal.m4 && Exit 1
80
81 $AUTOCONF
82 $AUTOMAKE
83
84 ./configure
85 $MAKE testdist1
86
87 cp aclocal.m4 stamp
88 $sleep
89
90 cat >>c.m4 <<\EOF
91 AC_DEFUN([FOO], [ANOTHER_MACRO])
92 EOF
93
94 $MAKE
95
96 # Because c.m4 has changed, aclocal.m4 must have been rebuilt.
97 test `ls -1t aclocal.m4 stamp | sed 1q` = aclocal.m4
98 # However, since FOO is not used, f.m4 should not be included
99 # and the contents of aclocal.m4 should remain the same
100 diff aclocal.m4 stamp
101
102 # If FOO where to be used, that would be another story, of course.
103 cat >>configure.in <<EOF
104 FOO
105 EOF
106
107 cp aclocal.m4 stamp
108 $sleep
109
110 $MAKE
111
112 $FGREP defs/f.m4 aclocal.m4
113 $MAKE testdist2
114
115 # Make sure aclocal diagnose missing included files with correct `file:line:'.
116 rm -f b.m4
117 $ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
118 cat stderr >&2
119 grep 'a\.m4:1: .*b\.m4.*does not exist' stderr
120
121 :