a26ef3825519b8f925a7b12024376e220f7d226c
[platform/upstream/automake.git] / tests / acloca18.test
1 #! /bin/sh
2 # Copyright (C) 2005, 2006, 2008, 2010, 2011, 2012 Free Software
3 # Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Test for --install with #serial numbers.
19
20 am_create_testdir=empty
21 . ./defs || Exit 1
22
23 cat > configure.in << 'END'
24 AC_INIT
25 AM_MACRO1
26 AM_MACRO2
27 END
28
29 mkdir 1 2 3 4 5 6
30
31 cat >1/m1.m4 <<EOF
32 #serial 1.8.1230.9
33 AC_DEFUN([AM_MACRO1], [:macro11:])
34 AC_DEFUN([AM_MACRO2], [:macro21:])
35 EOF
36
37 cat >2/m1.m4 <<EOF
38 #serial 1.8.1231.9
39 AC_DEFUN([AM_MACRO1], [:macro12:])
40 EOF
41
42 cat >3/m2.m4 <<EOF
43 #serial 13
44 AC_DEFUN([AM_MACRO2], [:macro23:])
45 EOF
46
47 cat >3/m1.m4 <<EOF
48 #serial 1.8.1230.1
49 AC_DEFUN([AM_MACRO1], [:macro13:])
50 EOF
51
52 cat >4/mumble.m4 <<EOF
53 #serial 0
54 AC_DEFUN([AM_MACRO1], [:macro14:])
55 EOF
56
57 cat >5/ill-formed.m4 <<EOF
58 #serial bla
59 #serial .2
60 #serial
61 AC_DEFUN([AM_MACRO1], [:macro15:])
62 EOF
63
64 cat >6/after-def.m4 <<EOF
65 AC_DEFUN([AM_MACRO1], [:macro16:])
66 #serial 1
67 EOF
68
69 clean_stale ()
70 {
71   rm -rf aclocal.m4 configure autom4te*.cache
72 }
73
74 $ACLOCAL -I 1 -I 2 -I 3 -I 4
75 $AUTOCONF
76 $FGREP ':macro11:' configure
77 $FGREP ':macro21:' configure
78
79 clean_stale
80 $ACLOCAL  -I 1 -I 2 -I 3 -I 4 --install
81 $AUTOCONF
82 $FGREP ':macro12:' configure
83 $FGREP ':macro23:' configure
84
85 cp -f aclocal.m4 aclocal-m4.sav
86 clean_stale
87 mv -f aclocal-m4.sav aclocal.m4
88 $ACLOCAL -I 4 -I 1 -I 2 -I 3 --install --dry-run
89 $AUTOCONF
90 $FGREP ':macro12:' configure
91 $FGREP ':macro23:' configure
92
93 clean_stale
94 $ACLOCAL -I 4 -I 1 -I 2 -I 3 --install
95 $AUTOCONF
96 $FGREP ':macro14:' configure
97 $FGREP ':macro23:' configure
98
99 clean_stale
100 $ACLOCAL -I 4 -I 1 -I 2 --install 2>stderr && { cat stderr >&2; Exit 1; }
101 cat stderr >&2
102 grep 'macro.*AM_MACRO2.*not found' stderr
103
104 clean_stale
105 $ACLOCAL -I 4 -I 1 --install
106 $AUTOCONF
107 $FGREP ':macro14:' configure
108 $FGREP ':macro21:' configure
109
110 mkdir acdir
111 ACLOCAL="$ACLOCAL --system-acdir acdir"
112
113 cat >acdir/m1.m4 <<EOF
114 #serial 456
115 AC_DEFUN([AM_MACRO1], [:macro1d:])
116 AC_DEFUN([AM_MACRO2], [:macro2d:])
117 EOF
118 clean_stale
119 $ACLOCAL -I 4 -I 1 --diff=diff >stdout 2>stderr || {
120   cat stderr >&2
121   cat stdout
122   Exit 1
123 }
124 cat stderr >&2
125 cat stdout
126 grep '#serial 456' stdout
127 test ! -f 4/m1.m4
128 grep 'installing.*4/m1\.m4' stderr
129
130 $ACLOCAL -I 5 2>stderr && { cat stderr >&2; Exit 1; }
131 cat stderr >&2
132 test `grep -c 'ill-formed serial' stderr` -eq 3
133
134 $ACLOCAL -I 6 2>stderr && { cat stderr >&2; Exit 1; }
135 cat stderr >&2
136 grep 'serial.*before any macro definition' stderr
137
138 :