2 # Copyright (C) 2011-2013 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.
36 cat >> configure.ac <<'END'
40 AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
46 $ACLOCAL || fatal_ "aclocal failure"
48 # Please keep this list in sync with the list of "Directory Variables"
49 # in the GNU Coding Standards and with the list additional directory
50 # variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
51 # ...). See also the hash '%standard_prefix' in the automake script.
52 prefixes='bin data dataroot doc dvi exec html include info lib libexec
53 lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
54 man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
55 ps sbin sharedstate sysconf'
56 # Please keep this list in sync with the list of primaries documented in
57 # the Automake manual (see the "The Uniform Naming Scheme" section).
58 primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
59 HEADERS MANS TEXINFOS'
61 # Use files, not variables, to hold the list of all the possible
62 # prefix_PRIMARY couples and the list of those couples valid for
63 # automake, to avoid having unreadable very verbose traces.
65 set +x # Don't be overly verbose.
67 for prefix in $prefixes; do
68 for primary in $primaries; do
69 echo ${prefix} ${primary}
73 for primary in $primaries; do
76 LIBRARIES|LTLIBRARIES)
77 prefixes_ok='lib pkglib'
80 prefixes_ok='bin sbin libexec pkglibexec'
83 prefixes_ok='bin sbin libexec pkglibexec pkgdata'
86 prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
87 sysconf sharedstate localstate lisp'
90 prefixes_ok='include oldinclude pkginclude'
102 # FIXME: Here we'd like to have:
103 # prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
104 # but Automake currently fails on that, as it allows the MANS
105 # primary to be coupled to any prefix.
106 # See also Automake bug#7656.
107 # We should dig out how automake had come to behave this way, and
108 # if such a behaviour can be safely changed.
109 prefixes_ok=$prefixes
112 # FIXME: Here we'd like to have:
114 # but Automake currently fails on that, as it allows the use of
115 # 'foo_TEXINFOS' to declare extra Texinfo sources for the 'foo'
116 # Texinfo manual, as in e.g.:
117 # info_TEXINFOS = foo.texi
118 # foo_TEXINFOS = gpl.texi
119 # See also Automake bug#7657.
120 prefixes_ok=$prefixes
123 fatal_ "unrecognized primary '$primary'"
126 for prefix in $prefixes_ok; do
127 echo ${prefix}_${primary}
131 # 'html_TEXINFOS' is not yet supported, and might never be.
132 grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
136 echo '=== all.list ==='
138 echo '=== allow.list ==='
141 # Create the Makefile.am.
142 while read lineno prefix primary; do
143 test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
144 || fatal_ "internal error in 'all.list'"
147 LTLIBRARIES) pfx=lib ext=la;;
148 LIBRARIES) pfx=lib ext=a;;
156 test -z "$ext" || ext=.$ext
157 if test $primary = TEXINFOS; then
158 echo @setfilename foo$lineno.info > foo$lineno.texi
160 echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
161 done <all.list >Makefile.am
164 echo '=== Makefile.am ==='
167 set -x # Restore shell xtraces from now on.
170 -d "'automake -a' error out on mismatched prefix/primary couples" \
173 while read lineno prefix primary; do
174 test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
175 || fatal_ "internal error in 'all.list'"
176 grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
177 errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
179 "mismatched prefix/primary in ${prefix}_${primary}" \
180 grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr
183 # Check that automake really failed only for the expected reason(s).
184 grep -v 'dir.* not a legitimate directory' stderr && exit 1
186 # Check that the same failures are present without the '--add-missing'
189 AUTOMAKE_fails -d "automake error out on mismatched prefix/primary couples"
190 command_ok_ "... and with the same diagnostic of 'automake -a'" \
191 diff stderr.old stderr