From: Stefano Lattarini Date: Sun, 29 May 2011 13:24:58 +0000 (+0200) Subject: remake: behave better with non-GNU make in subdirectories X-Git-Tag: v1.11.1b~26^2~28^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=v1.11-366-gbee9871;p=thirdparty%2Fautomake.git remake: behave better with non-GNU make in subdirectories Currently, with every decent make program, it is possible to rebuild out-of-date autotools-generated files with a simple "make Makefile" -- but for this to work reliably with non-GNU make implementations, the command must be issued from the top-level directory. This patch removes such limitation. * lib/am/configure.am (am--refresh): Depend on `%MAKEFILE%'. * tests/defs.in (using_gmake): New function, backported from the `master' branch (and simplified). * tests/remake-subdir.test: New test. * tests/remake-subdir2.test: Likewise. * tests/remake-subdir-gnu.test: Likewise. * tests/remake-subdir-from-subdir.test: Likewise. * tests/Makefile.am (TESTS): Update. --- diff --git a/ChangeLog b/ChangeLog index 363112927..9c9b2561a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2011-05-29 Stefano Lattarini + + remake: behave better with non-GNU make in subdirectories + Currently, with every decent make program, it is possible to + rebuild out-of-date autotools-generated files with a simple + "make Makefile" -- but for this to work reliably with non-GNU + make implementations, the command must be issued from the + top-level directory. This patch removes such limitation. + * lib/am/configure.am (am--refresh): Depend on `%MAKEFILE%'. + * tests/defs.in (using_gmake): New function, backported from the + `master' branch (and simplified). + * tests/remake-subdir.test: New test. + * tests/remake-subdir2.test: Likewise. + * tests/remake-subdir-gnu.test: Likewise. + * tests/remake-subdir-from-subdir.test: Likewise. + * tests/Makefile.am (TESTS): Update. + 2011-05-20 Stefano Lattarini testsuite: avoid re-running few tests with 'parallel-tests' option diff --git a/Makefile.in b/Makefile.in index 49c35f50e..b5acca7bc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -372,7 +372,7 @@ texinfo.tex all: all-recursive .SUFFIXES: -am--refresh: +am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ diff --git a/lib/am/configure.am b/lib/am/configure.am index e9299d64b..d00846aaa 100644 --- a/lib/am/configure.am +++ b/lib/am/configure.am @@ -22,7 +22,7 @@ ## %MAKEFILE% is updated before considering the am--refresh target. if %?TOPDIR_P% .PHONY: am--refresh -am--refresh: +am--refresh: %MAKEFILE% @: endif %?TOPDIR_P% diff --git a/tests/Makefile.am b/tests/Makefile.am index 49d894281..33ae8bc62 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -654,6 +654,10 @@ remake4.test \ remake5.test \ remake6.test \ remake7.test \ +remake-subdir-from-subdir.test \ +remake-subdir-gnu.test \ +remake-subdir.test \ +remake-subdir2.test \ pr8365-remake-timing.test \ regex.test \ req.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 110d13b85..ad45cffbd 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -922,6 +922,10 @@ remake4.test \ remake5.test \ remake6.test \ remake7.test \ +remake-subdir-from-subdir.test \ +remake-subdir-gnu.test \ +remake-subdir.test \ +remake-subdir2.test \ pr8365-remake-timing.test \ regex.test \ req.test \ diff --git a/tests/defs.in b/tests/defs.in index e020498af..1a72391fa 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -513,6 +513,16 @@ is_newest () test -z "$is_newest_files" } +# using_gmake +# ----------- +# Return success if $MAKE is GNU make, return failure otherwise. +using_gmake () +{ + # Use --version AND -v, because SGI Make doesn't fail on --version. + # Also grep for GNU because newer versions of FreeBSD make do + # not complain about `--version' (they seem to silently ignore it). + $MAKE --version -v | grep GNU +} # AUTOMAKE_run status [options...] # -------------------------------- diff --git a/tests/remake-subdir-from-subdir.test b/tests/remake-subdir-from-subdir.test new file mode 100755 index 000000000..1e369f8a2 --- /dev/null +++ b/tests/remake-subdir-from-subdir.test @@ -0,0 +1,56 @@ +#! /bin/sh +# Copyright (C) 2009 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 . + +# Check that remake rules works for adding a new subdirectory from a +# pre-existing subdirectory. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +m4_include([subdirs.m4]) +AC_SUBST([MAGIC], [magic]) +AC_OUTPUT +END + +echo 'AC_CONFIG_FILES([sub/Makefile])' > subdirs.m4 +echo 'SUBDIRS = sub' > Makefile.am + +mkdir sub +: > sub/Makefile.am + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +$MAKE + +cd sub +$sleep +echo 'AC_CONFIG_FILES([sub/subsub/Makefile])' >> ../subdirs.m4 +echo 'SUBDIRS = subsub' >> Makefile.am +mkdir subsub +cat > subsub/Makefile.am <<'END' +all-local: + : > ok-it-works +END +using_gmake || $MAKE Makefile +$MAKE +test -f subsub/ok-it-works + +: diff --git a/tests/remake-subdir-gnu.test b/tests/remake-subdir-gnu.test new file mode 100755 index 000000000..cc683f3ae --- /dev/null +++ b/tests/remake-subdir-gnu.test @@ -0,0 +1,80 @@ +#! /bin/sh +# Copyright (C) 2011 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 . + +# Check that remake rules works from subdirectories, even using +# `GNUmakefile' as makefiles name. This obviously requires GNU +# make. + +required=GNUmake +. ./defs || Exit 1 + +set -e + +magic1='::MagicString::One::' +magic2='__MagicString__Two__' + +debug_info () +{ + grep -i magic configure GNUmakefile.in GNUmakefile \ + sub/GNUmakefile.in sub/GNUmakefile +} + +cat > configure.in < GNUmakefile.am <<'END' +SUBDIRS = sub +END + +mkdir sub +: > sub/GNUmakefile.am + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +$MAKE +debug_info + +$sleep +sed "s|magic|$magic1|" configure.in > t +mv -f t configure.in +cd sub +$MAKE +cd .. +debug_info +$FGREP $magic1 configure +$FGREP $magic1 GNUmakefile +$FGREP $magic1 sub/GNUmakefile + +$sleep +cd sub +echo MAGIC = $magic2 >> GNUmakefile.am +$MAKE +cd .. +debug_info +$FGREP $magic2 sub/GNUmakefile +$FGREP $magic2 sub/GNUmakefile.in +$FGREP $magic1 sub/GNUmakefile sub/GNUmakefile.in && Exit 1 +$FGREP $magic2 GNUmakefile GNUmakefile.in && Exit 1 + +: diff --git a/tests/remake-subdir.test b/tests/remake-subdir.test new file mode 100755 index 000000000..5bbc3452b --- /dev/null +++ b/tests/remake-subdir.test @@ -0,0 +1,81 @@ +#! /bin/sh +# Copyright (C) 2011 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 . + +# Check that remake rules works from subdirectories, even with non-GNU +# make implementations. + +. ./defs || Exit 1 + +set -e + +if using_gmake; then + remake=$MAKE +else + remake="$MAKE Makefile" +fi + +magic1='::MagicString::One::' +magic2='__MagicString__Two__' + +debug_info () +{ + grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile +} + +cat >> configure.in <<'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_SUBST([MAGIC], [magic]) +AC_OUTPUT +END + +cat > Makefile.am <<'END' +SUBDIRS = sub +END + +mkdir sub +: > sub/Makefile.am + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +$MAKE +debug_info + +$sleep +sed "s|magic|$magic1|" configure.in > t +mv -f t configure.in +cd sub +$remake +cd .. +debug_info +$FGREP $magic1 configure +$FGREP $magic1 Makefile +$FGREP $magic1 sub/Makefile + +$sleep +cd sub +echo MAGIC = $magic2 >> Makefile.am +$remake +cd .. +debug_info +$FGREP $magic2 sub/Makefile +$FGREP $magic2 sub/Makefile.in +$FGREP $magic1 sub/Makefile sub/Makefile.in && Exit 1 +$FGREP $magic2 Makefile Makefile.in && Exit 1 + +: diff --git a/tests/remake-subdir2.test b/tests/remake-subdir2.test new file mode 100755 index 000000000..09d1a36b9 --- /dev/null +++ b/tests/remake-subdir2.test @@ -0,0 +1,82 @@ +#! /bin/sh +# Copyright (C) 2011 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 . + +# Check that remake rules works from subdirectories, even when makefiles +# are not named "Makefile". + +. ./defs || Exit 1 + +set -e + +magic1='::MagicString::One::' +magic2='__MagicString__Two__' + +debug_info () +{ + grep -i magic configure build.in build.mk sub/build.in sub/build.mk +} + +cat > configure.in < build.am <<'END' +AM_MAKEFLAGS = -f build.mk +SUBDIRS = sub +END + +mkdir sub +cat > sub/build.am <<'END' +AM_MAKEFLAGS = -f build.mk +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure +ls -l # For debugging. + +$MAKE -f build.mk +debug_info + +$sleep +sed "s|magic|$magic1|" configure.in > t +mv -f t configure.in +cd sub +$MAKE -f build.mk build.mk +cd .. +debug_info +$FGREP $magic1 configure +$FGREP $magic1 build.mk +$FGREP $magic1 sub/build.mk + +$sleep +cd sub +echo MAGIC = $magic2 >> build.am +$MAKE -f build.mk build.mk +cd .. +debug_info +$FGREP $magic2 sub/build.mk +$FGREP $magic2 sub/build.in +$FGREP $magic1 sub/build.in sub/build.mk && Exit 1 +$FGREP $magic2 build.in build.mk && Exit 1 + +: