1#! /bin/sh
2# Copyright (C) 2003-2021 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 <https://www.gnu.org/licenses/>.
16
17# Make sure aclocal define macros in the same order as -I's.
18# This is the similar to aclocal-I-order-1.sh, with the macro calls
19# reversed (it did make a difference).
20#
21# Also check for --install.
22
23# TODO: write a sister test that doesn't use a 'dirlist' file, but
24# TODO: puts third-party macros directly into 'acdir'.
25
26am_create_testdir=empty
27. test-init.sh
28
29cat > configure.ac << 'END'
30AC_INIT
31MACRO2
32MACRO1
33MACRO3
34END
35
36ACLOCAL="$ACLOCAL --system-acdir acdir"
37
38mkdir m4_1 m4_2 acdir acdir2
39echo ./acdir2 > acdir/dirlist
40
41cat >m4_1/somedefs.m4 <<EOF
42AC_DEFUN([MACRO1], [:macro11:])
43AC_DEFUN([MACRO2], [:macro21:])
44EOF
45
46cat >m4_2/somedefs.m4 <<EOF
47AC_DEFUN([MACRO1], [:macro12:])
48EOF
49
50cat >acdir2/macro.m4 <<EOF
51AC_DEFUN([MACRO3], [:macro33:])
52EOF
53
54$ACLOCAL -I m4_1 -I m4_2
55$AUTOCONF
56$FGREP ':macro11:' configure
57$FGREP ':macro21:' configure
58$FGREP ':macro33:' configure
59grep MACRO3 aclocal.m4
60test ! -e m4_1/macro.m4
61test ! -e m4_2/macro.m4
62
63$sleep
64
65$ACLOCAL -I m4_2 -I m4_1
66$AUTOCONF
67$FGREP ':macro12:' configure
68$FGREP ':macro21:' configure
69$FGREP ':macro33:' configure
70grep MACRO3 aclocal.m4
71test ! -e m4_1/macro.m4
72test ! -e m4_2/macro.m4
73
74$sleep
75
76$ACLOCAL -I m4_1 -I m4_2 --install
77$AUTOCONF
78$FGREP ':macro11:' configure
79$FGREP ':macro21:' configure
80$FGREP ':macro33:' configure
81grep MACRO3 aclocal.m4 && exit 1
82test -f m4_1/macro.m4
83test ! -e m4_2/macro.m4
84cp aclocal.m4 copy.m4
85
86$sleep
87
88echo '#GREPME' >>acdir2/macro.m4
89$ACLOCAL -I m4_1 -I m4_2 --install
90$AUTOCONF
91$FGREP ':macro11:' configure
92$FGREP ':macro21:' configure
93$FGREP ':macro33:' configure
94grep MACRO3 aclocal.m4 && exit 1
95grep GREPME m4_1/macro.m4 && exit 1
96test -f m4_1/macro.m4
97test ! -e m4_2/macro.m4
98diff aclocal.m4 copy.m4
99
100:
101