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