From: Stefano Lattarini Date: Sun, 13 Jan 2013 16:50:30 +0000 (+0100) Subject: subdir-objects: complain if it isn't enabled X-Git-Tag: v1.13b~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4864af66bfd189a501061d775bb9743a1285d88e;p=thirdparty%2Fautomake.git subdir-objects: complain if it isn't enabled Since the next major automake version will make the behaviour so far only activated with the 'subdir-object' option mandatory, it's better if we start warning users not using that option. As suggested by Peter Johansson, we strive to avoid the warning when it would be irrelevant, i.e., if all source files sit in "current" directory. See automake bug#13378. * automake.in (handle_single_transform): Print the warning when necessary. * t/subobj.sh: Enhance. * t/ax/depcomp.sh: Adjust. * t/cscope.tap: Likewise. * t/depcomp8a.sh: Likewise. * t/depcomp8b.sh: Likewise. * t/ext2.sh: Likewise. * t/extra-portability.sh: Likewise. * t/fort2.sh: Likewise. * t/fort4.sh: Likewise. * t/fort5.sh: Likewise. * t/lex-line.sh: Likewise. * t/libtool3.sh: Likewise. * t/ltinstloc.sh: Likewise. * t/ltlibsrc.sh: Likewise. * t/ltorder.sh: Likewise. * t/parallel-tests-suffix-prog.sh: Likewise. * t/sourcefile-in-subdir.sh: Likewise. * t/specflg9.sh: Likewise. * t/subobj4.sh: Likewise. * t/subobj7.sh: Likewise. * t/subpkg-yacc.sh: Likewise. * t/subpkg.sh: Likewise. * t/suffix-custom-subobj-and-specflg.sh: Likewise. * t/vala-libs.sh: Likewise. * t/vala-non-recursive-setup.sh: Likewise. * t/yacc-grepping2.sh: Likewise. * t/yacc-line.sh: Likewise. --- diff --git a/automake.in b/automake.in index 990b60d60..0e3b882b8 100644 --- a/automake.in +++ b/automake.in @@ -1793,9 +1793,36 @@ sub handle_single_transform ($$$$$%) # If rewrite said it was ok, put the object into a # subdir. - if ($r == LANG_SUBDIR && $directory ne '') + if ($directory ne '') { - $object = $directory . '/' . $object; + if ($r == LANG_SUBDIR) + { + $object = $directory . '/' . $object; + } + else + { + # Since the next major version of automake (1.14) will + # make the behaviour so far only activated with the + # 'subdir-object' option mandatory, it's better if we + # start warning users not using that option. + # As suggested by Peter Johansson, we strive to avoid + # the warning when it would be irrelevant, i.e., if + # all source files sit in "current" directory. + msg_var 'unsupported', $var, + "source file '$full' is in a subdirectory," + . "\nbut option 'subdir-objects' is disabled"; + msg 'unsupported', INTERNAL, <<'EOF', uniq_scope => US_GLOBAL; +possible forward-incompatibility. +At least a source file is in a subdirectory, but the 'subdir-objects' +automake option hasn't been enabled. For now, the corresponding output +object file(s) will be placed in the top-level directory. However, +this behaviour will change in future Automake versions: they will +unconditionally cause object files to be placed in the same subdirectory +of the corresponding sources. +You are advised to start using 'subdir-objects' option throughout your +project, to avoid future incompatibilities. +EOF + } } # If the object file has been renamed (because per-target diff --git a/t/ax/depcomp.sh b/t/ax/depcomp.sh index 0e5b6a521..1534d5f8e 100644 --- a/t/ax/depcomp.sh +++ b/t/ax/depcomp.sh @@ -130,7 +130,7 @@ check_distclean () cat > configure.ac < src/Makefile.am <> configure.ac << 'END' -AC_CONFIG_FILES([sub/Makefile]) +cat > configure.ac << 'END' +AC_INIT([cscope-test], [1.0]) +AM_INIT_AUTOMAKE([subdir-objects]) +AC_CONFIG_FILES([Makefile sub/Makefile]) AC_SUBST([CC], [who-cares]) AC_SUBST([CXX], [who-cares]) AC_SUBST([FC], [who-cares]) diff --git a/t/depcomp8a.sh b/t/depcomp8a.sh index 76aa37694..d6c73edb7 100755 --- a/t/depcomp8a.sh +++ b/t/depcomp8a.sh @@ -48,7 +48,9 @@ int bar (void) END $ACLOCAL -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported grep include Makefile.in # For debugging. grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in diff --git a/t/depcomp8b.sh b/t/depcomp8b.sh index 52382f14a..879ee1c0d 100755 --- a/t/depcomp8b.sh +++ b/t/depcomp8b.sh @@ -31,6 +31,9 @@ AC_OUTPUT END cat > Makefile.am << 'END' +## FIXME: stop disabling the warnings in the 'unsupported' category +## FIXME: once the 'subdir-objects' option has been mandatory. +AUTOMAKE_OPTIONS = -Wno-unsupported lib_LTLIBRARIES = libzardoz.la libzardoz_la_SOURCES = foo.c sub/bar.c END @@ -42,7 +45,9 @@ echo 'int bar (void) { return 0; }' > sub/bar.c libtoolize $ACLOCAL -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported grep include Makefile.in # For debugging. grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in @@ -56,7 +61,7 @@ DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck # Try again with subdir-objects option. -echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am +echo AUTOMAKE_OPTIONS += subdir-objects >> Makefile.am $AUTOMAKE grep include Makefile.in # For debugging. diff --git a/t/ext2.sh b/t/ext2.sh index 108908058..4858aec66 100755 --- a/t/ext2.sh +++ b/t/ext2.sh @@ -25,6 +25,7 @@ AC_PROG_CXX EOF cat >Makefile.am <Makefile.am <Makefile.am <<'END' +AUTOMAKE_OPTIONS = subdir-objects +FC = fake-fc bin_PROGRAMS = hello goodbye -hello_SOURCES = hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 greets.f08 sub/bonjour.f08 +hello_SOURCES = hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 \ + greets.f08 sub/bonjour.f08 goodbye_SOURCES = bye.f95 sub/baz.f90 -goodbye_FCFLAGS = +goodbye_FCFLAGS = --gby END $ACLOCAL $AUTOMAKE -# The following tests aren't fool-proof, but they don't -# need a Fortran compiler. grep '.\$(LINK)' Makefile.in && exit 1 grep '.\$(FCLINK)' Makefile.in grep '.\$(FCCOMPILE)' Makefile.in > stdout cat stdout grep -v '\$(FCFLAGS_f' stdout && exit 1 grep '.\$(FC.*\$(FCFLAGS_blabla' Makefile.in && exit 1 -# Notice the TAB: -grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f90' Makefile.in -grep '^[ ].*\$(FC.*\$(FCFLAGS_f95).*\.f95' Makefile.in -grep '^[ ].*\$(FC.*\$(FCFLAGS_f03).*\.f03' Makefile.in -grep '^[ ].*\$(FC.*\$(FCFLAGS_f08).*\.f08' Makefile.in -grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f95' Makefile.in && exit 1 -grep '^[ ].*\$(FC.*\$(FCFLAGS_f95).*\.f90' Makefile.in && exit 1 -grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f03' Makefile.in && exit 1 -grep '^[ ].*\$(FC.*\$(FCFLAGS_f08).*\.f90' Makefile.in && exit 1 + +sed '/^AC_FC_SRCEXT.*blabla/d' configure.ac >t +mv -f t configure.ac + +rm -rf autom4te*.cache +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure + +touch hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 greets.f08 \ + sub/bonjour.f08 bye.f95 sub/baz.f90 + +$MAKE -n \ + FCFLAGS_f90=--@90 FCFLAGS_f95=--@95 FCFLAGS_f03=--@03 FCFLAGS_f08=--@08 \ + > stdout || { cat stdout; exit 1; } +cat stdout +# To make it easier to have stricter grepping below. +sed -e 's/[ ][ ]*/ /g' -e 's/^/ /' -e 's/$/ /' stdout > out +cat out + +grep ' fake-fc .* --@90 .* hello\.f90 ' out +grep ' fake-fc .* --@95 .* foo\.f95 ' out +grep ' fake-fc .* --@95 .* sub/bar\.f95 ' out +grep ' fake-fc .* --@03 .* hi\.f03 ' out +grep ' fake-fc .* --@03 .* sub/howdy\.f03 ' out +grep ' fake-fc .* --@08 .* greets\.f08 ' out +grep ' fake-fc .* --@08 .* sub/bonjour\.f08 ' out +grep ' fake-fc .* --gby .* --@95 .*[` ]bye\.f95 ' out +grep ' fake-fc .* --gby .* --@90 .*[` ]sub/baz\.f90 ' out + +test $(grep -c '.*--gby.*\.f' out) -eq 2 + +$EGREP 'fake-fc.*--@(95|03|08).*\.f90' out && exit 1 +$EGREP 'fake-fc.*--@(90|03|08).*\.f95' out && exit 1 +$EGREP 'fake-fc.*--@(90|95|08).*\.f03' out && exit 1 +$EGREP 'fake-fc.*--@(95|95|03).*\.f08' out && exit 1 : diff --git a/t/fort4.sh b/t/fort4.sh index 822edb8c8..2ef27abeb 100755 --- a/t/fort4.sh +++ b/t/fort4.sh @@ -65,7 +65,7 @@ LDADD = $(FCLIBS) END $ACLOCAL -$AUTOMAKE -a +$AUTOMAKE -a -Wno-unsupported # The Fortran 77 linker should be preferred: grep '.\$(FCLINK)' Makefile.in && exit 1 diff --git a/t/fort5.sh b/t/fort5.sh index 02727061d..7b9991b96 100755 --- a/t/fort5.sh +++ b/t/fort5.sh @@ -75,7 +75,9 @@ END libtoolize --force $ACLOCAL -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported $AUTOCONF # This test requires Libtool >= 2.0. Earlier Libtool does not diff --git a/t/lex-line.sh b/t/lex-line.sh index 9b27c0b39..258f6af56 100755 --- a/t/lex-line.sh +++ b/t/lex-line.sh @@ -86,7 +86,9 @@ c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c' $ACLOCAL $AUTOCONF -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported for vpath in : false; do diff --git a/t/libtool3.sh b/t/libtool3.sh index fb8c194ed..5653280e6 100755 --- a/t/libtool3.sh +++ b/t/libtool3.sh @@ -28,6 +28,10 @@ AC_OUTPUT END cat > Makefile.am << 'END' +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +AUTOMAKE_OPTIONS = -Wno-unsupported + lib_LTLIBRARIES = lib0.la liba/liba.la lib0_la_SOURCES = 0.c liba_liba_la_SOURCES = liba/a.c diff --git a/t/ltinstloc.sh b/t/ltinstloc.sh index b9670cbac..bae3d49df 100755 --- a/t/ltinstloc.sh +++ b/t/ltinstloc.sh @@ -35,6 +35,7 @@ lib_LTLIBRARIES = liba1.la sub/liba2.la pkglib_LTLIBRARIES = liba1.la nobase_lib_LTLIBRARIES = sub/liba2.la endif +AUTOMAKE_OPTIONS = subdir-objects END libtoolize diff --git a/t/ltlibsrc.sh b/t/ltlibsrc.sh index e58bba716..8c8098bdb 100755 --- a/t/ltlibsrc.sh +++ b/t/ltlibsrc.sh @@ -35,6 +35,8 @@ noinst_LTLIBRARIES = foo.la zoo.d/old2.la $(srcdir)/zoo_d_old2_la.c: $(srcdir)/old_la.c cp $(srcdir)/old_la.c $@ + +AUTOMAKE_OPTIONS = -Wno-unsupported END cat > foo.c << 'END' diff --git a/t/ltorder.sh b/t/ltorder.sh index fe9d7bda2..c243ac78b 100755 --- a/t/ltorder.sh +++ b/t/ltorder.sh @@ -27,6 +27,7 @@ AC_OUTPUT END cat >Makefile.am <<'END' +AUTOMAKE_OPTIONS = subdir-objects nobase_lib_LTLIBRARIES = liba1.la sub/liba2.la sub/liba3.la liba4.la liba5.la sub_liba2_la_LIBADD = liba1.la sub_liba3_la_LIBADD = sub/liba2.la diff --git a/t/parallel-tests-suffix-prog.sh b/t/parallel-tests-suffix-prog.sh index 64f103c70..7b924a33b 100755 --- a/t/parallel-tests-suffix-prog.sh +++ b/t/parallel-tests-suffix-prog.sh @@ -27,6 +27,7 @@ AC_OUTPUT END cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects ## Note that automake should not match the '/test' part of 'sub/test' as ## '.test' suffix, nor the '/chk' part of 'sub/chk' as '.chk' suffix. TESTS = $(dist_TESTS) $(check_PROGRAMS) diff --git a/t/sourcefile-in-subdir.sh b/t/sourcefile-in-subdir.sh index a01077617..1054f18aa 100755 --- a/t/sourcefile-in-subdir.sh +++ b/t/sourcefile-in-subdir.sh @@ -29,7 +29,7 @@ AC_PROG_CC END $ACLOCAL -$AUTOMAKE +$AUTOMAKE -Wno-unsupported grep '^z\.o: x/z\.c$' Makefile.in diff --git a/t/specflg9.sh b/t/specflg9.sh index 3e0c69484..4f3d3b0c2 100755 --- a/t/specflg9.sh +++ b/t/specflg9.sh @@ -24,6 +24,7 @@ AC_OUTPUT END cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = zzfoo zzbar zzfoo_SOURCES = sub/foo.c zzbar_SOURCES = bar.c diff --git a/t/subobj.sh b/t/subobj.sh index d16512abc..22ab2d30d 100755 --- a/t/subobj.sh +++ b/t/subobj.sh @@ -14,19 +14,63 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test of subdir objects with C. +# Test of subdir objects with C and C++. . test-init.sh -echo AC_PROG_CC >> configure.ac +cat >> configure.ac <<'END' +AC_PROG_CC +AC_PROG_CXX +AC_PROG_YACC +AC_CONFIG_FILES([sub/Makefile]) +END + +$ACLOCAL +: > ylwrap cat > Makefile.am << 'END' -AUTOMAKE_OPTIONS = subdir-objects +SUBDIRS = sub bin_PROGRAMS = wish -wish_SOURCES = generic/a.c generic/b.c +wish_SOURCES = generic/a.c +wish_SOURCES += another/z.cxx END -$ACLOCAL +mkdir sub +cat > sub/Makefile.am << 'END' +dream_SOURCES = generic/b.c more/r.y +bin_PROGRAMS = dream +END + +AUTOMAKE_fails +grep "^Makefile\.am:3:.*'generic/a\.c'.* in a subdirectory" stderr +grep "^Makefile\.am:[34]:.*'another/z\.cxx'.* in a subdirectory" stderr +grep "^sub/Makefile\.am:1:.*'generic/b\.c'.* in a subdirectory" stderr +grep "option 'subdir-objects' is disabled" stderr +# Verbose tips should be given, but not too many times. +for msg in \ + "possible forward-incompatibility" \ + "advi[sc]e.* 'subdir-objects' option throughout" \ + "unconditionally.* object file.* same subdirectory" \ +; do + test $(grep -c "$msg" stderr) -eq 1 +done + +# Guard against stupid typos. +grep 'subdir-object([^s]|$)' stderr && exit 1 + +$AUTOMAKE -Wno-unsupported + +echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am +AUTOMAKE_fails +grep "^Makefile\.am" stderr && exit 1 +grep "^sub/Makefile\.am:.*'generic/b\.c'.* in a subdirectory" stderr +grep "option 'subdir-objects' is disabled" stderr + +sed 's/^AM_INIT_AUTOMAKE/&([subdir-objects])/' configure.ac > configure.tmp +mv -f configure.tmp configure.ac +$ACLOCAL --force +$AUTOMAKE + rm -f compile $AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; exit 1; } cat stderr >&2 @@ -35,9 +79,12 @@ grep '^configure\.ac:4:.*install.*compile' stderr test -f compile grep '^generic/a\.\$(OBJEXT):' Makefile.in -grep '[^/]a\.\$(OBJEXT)' Makefile.in && exit 1 +grep '^generic/b\.\$(OBJEXT):' sub/Makefile.in +grep '^another/z\.\$(OBJEXT):' Makefile.in +$EGREP '(^|[^/])[abz]\.\$(OBJEXT)' Makefile.in sub/Makefile.in && exit 1 # Opportunistically test for a different bug. -grep '^generic/b\.\$(OBJEXT):.*dirstamp' Makefile.in +grep '^another/z\.\$(OBJEXT):.*dirstamp' Makefile.in +grep '^generic/b\.\$(OBJEXT):.*dirstamp' sub/Makefile.in : diff --git a/t/subobj4.sh b/t/subobj4.sh index 816f50668..dbbed30be 100755 --- a/t/subobj4.sh +++ b/t/subobj4.sh @@ -43,7 +43,7 @@ END : > d2/z.c $ACLOCAL -$AUTOMAKE +$AUTOMAKE -Wno-unsupported grep '\$(CC) .*\.\./d2/z\.c' d1/Makefile.in diff --git a/t/subobj7.sh b/t/subobj7.sh index 5dc9ea861..de73cc2dc 100755 --- a/t/subobj7.sh +++ b/t/subobj7.sh @@ -25,6 +25,7 @@ AC_OUTPUT END cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = wish wish_SOURCES = foo.c generic/a.c END diff --git a/t/subpkg-yacc.sh b/t/subpkg-yacc.sh index 639e4156c..9fc676190 100755 --- a/t/subpkg-yacc.sh +++ b/t/subpkg-yacc.sh @@ -49,7 +49,7 @@ mkdir lib/src cat >lib/configure.ac <<'EOF' AC_INIT([lib], [2.3]) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([subdir-objects]) AC_PROG_RANLIB AC_PROG_YACC dnl This comes after YACC and RANLIB checks, deliberately. diff --git a/t/subpkg.sh b/t/subpkg.sh index 6f59ac58d..f9cdc74e2 100755 --- a/t/subpkg.sh +++ b/t/subpkg.sh @@ -62,7 +62,7 @@ mkdir lib/src cat >lib/configure.ac <<'EOF' AC_INIT([lib], [2.3]) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([subdir-objects]) AC_CONFIG_MACRO_DIR([../m4]) AM_PROG_AR AC_PROG_RANLIB diff --git a/t/suffix-custom-subobj-and-specflg.sh b/t/suffix-custom-subobj-and-specflg.sh index 32356d7b3..b862d8825 100755 --- a/t/suffix-custom-subobj-and-specflg.sh +++ b/t/suffix-custom-subobj-and-specflg.sh @@ -53,18 +53,9 @@ END $ACLOCAL $AUTOCONF $AUTOMAKE -a -./configure -$MAKE - -$MAKE distcheck -$MAKE distclean - -# Should also work without subdir-objects. -sed '/subdir-objects/d' < Makefile.am > t -mv -f t Makefile.am -$AUTOMAKE ./configure + $MAKE $MAKE distcheck diff --git a/t/vala-libs.sh b/t/vala-libs.sh index 66fd2436a..f1ed99ab2 100755 --- a/t/vala-libs.sh +++ b/t/vala-libs.sh @@ -31,6 +31,7 @@ AC_OUTPUT END cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects lib_LIBRARIES = libmu.a lib_LTLIBRARIES = src/libzardoz.la libmu_a_SOURCES = mu.vala mu2.c mu.vapi mu2.h @@ -75,7 +76,7 @@ int main () } END -mkdir src +mkdir -p src cat > src/zardoz-foo.vala << 'END' using GLib; public class Foo { diff --git a/t/vala-non-recursive-setup.sh b/t/vala-non-recursive-setup.sh index 88d9d332a..88f67a879 100755 --- a/t/vala-non-recursive-setup.sh +++ b/t/vala-non-recursive-setup.sh @@ -39,6 +39,7 @@ public class Zardoz { END cat > 'Makefile.am' <<'END' +AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = src/zardoz src_zardoz_CFLAGS = $(GOBJECT_CFLAGS) src_zardoz_LDADD = $(GOBJECT_LIBS) diff --git a/t/yacc-grepping2.sh b/t/yacc-grepping2.sh index 58a963c8c..3c5da2255 100755 --- a/t/yacc-grepping2.sh +++ b/t/yacc-grepping2.sh @@ -34,7 +34,9 @@ mkdir sub : > sub/maude.y $ACLOCAL -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported grep '^maude\.c:.*maude\.y' Makefile.in @@ -47,7 +49,6 @@ bin_PROGRAMS = maude maude_SOURCES = sub/maude.y END -$ACLOCAL $AUTOMAKE -a # No rule needed, the default .y.c: inference rule is enough @@ -64,8 +65,9 @@ maude_SOURCES = sub/maude.y maude_YFLAGS = -d END -$ACLOCAL -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported # Rule should use maude_YFLAGS. grep 'AM_YFLAGS.*maude' Makefile.in && exit 1 diff --git a/t/yacc-line.sh b/t/yacc-line.sh index 9067a2d63..b034af36e 100755 --- a/t/yacc-line.sh +++ b/t/yacc-line.sh @@ -76,7 +76,9 @@ c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c' $ACLOCAL $AUTOCONF -$AUTOMAKE -a +# FIXME: stop disabling the warnings in the 'unsupported' category +# FIXME: once the 'subdir-objects' option has been mandatory. +$AUTOMAKE -a -Wno-unsupported for vpath in : false; do