On Wednesday 15 December 2010, Ralf Wildenhues wrote: > Hello, and dropping automake@, > > * Stefano Lattarini wrote on Wed, Dec 15, 2010 at 12:27:43PM CET: > > The list in `%standard_prefix' is used only for diagnosing invalid > > primary/directory combinations, such as `data_PROGRAMS' or > > 'lib_HEADERS'. For more info, see test `dirforbid.test', PR/294 at > > <http://sources.redhat.com/cgi-bin/gnatsweb.pl?database=automake>, > > and commit e87d851a863a7c321af8bc7b2b36aff5e072ff94 (05/03/2002). > > > > That said, you might have uncovered a bug in automake, because > > something like: > > doc_LIBRARIES = libfoo.a > > should warn IMHO, but it currently doesn't. > > Agreed. Extending dirforbid.test and fixing fallout would be good. > I've also throw in a couple of related fixings and improvements, and (as you might have guessed I'd do ;-) greatly extended the relevant tests.
Attached is what I'd like to push; it's based off of maint, but I'd like to push it to master only, as it might cause some backwards incompatibilities (IMHO very minor, but better play safe here). OK to apply? Regards, Stefano
From 5d284ed4fccb649b3e968aa2700891afab001029 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Thu, 16 Dec 2010 19:23:06 +0100 Subject: [PATCH] Warnings about primary/prefix mismatch fixed and extended. * automake.in (%standard_prefix): Add `doc' and `locale'. Rename `pkgdatadir' to `pkgdata'. Similarly for`pkglibdir', `pkgincludedir' and `pkglibexecdir'. (handle_programs): List `pkglibexec', not `pkglib', among the prefixes valid for the `PROGRAMS' primary. (handle_data): List also `doc' among the prefixes valid for the `DATA' primary. This is required by automake's own build system. * tests/dirforbid.test: Test removed, superseded by ... * tests/primary-prefix-invalid-couples.test: ... this new test. * tests/primary-prefix-valid-couples.test: New test. * tests/primary-prefix-documented-valid.test: Likewise. * tests/primary-prefix-force-valid.test: Likewise. * tests/java3.test: Adjusted, and extended a bit. * tests/Makefile.am (TESTS): Updated. * NEWS: Updated. From a report by Eric Blake. --- ChangeLog | 21 +++ NEWS | 3 + automake.in | 16 +- tests/Makefile.am | 5 +- tests/Makefile.in | 5 +- tests/dirforbid.test | 38 ----- tests/java3.test | 14 ++- tests/primary-prefix-couples-documented-valid.test | 83 ++++++++++++ tests/primary-prefix-couples-force-valid.test | 87 ++++++++++++ tests/primary-prefix-invalid-couples.test | 142 ++++++++++++++++++++ tests/primary-prefix-valid-couples.test | 90 ++++++++++++ 11 files changed, 453 insertions(+), 51 deletions(-) delete mode 100755 tests/dirforbid.test create mode 100755 tests/primary-prefix-couples-documented-valid.test create mode 100755 tests/primary-prefix-couples-force-valid.test create mode 100755 tests/primary-prefix-invalid-couples.test create mode 100755 tests/primary-prefix-valid-couples.test diff --git a/ChangeLog b/ChangeLog index 2482ef1..a67b1d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2010-12-17 Stefano Lattarini <stefano.lattar...@gmail.com> + + Warnings about primary/prefix mismatch fixed and extended. + * automake.in (%standard_prefix): Add `doc' and `locale'. + Rename `pkgdatadir' to `pkgdata'. Similarly for`pkglibdir', + `pkgincludedir' and `pkglibexecdir'. + (handle_programs): List `pkglibexec', not `pkglib', among the + prefixes valid for the `PROGRAMS' primary. + (handle_data): List also `doc' among the prefixes valid for + the `DATA' primary. This is required by automake's own build + system. + * tests/dirforbid.test: Test removed, superseded by ... + * tests/primary-prefix-invalid-couples.test: ... this new test. + * tests/primary-prefix-valid-couples.test: New test. + * tests/primary-prefix-couples-documented-valid.test: Likewise. + * tests/primary-prefix-couples-force-valid.test: Likewise. + * tests/java3.test: Adjusted, and extended a bit. + * tests/Makefile.am (TESTS): Updated. + * NEWS: Updated. + From a report by Eric Blake. + 2010-12-14 Stefano Lattarini <stefano.lattar...@gmail.com> Improve tests on generated portions of configure help screen. diff --git a/NEWS b/NEWS index 6bc0d6f..2f98f90 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,9 @@ Bugs fixed in 1.11.0a: * Long standing bugs: + - Automake now warns about more primary/directory invalid combinations, + such as "doc_LIBRARIES" or "pkglib_PROGRAMS". + - On Darwin 9, `pythondir' and `pyexecdir' pointed below `/Library/Python' even if the `--prefix' argument pointed outside of a system directory. AM_PATH_PYTHON has been fixed to ignore the value returned from python's diff --git a/automake.in b/automake.in index 8f3edde..c3bcfd5 100755 --- a/automake.in +++ b/automake.in @@ -249,11 +249,11 @@ my @common_sometimes = # Standard directories from the GNU Coding Standards, and additional # pkg* directories from Automake. Stored in a hash for fast member check. my %standard_prefix = - map { $_ => 1 } (qw(bin data dataroot dvi exec html include info - lib libexec lisp localstate man man1 man2 man3 - man4 man5 man6 man7 man8 man9 oldinclude pdf - pkgdatadir pkgincludedir pkglibdir pkglibexecdir - ps sbin sharedstate sysconf)); + map { $_ => 1 } (qw(bin data dataroot doc dvi exec html include info + lib libexec lisp locale localstate man man1 man2 + man3 man4 man5 man6 man7 man8 man9 oldinclude pdf + pkgdata pkginclude pkglib pkglibexec ps sbin + sharedstate sysconf)); # Copyright on generated Makefile.ins. my $gen_copyright = "\ @@ -2616,7 +2616,7 @@ sub handle_libtool sub handle_programs { my @proglist = &am_install_var ('progs', 'PROGRAMS', - 'bin', 'sbin', 'libexec', 'pkglib', + 'bin', 'sbin', 'libexec', 'pkglibexec', 'noinst', 'check'); return if ! @proglist; @@ -3726,8 +3726,8 @@ sub handle_man_pages sub handle_data { &am_install_var ('-noextra', '-candist', 'data', 'DATA', - 'data', 'dataroot', 'dvi', 'html', 'pdf', 'ps', - 'sysconf', 'sharedstate', 'localstate', + 'data', 'dataroot', 'doc', 'dvi', 'html', 'pdf', + 'ps', 'sysconf', 'sharedstate', 'localstate', 'pkgdata', 'lisp', 'noinst', 'check'); } diff --git a/tests/Makefile.am b/tests/Makefile.am index dab04e3..5940ffe 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -270,7 +270,6 @@ depend4.test \ depend5.test \ depend6.test \ destdir.test \ -dirforbid.test \ dirlist.test \ dirlist2.test \ discover.test \ @@ -598,6 +597,10 @@ prefix.test \ primary.test \ primary2.test \ primary3.test \ +primary-prefix-invalid-couples.test \ +primary-prefix-valid-couples.test \ +primary-prefix-couples-force-valid.test \ +primary-prefix-couples-documented-valid.test \ proginst.test \ python.test \ python2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index de21f43..f70aee1 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -537,7 +537,6 @@ depend4.test \ depend5.test \ depend6.test \ destdir.test \ -dirforbid.test \ dirlist.test \ dirlist2.test \ discover.test \ @@ -865,6 +864,10 @@ prefix.test \ primary.test \ primary2.test \ primary3.test \ +primary-prefix-invalid-couples.test \ +primary-prefix-valid-couples.test \ +primary-prefix-couples-force-valid.test \ +primary-prefix-couples-documented-valid.test \ proginst.test \ python.test \ python2.test \ diff --git a/tests/dirforbid.test b/tests/dirforbid.test deleted file mode 100755 index 3ab319d..0000000 --- a/tests/dirforbid.test +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh -# Copyright (C) 2002, 2003 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# All primaries cannot be used with all directories. -# Automake should flag them as errors. -# For PR/294 - -. ./defs || Exit 1 - -set -e - -cat >> configure.in <<'END' -AC_PROG_CC -END - -# Try some (not all) disallowed variables -for i in data_PROGRAMS lib_HEADERS ; do - cat > Makefile.am << END -$i = foo -END - $ACLOCAL - AUTOMAKE_fails -a - grep 'Makefile.am:1:.*directory' stderr -done -: diff --git a/tests/java3.test b/tests/java3.test index 7895769..41dbb71 100755 --- a/tests/java3.test +++ b/tests/java3.test @@ -23,7 +23,7 @@ set -e cat >> configure.in << 'END' -AM_CONDITIONAL([WHO_CARES], false) +AM_CONDITIONAL([WHO_CARES], [false]) AC_OUTPUT END @@ -32,7 +32,7 @@ if WHO_CARES JAVA_FILES = MyClass1.java endif -dist_pkgdata_JAVA = $(JAVA_FILES) +dist_java_JAVA = $(JAVA_FILES) END : >MyClass1.java @@ -40,5 +40,13 @@ END $ACLOCAL $AUTOCONF $AUTOMAKE -./configure + +cwd=`pwd` || Exit 1 +./configure --prefix="$cwd/_inst" +$MAKE install +test ! -d _inst +test ! -r _inst +$MAKE uninstall $MAKE distcheck + +: diff --git a/tests/primary-prefix-couples-documented-valid.test b/tests/primary-prefix-couples-documented-valid.test new file mode 100755 index 0000000..893704f --- /dev/null +++ b/tests/primary-prefix-couples-documented-valid.test @@ -0,0 +1,83 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check that the "uncommon" prefix/primary combinations used in +# examples in the Automake manual do not cause obvious errors. +# Please keep this test in sync with the automake manual. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_CC +AC_PROG_LIBTOOL +AM_PROG_GCJ +AM_PATH_PYTHON +END + +# Fake libtool availability. +: > ltmain.sh +cat > acinclude.m4 <<'END' +AC_DEFUN([AC_PROG_LIBTOOL], + [AC_SUBST([LIBTOOL], [:])]) +END + +cat > Makefile.am <<'END' +xmldir = $(datadir)/xml +xml_DATA = file.xml + +data_DATA = file1 file2 file3 +data2dir = $(datadir) +data2_DATA = file4 file5 file6 + +aclocaldir = $(datadir)/aclocal +aclocal_DATA = mymacro.m4 myothermacro.m4 + +imagesdir = $(pkgdatadir)/images +soundsdir = $(pkgdatadir)/sounds +dist_images_DATA = images/vortex.pgm +dist_sounds_DATA = sounds/whirl.ogg + +lisp_DATA = file1.el file2.el + +javadir = $(datadir)/java +dist_java_JAVA = a.java b.java c.java + +pkgpython_PYTHON = foo.py + +pyexec_LTLIBRARIES = quaternion.la +quaternion_la_SOURCES = quaternion.c support.c support.h +quaternion_la_LDFLAGS = -avoid-version -module + +myexecbindir = /exec +myexecbin_PROGRAMS = foo + +foodir = $(prefix)/foo +barexecdir = $(prefix)/bar/binaries +foo_SCRIPTS = foo.sh +barexec_SCRIPTS = quux.pl +END + +$ACLOCAL + +# Both these two invocations are meant. +# They exercise both code paths concerning auxiliary files. +$AUTOMAKE -a +$AUTOMAKE + +: diff --git a/tests/primary-prefix-couples-force-valid.test b/tests/primary-prefix-couples-force-valid.test new file mode 100755 index 0000000..02728b9 --- /dev/null +++ b/tests/primary-prefix-couples-force-valid.test @@ -0,0 +1,87 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check that a user who wants to use an invalid prefix/primary +# combination can do so with a proper workaround. +# For example, this: +# lib_PROGRAMS = foo +# is expected to cause an automake error, but this: +# bardir = $(libdir) +# bar_PROGRAMS = foo +# should work. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_RANLIB +AC_OUTPUT +END + +cat > Makefile.am <<'END' +my_libdir = $(libdir) +my_lib_PROGRAMS = foo + +foodir = $(bindir) +foo_LIBRARIES = libquux.a + +xdir = $(libexecdir) +x_HEADERS = bar.h + +installcheck-local: test +.PHONY: test +test: + (cd '$(prefix)' && find .);: for debugging + ls -l '$(libdir)/foo' + test -f '$(libdir)/foo' + test -x '$(libdir)/foo' + ls -l '$(bindir)/libquux.a' + test -f '$(bindir)/libquux.a' + ls -l '$(libexecdir)/bar.h' + test -f '$(libexecdir)/bar.h' + test ! -x '$(libexecdir)/bar.h' +END + +cat > foo.c <<'END' +int main (void) +{ + return 0; +} +END + +cat > libquux.c <<'END' +int quux(void) +{ + return 1; +} +END + +: > bar.h + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +cwd=`pwd` || Exit 1 +./configure --prefix="$cwd/_inst" + +$MAKE install +$MAKE installcheck +$MAKE distcheck + +: diff --git a/tests/primary-prefix-invalid-couples.test b/tests/primary-prefix-invalid-couples.test new file mode 100755 index 0000000..1a3d4e0 --- /dev/null +++ b/tests/primary-prefix-invalid-couples.test @@ -0,0 +1,142 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Not all primaries/directories combinations are valid. +# Automake should flag them as errors. +# Originated from PR/294, extended later (following bug #7647) to +# cover more cases. +# See also test `primary-prefix-valid-couples.test'. + +. ./defs || Exit 1 + +set -e + +oIFS=$IFS # saved for later + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_RANLIB +AC_PROG_LIBTOOL +AM_PROG_GCJ +AM_PATH_PYTHON +AM_PATH_LISPDIR +END + +$ACLOCAL + +# Please keep this list in sync with the list of "Directory Variables" +# in the GNU Coding Standards and with the list additional directory +# variables provided by autoconf and/or automake (pkgdatadir, pkglibdir, +# ...). See also the hash `%standard_prefix' in the automake script. +prefixes='bin data dataroot doc dvi exec html include info lib libexec + lisp locale localstate man man1 man2 man3 man4 man5 man6 man7 + man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec + ps sbin sharedstate sysconf' +# Please keep this list in sync with the list of primaries documented in +# the Automake manual (see the "The Uniform Naming Scheme" section). +primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA + HEADERS MANS TEXINFOS' + +# Use files, not variables, to hold the list of all the possible +# prefix_PRIMARY couples and the list of those couples valid for +# automake, to avoid having unreadable very verbose traces. + +set +x # don't be overly verbose + +for prefix in $prefixes; do + for primary in $primaries; do + echo ${prefix}_${primary} + done +done >all.list + +for primary in $primaries; do + prefixes_ok='' + case $primary in + LIBRARIES|LTLIBRARIES) + prefixes_ok='lib pkglib' + ;; + PROGRAMS) + prefixes_ok='bin sbin libexec pkglibexec' + ;; + SCRIPTS) + prefixes_ok='bin sbin libexec pkgdata' + ;; + DATA) + prefixes_ok='data dataroot pkgdata doc html dvi pdf ps + sysconf sharedstate localstate lisp' + ;; + HEADERS) + prefixes_ok='include oldinclude pkginclude' + ;; + LISP) + prefixes_ok='lisp' + ;; + PYTHON) + prefixes_ok='python' + ;; + JAVA) + prefixes_ok='java' + ;; + MANS) + # FIXME: Here we'd like to have: + # prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9' + # but Automake currently fails on that, as it allows the MANS + # primary to be coupled to any prefix. + # See also Automake bug#7656. + # We should dig out how automake had come to behave this way, and + # if such a behaviour can be safely changed. + prefixes_ok=$prefixes + ;; + TEXINFOS) + # FIXME: Here we'd like to have: + # prefixes_ok='info' + # but Automake currently fails on that, as it allows the TEXINFOS + # primary to be coupled to any prefix. + # See also Automake bug#7657. + # We should dig out how automake had come to behave this way, and + # if such a behaviour can be safely changed. + prefixes_ok=$prefixes + ;; + *) + echo "$me: internal error: unrecognized primary '$primary'" >&2 + Exit 99 + ;; + esac + for prefix in $prefixes_ok; do + echo ${prefix}_${primary} + done +done >allow.list + +set -x + +cat all.list +cat allow.list + +while read x; do + grep "^$x$" allow.list >/dev/null && continue + # To get the expected error message more in detail. + IFS=_; set $x; IFS=$oIFS + test $# -eq 2 || Exit 99 # sanity check + prefix=$1 + primary=$2 + errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary" + # Now do the test for this prefix/primary combination. + echo "$x = foo" > Makefile.am + AUTOMAKE_fails -a + grep "^Makefile\\.am:1:$errmsg_rx" stderr +done <all.list + +: diff --git a/tests/primary-prefix-valid-couples.test b/tests/primary-prefix-valid-couples.test new file mode 100755 index 0000000..8acb32e --- /dev/null +++ b/tests/primary-prefix-valid-couples.test @@ -0,0 +1,90 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Test for valid prefix/primary combinations. +# See also test `primary-prefix-invalid-couples.test'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_RANLIB +AC_PROG_LIBTOOL +AM_PROG_GCJ +AM_PATH_PYTHON +AM_PATH_LISPDIR +END + +# Fake libtool availability. +: > ltmain.sh +: > config.sub +: > config.guess +cat > acinclude.m4 <<'END' +AC_DEFUN([AC_PROG_LIBTOOL], + [AC_SUBST([LIBTOOL], [:])]) +END + +# Other required files. +echo '@setfilename foo' > foo.texi +: > texinfo.tex +: > py-compile +: > elisp-comp + +# Setup Makefile.am. + +: > Makefile.am + +for p in bin sbin libexec pkglibexec; do + echo "${p}_PROGRAMS = prog-$p" >> Makefile.am +done + +for p in lib pkglib; do + echo "${p}_LIBRARIES = libs-$p.a" >> Makefile.am + echo "${p}_LTLIBRARIES = libd-$p.la" >> Makefile.am +done + +for p in bin sbin libexec pkgdata; do + echo "${p}_SCRIPTS = $p.sh" >> Makefile.am +done + +for p in data dataroot pkgdata doc html dvi pdf ps sysconf \ + sharedstate localstate lisp; do + echo "${p}_DATA = $p.dat" >> Makefile.am +done + +for p in include oldinclude pkginclude; do + echo "${p}_HEADERS = $p.h" >> Makefile.am +done + +for p in man man1 man2 man3 man4 man5 man6 man7 man8 man9; do + echo "${p}_MANS = bar.$p" +done + +echo "info_TEXINFOS = foo.texi" >> Makefile.am +echo "lisp_LISP = foo.el" >> Makefile.am +echo "python_PYTHON = foo.py" >> Makefile.am +echo "java_JAVA = foo.java" >> Makefile.am + +awk '{print NR ":" $0}' Makefile.am # for debugging + +# Go with the tests. + +$ACLOCAL +$AUTOMAKE + +: -- 1.7.1