Merge branch 'maint'
[platform/upstream/automake.git] / tests / primary-prefix-invalid-couples.tap
1 #! /bin/sh
2 # Copyright (C) 2011 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 <http://www.gnu.org/licenses/>.
16
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
20 # cover more cases.
21 # See also test `primary-prefix-valid-couples.test'.
22
23 . ./defs || Exit 1
24
25 plan_ "later"
26
27 oIFS=$IFS # Saved for later.
28
29 : > ar-lib
30 : > ltmain.sh
31 : > texinfo.tex
32 : > elisp-comp
33 : > py-compile
34 : > config.guess
35 : > config.sub
36
37 cat >> configure.in <<'END'
38 AC_PROG_CC
39 AM_PROG_AR
40 AC_PROG_RANLIB
41 AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
42 AM_PROG_GCJ
43 AM_PATH_PYTHON
44 AM_PATH_LISPDIR
45 END
46
47 $ACLOCAL || fatal_ "aclocal failure"
48
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'
61
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.
65
66 set +x # Don't be overly verbose.
67
68 for prefix in $prefixes; do
69   for primary in $primaries; do
70     echo ${prefix} ${primary}
71   done
72 done >all.list
73
74 for primary in $primaries; do
75   prefixes_ok=''
76   case $primary in
77     LIBRARIES|LTLIBRARIES)
78       prefixes_ok='lib pkglib'
79       ;;
80     PROGRAMS)
81       prefixes_ok='bin sbin libexec pkglibexec'
82       ;;
83     SCRIPTS)
84       prefixes_ok='bin sbin libexec pkglibexec pkgdata'
85       ;;
86     DATA)
87       prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
88                    sysconf sharedstate localstate lisp'
89       ;;
90     HEADERS)
91       prefixes_ok='include oldinclude pkginclude'
92       ;;
93     LISP)
94       prefixes_ok='lisp'
95       ;;
96     PYTHON)
97       prefixes_ok='python'
98       ;;
99     JAVA)
100       prefixes_ok='java'
101       ;;
102     MANS)
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
111       ;;
112     TEXINFOS)
113       # FIXME: Here we'd like to have:
114       #   prefixes_ok='info'
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
122       ;;
123     *)
124       fatal_ "unrecognized primary '$primary'"
125       ;;
126   esac
127   for prefix in $prefixes_ok; do
128     echo ${prefix}_${primary}
129   done
130 done >allow.list
131
132 # `html_TEXINFOS' is not yet supported, and might never be.
133 grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
134 mv -f t all.list
135
136 # For debugging.
137 echo '=== all.list ==='
138 cat all.list
139 echo '=== allow.list ==='
140 cat allow.list
141
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'"
146   pfx='' ext=''
147   case $primary in
148     LTLIBRARIES) pfx=lib ext=la;;
149     LIBRARIES) pfx=lib ext=a;;
150     MANS) ext=man;;
151     HEADERS) ext=h;;
152     JAVA) ext=java;;
153     PYTHON) ext=py;;
154     LISP) ext=el;;
155     TEXINFOS) ext=texi;;
156   esac
157   test -z "$ext" || ext=.$ext
158   if test $primary = TEXINFOS; then
159     echo @setfilename foo$lineno.info > foo$lineno.texi
160   fi
161   echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
162 done <all.list >Makefile.am
163
164 # For debugging.
165 echo '=== Makefile.am ==='
166 cat Makefile.am
167
168 set -x # Restore shell xtraces from now on.
169
170 AUTOMAKE_fails \
171   -d "'automake -a' error out on mismatched prefix/primary couples" \
172   -- --add-missing
173
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"
179   command_ok_ \
180     "mismatched prefix/primary in ${prefix}_${primary}" \
181     grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr
182 done <all.list
183
184 # Check that automake really failed only for the expected reason(s).
185 grep -v 'dir.* not a legitimate directory' stderr && Exit 1
186
187 # Check that the same failures are present without the `--add-missing'
188 # option.
189 mv stderr stderr.old
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
193
194 :