# 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
cat > configure.ac <<END
AC_INIT([$me], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([subdir-objects])
AC_PROG_CC
AM_PROG_AR
$(if test $depcomp_with_libtool = yes; then
grep-test:
## For debugging.
cat \$(DEPDIR)/foo.$po || :
- cat \$(DEPDIR)/subfoo.$po || :
+ cat sub/\$(DEPDIR)/subfoo.$po || :
cat src/\$(DEPDIR)/baz.$po || :
cat src/sub2/\$(DEPDIR)/sub2foo.$po || :
-## Checks done here.
+## Checks are done here.
grep '^foo.$objext.*:' \$(DEPDIR)/foo.$po
- grep '^subfoo\.$objext.*:' \$(DEPDIR)/subfoo.$po
+ grep '^sub/subfoo\.$objext.*:' sub/\$(DEPDIR)/subfoo.$po
grep '^baz\.$objext.*:' src/\$(DEPDIR)/baz.$po
grep '^sub2/sub2foo\.$objext.*:' src/sub2/\$(DEPDIR)/sub2foo.$po
END
cat > src/Makefile.am <<END
-AUTOMAKE_OPTIONS = subdir-objects
noinst_${LIBPRIMARY} = libbaz.$a
# We include sub2foo only to be sure that the munging in depcomp
# doesn't remove too much from the object file name.
ocwd=$(pwd) || fatal_ "getting top-level directory"
-cat >> 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])
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
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
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
# 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.
EOF
cat >Makefile.am <<EOF
+AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = p q r
p_SOURCES = a.cc b.cpp c.cxx
q_SOURCES = sub/d.cc sub/e.cpp sub/f.cxx
cat >Makefile.am <<END
EXTRA_LIBRARIES = libfoo.a
-libfoo_a_SOURCES = sub/foo.c
+libfoo_a_SOURCES = foo.c
END
# Sanity check: extra-portability warnings causes the expected error.
# Cf. 'fort1.sh' and 'link_f90_only.sh'.
+required=gfortran # Required only in order to run ./configure.
. test-init.sh
mkdir sub
AC_FC_SRCEXT([f03])
AC_FC_SRCEXT([f08])
AC_FC_SRCEXT([blabla])
+AC_OUTPUT
END
cat >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
:
END
$ACLOCAL
-$AUTOMAKE -a
+$AUTOMAKE -a -Wno-unsupported
# The Fortran 77 linker should be preferred:
grep '.\$(FCLINK)' Makefile.in && exit 1
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
$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
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
pkglib_LTLIBRARIES = liba1.la
nobase_lib_LTLIBRARIES = sub/liba2.la
endif
+AUTOMAKE_OPTIONS = subdir-objects
END
libtoolize
$(srcdir)/zoo_d_old2_la.c: $(srcdir)/old_la.c
cp $(srcdir)/old_la.c $@
+
+AUTOMAKE_OPTIONS = -Wno-unsupported
END
cat > foo.c << 'END'
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
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)
END
$ACLOCAL
-$AUTOMAKE
+$AUTOMAKE -Wno-unsupported
grep '^z\.o: x/z\.c$' Makefile.in
END
cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = zzfoo zzbar
zzfoo_SOURCES = sub/foo.c
zzbar_SOURCES = bar.c
# 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 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
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
:
: > d2/z.c
$ACLOCAL
-$AUTOMAKE
+$AUTOMAKE -Wno-unsupported
grep '\$(CC) .*\.\./d2/z\.c' d1/Makefile.in
END
cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = wish
wish_SOURCES = foo.c generic/a.c
END
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.
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
$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
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
}
END
-mkdir src
+mkdir -p src
cat > src/zardoz-foo.vala << 'END'
using GLib;
public class Foo {
END
cat > 'Makefile.am' <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = src/zardoz
src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
src_zardoz_LDADD = $(GOBJECT_LIBS)
: > 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
maude_SOURCES = sub/maude.y
END
-$ACLOCAL
$AUTOMAKE -a
# No rule needed, the default .y.c: inference rule is enough
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
$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