2 # Copyright (C) 2011-2012 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)
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 # Not all primaries/directories combinations are valid.
18 # Automake should flag them as errors.
19 # Originated from PR/294, extended later (following bug #7647) to
21 # See also test 'primary-prefix-valid-couples.test'.
27 oIFS=$IFS # Saved for later.
37 cat >> configure.ac <<'END'
41 AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
47 $ACLOCAL || fatal_ "aclocal failure"
49 # Please keep this list in sync with the list of "Directory Variables"
50 # in the GNU Coding Standards and with the list additional directory
51 # variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
52 # ...). See also the hash '%standard_prefix' in the automake script.
53 prefixes='bin data dataroot doc dvi exec html include info lib libexec
54 lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
55 man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
56 ps sbin sharedstate sysconf'
57 # Please keep this list in sync with the list of primaries documented in
58 # the Automake manual (see the "The Uniform Naming Scheme" section).
59 primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
60 HEADERS MANS TEXINFOS'
62 # Use files, not variables, to hold the list of all the possible
63 # prefix_PRIMARY couples and the list of those couples valid for
64 # automake, to avoid having unreadable very verbose traces.
66 set +x # Don't be overly verbose.
68 for prefix in $prefixes; do
69 for primary in $primaries; do
70 echo ${prefix} ${primary}
74 for primary in $primaries; do
77 LIBRARIES|LTLIBRARIES)
78 prefixes_ok='lib pkglib'
81 prefixes_ok='bin sbin libexec pkglibexec'
84 prefixes_ok='bin sbin libexec pkglibexec pkgdata'
87 prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
88 sysconf sharedstate localstate lisp'
91 prefixes_ok='include oldinclude pkginclude'
103 # FIXME: Here we'd like to have:
104 # prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
105 # but Automake currently fails on that, as it allows the MANS
106 # primary to be coupled to any prefix.
107 # See also Automake bug#7656.
108 # We should dig out how automake had come to behave this way, and
109 # if such a behaviour can be safely changed.
110 prefixes_ok=$prefixes
113 # FIXME: Here we'd like to have:
115 # but Automake currently fails on that, as it allows the use of
116 # 'foo_TEXINFOS' to declare extra Texinfo sources for the 'foo'
117 # Texinfo manual, as in e.g.:
118 # info_TEXINFOS = foo.texi
119 # foo_TEXINFOS = gpl.texi
120 # See also Automake bug#7657.
121 prefixes_ok=$prefixes
124 fatal_ "unrecognized primary '$primary'"
127 for prefix in $prefixes_ok; do
128 echo ${prefix}_${primary}
132 # 'html_TEXINFOS' is not yet supported, and might never be.
133 grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
137 echo '=== all.list ==='
139 echo '=== allow.list ==='
142 # Create the Makefile.am.
143 while read lineno prefix primary; do
144 test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
145 || fatal_ "internal error in 'all.list'"
148 LTLIBRARIES) pfx=lib ext=la;;
149 LIBRARIES) pfx=lib ext=a;;
157 test -z "$ext" || ext=.$ext
158 if test $primary = TEXINFOS; then
159 echo @setfilename foo$lineno.info > foo$lineno.texi
161 echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
162 done <all.list >Makefile.am
165 echo '=== Makefile.am ==='
168 set -x # Restore shell xtraces from now on.
171 -d "'automake -a' error out on mismatched prefix/primary couples" \
174 while read lineno prefix primary; do
175 test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
176 || fatal_ "internal error in 'all.list'"
177 grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
178 errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
180 "mismatched prefix/primary in ${prefix}_${primary}" \
181 grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr
184 # Check that automake really failed only for the expected reason(s).
185 grep -v 'dir.* not a legitimate directory' stderr && Exit 1
187 # Check that the same failures are present without the '--add-missing'
190 AUTOMAKE_fails -d "automake error out on mismatched prefix/primary couples"
191 command_ok_ "... and with the same diagnostic of 'automake -a'" \
192 diff stderr.old stderr