automake: recognize all-numeric MAJ.MIN.MICROa.ALPHA versions better.
[automake.git] / t / aclocal-path-precedence.sh
blob5dbf20f04cffe8117dc02186d3f3b25ac08b96f9
1 #! /bin/sh
2 # Copyright (C) 2011-2024 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 <https://www.gnu.org/licenses/>.
17 # Check precedence rules for ACLOCAL_PATH.
19 am_create_testdir=empty
20 . test-init.sh
22 cat > configure.ac << 'END'
23 AC_INIT([foo], [1.0])
24 AM_INIT_AUTOMAKE
25 FOO_MACRO
26 BAR_MACRO
27 AC_PROG_LIBTOOL
28 AM_GNU_GETTEXT
29 AC_OUTPUT
30 END
32 mkdir mdir1 mdir2 mdir3 sysdir extradir
34 cat > mdir1/foo1.m4 << 'END'
35 AC_DEFUN([FOO_MACRO], [::pass-foo::])
36 END
38 cat > mdir2/foo2.m4 << 'END'
39 AC_DEFUN([FOO_MACRO], [::fail-foo::])
40 END
42 cat > mdir1/baz.m4 << 'END'
43 AC_DEFUN([BAR_MACRO], [::fail-bar::])
44 END
46 cat > mdir3/bar.m4 << 'END'
47 AC_DEFUN([BAR_MACRO], [::pass-bar::])
48 END
50 cat > mdir2/quux.m4 << 'END'
51 AC_DEFUN([AM_INIT_AUTOMAKE], [::fail-init::])
52 AC_DEFUN([AC_PROG_LIBTOOL], [::pass-libtool::])
53 AC_DEFUN([AM_GNU_GETTEXT], [::pass-gettext::])
54 END
56 cat > sysdir/libtool.m4 << 'END'
57 AC_DEFUN([AC_PROG_LIBTOOL], [::fail-libtool::])
58 END
60 cat > extradir/gettext.m4 << 'END'
61 AC_DEFUN([AM_GNU_GETTEXT], [::fail-gettext::])
62 END
64 echo ./extradir > sysdir/dirlist
66 ACLOCAL_PATH=mdir1:mdir2 $ACLOCAL -I mdir3 --system-acdir sysdir
67 $AUTOCONF
69 $FGREP '::' configure # For debugging.
71 # Directories coming first in ACLOCAL_PATH should take precedence
72 # over those coming later.
73 $FGREP '::pass-foo::' configure
75 # Directories from '-I' options should take precedence over directories
76 # in ACLOCAL_PATH.
77 $FGREP '::pass-bar::' configure
79 # Directories in ACLOCAL_PATH should take precedence over system acdir
80 # (typically '${prefix}/share/aclocal'), and any directory added through
81 # the 'dirlist' special file.
82 $FGREP '::pass-gettext::' configure
83 $FGREP '::pass-libtool::' configure
85 # Directories in ACLOCAL_PATH shouldn't take precedence over the internal
86 # automake acdir (typically '${prefix}/share/aclocal-${APIVERSION}').
87 $FGREP 'am__api_version' configure
89 # A final sanity check.
90 $FGREP '::fail' configure && exit 1
92 # Same checks, but now with the command line option.
93 ACLOCAL_PATH=mdir2:mdir1 $ACLOCAL -I mdir3 --system-acdir sysdir --aclocal-path "mdir1:mdir2"
94 $ACLOCAL -I mdir3 --system-acdir sysdir --aclocal-path "mdir1:mdir2"
95 $AUTOCONF
97 $FGREP '::' configure # For debugging.
99 # Directories coming first in ACLOCAL_PATH should take precedence
100 # over those coming later.
101 $FGREP '::pass-foo::' configure
103 # Directories from '-I' options should take precedence over directories
104 # in ACLOCAL_PATH.
105 $FGREP '::pass-bar::' configure
107 # Directories in ACLOCAL_PATH should take precedence over system acdir
108 # (typically '${prefix}/share/aclocal'), and any directory added through
109 # the 'dirlist' special file.
110 $FGREP '::pass-gettext::' configure
111 $FGREP '::pass-libtool::' configure
113 # Directories in ACLOCAL_PATH shouldn't take precedence over the internal
114 # automake acdir (typically '${prefix}/share/aclocal-${APIVERSION}').
115 $FGREP 'am__api_version' configure
117 # A final sanity check.
118 $FGREP '::fail' configure && exit 1