news: describe recently-fixed bug in vala support
[platform/upstream/automake.git] / tests / primary-prefix-invalid-couples.test
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 set -e
26
27 oIFS=$IFS # Saved for later.
28
29 : > ltmain.sh
30 : > texinfo.tex
31 : > elisp-comp
32 : > py-compile
33 : > config.guess
34 : > config.sub
35
36 cat >> configure.in <<'END'
37 AC_PROG_CC
38 AC_PROG_RANLIB
39 AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
40 AM_PROG_GCJ
41 AM_PATH_PYTHON
42 AM_PATH_LISPDIR
43 END
44
45 $ACLOCAL
46
47 # Please keep this list in sync with the list of "Directory Variables"
48 # in the GNU Coding Standards and with the list additional directory
49 # variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
50 # ...).   See also the hash `%standard_prefix' in the automake script.
51 prefixes='bin data dataroot doc dvi exec html include info lib libexec
52           lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
53           man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
54           ps sbin sharedstate sysconf'
55 # Please keep this list in sync with the list of primaries documented in
56 # the Automake manual (see the "The Uniform Naming Scheme" section).
57 primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
58            HEADERS MANS TEXINFOS'
59
60 # Use files, not variables, to hold the list of all the possible
61 # prefix_PRIMARY couples and the list of those couples valid for
62 # automake, to avoid having unreadable very verbose traces.
63
64 set +x # Don't be overly verbose.
65
66 for prefix in $prefixes; do
67   for primary in $primaries; do
68     echo ${prefix} ${primary}
69   done
70 done >all.list
71
72 for primary in $primaries; do
73   prefixes_ok=''
74   case $primary in
75     LIBRARIES|LTLIBRARIES)
76       prefixes_ok='lib pkglib'
77       ;;
78     PROGRAMS)
79       prefixes_ok='bin sbin libexec pkglibexec'
80       ;;
81     SCRIPTS)
82       prefixes_ok='bin sbin libexec pkglibexec pkgdata'
83       ;;
84     DATA)
85       prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
86                    sysconf sharedstate localstate lisp'
87       ;;
88     HEADERS)
89       prefixes_ok='include oldinclude pkginclude'
90       ;;
91     LISP)
92       prefixes_ok='lisp'
93       ;;
94     PYTHON)
95       prefixes_ok='python'
96       ;;
97     JAVA)
98       prefixes_ok='java'
99       ;;
100     MANS)
101       # FIXME: Here we'd like to have:
102       #   prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
103       # but Automake currently fails on that, as it allows the MANS
104       # primary to be coupled to any prefix.
105       # See also Automake bug#7656.
106       # We should dig out how automake had come to behave this way, and
107       # if such a behaviour can be safely changed.
108       prefixes_ok=$prefixes
109       ;;
110     TEXINFOS)
111       # FIXME: Here we'd like to have:
112       #   prefixes_ok='info'
113       # but Automake currently fails on that, as it allows the use of
114       # `foo_TEXINFOS' to declare extra Texinfo sources for the `foo'
115       # Texinfo manual, as in e.g.:
116       #   info_TEXINFOS = foo.texi
117       #   foo_TEXINFOS = gpl.texi
118       # See also Automake bug#7657.
119       prefixes_ok=$prefixes
120       ;;
121     *)
122       fatal_ "unrecognized primary '$primary'"
123       ;;
124   esac
125   for prefix in $prefixes_ok; do
126     echo ${prefix}_${primary}
127   done
128 done >allow.list
129
130 # `html_TEXINFOS' is not yet supported, and might never be.
131 grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
132 mv -f t all.list
133
134 # For debugging.
135 echo '=== all.list ==='
136 cat all.list
137 echo '=== allow.list ==='
138 cat allow.list
139
140 # Create the Makefile.am.
141 while read lineno prefix primary; do
142   test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
143     || fatal_ "internal error in 'all.list'"
144   pfx='' ext=''
145   case $primary in
146     LTLIBRARIES) pfx=lib ext=la;;
147     LIBRARIES) pfx=lib ext=a;;
148     MANS) ext=man;;
149     HEADERS) ext=h;;
150     JAVA) ext=java;;
151     PYTHON) ext=py;;
152     LISP) ext=el;;
153     TEXINFOS) ext=texi;;
154   esac
155   test -z "$ext" || ext=.$ext
156   if test $primary = TEXINFOS; then
157     echo @setfilename foo$lineno.info > foo$lineno.texi
158   fi
159   echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
160 done <all.list >Makefile.am
161
162 # For debugging.
163 echo '=== Makefile.am ==='
164 cat Makefile.am
165
166 set -x # Restore shell xtraces from now on.
167
168 AUTOMAKE_fails -a
169
170 while read lineno prefix primary; do
171   test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
172     || fatal_ "internal error in 'all.list'"
173   grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
174   errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
175   grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr || Exit 1
176 done <all.list
177
178 # Check that automake really failed only for the expected reason(s).
179 grep -v 'dir.* not a legitimate directory' stderr && Exit 1
180
181 # Check that the same failures are present without the `--add-missing'
182 # option.
183 mv stderr stderr.old
184 AUTOMAKE_fails
185 diff stderr.old stderr
186
187 :