]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] vpath: define generic make function for VPATH rewrites
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 31 Jan 2012 19:37:16 +0000 (20:37 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 1 Feb 2012 12:18:22 +0000 (13:18 +0100)
This change generalizes and makes available to all the Automake
generated Makefiles a common idiom dealing with VPATH rewrites.
This idiom was introduced in recent commits (see in particular
'v1.11-1835-gcf93724').

* lib/am/depend2.am (am__vpath_rewrite): Move ...
* lib/am/header-vars.am: ... here.
* tests/vpath-rewrite.test: New test.
* tests/list-of-tests.mk: Add it.

lib/am/depend2.am
lib/am/header-vars.am
tests/list-of-tests.mk
tests/vpath-rewrite.test [new file with mode: 0755]

index 59dd90e8898ea94356811aba123949ca8e3f9c5e..df5db1ef5f80915071706ccbf1523a4d97d48292 100644 (file)
@@ -43,10 +43,6 @@ am__depbase = $(am__depdir)/$(basename $(notdir $@))
 ## Avoid useless forks when possible.
 am__ensure_depdir = test -d $(am__depdir) || $(MKDIR_P) $(am__depdir)
 
-## Emulate VPATH rewrites.  This only uses GNU make primitives, which
-## allows us to avoid extra forks.
-am__vpath_rewrite = $(firstword $(wildcard $(strip $(1))) $(srcdir)/$(strip $(1)))
-
 ## Used for suffix rules.
 am__cooked_source_0 = $(call am__vpath_rewrite, $<)
 ## Used for explicit rules.
index f4124706f317190a06aa7a5f2adce629516a789a..425a6b236a24fabcaa89ac3300f98b75e696380f 100644 (file)
 
 VPATH = @srcdir@
 
+## Emulate VPATH rewrites.  This uses only GNU make primitives, which
+## allows us to avoid extra forks.
+am__vpath_rewrite = \
+  $(firstword $(wildcard $(strip $(1))) $(srcdir)/$(strip $(1)))
+
 ## We used to define this.  However, we don't because vendor makes
 ## (e.g., Solaris, Irix) won't correctly propagate variables that are
 ## defined in Makefile.  This particular variable can't be correctly
index d59086885e4365e4e9c9b0acdf61601f011be788..77f0d00902d0f2fd17371a4c2b2413da6c105b55 100644 (file)
@@ -1154,6 +1154,7 @@ version6.test \
 version7.test \
 version8.test \
 vpath.test \
+vpath-rewrite.test \
 vtexi.test \
 vtexi2.test \
 vtexi3.test \
diff --git a/tests/vpath-rewrite.test b/tests/vpath-rewrite.test
new file mode 100755 (executable)
index 0000000..0b43236
--- /dev/null
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2012 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 Automake-provided internal make macros to deal with VPATH rewrites.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am << END
+bsub:
+       mkdir \$@
+bsub/foo: bsub
+       mkdir \$@
+bsub/foo/bar: bsub/foo
+       mkdir \$@
+bsub/mu.c++: bsub/foo
+       touch \$@
+bsub/foo/pu.cxx: bsub/foo
+       touch \$@
+
+clean-local:
+       rm -rf bsub
+
+## Yes, I'm a lazy typist.
+vr = \$(am__vpath_rewrite)
+
+test-common: bsub/foo/bar bsub/mu.c++ bsub/foo/pu.cxx
+       test '\$(call vr,Makefile)'             = Makefile
+       test '\$(call vr,$tab config.status  )' = config.status
+       test '\$(call vr,.)'                    = .
+## FIXME: These two do not work apparently :-(  Such use cases are not
+## FIXME: required presently though, so this is not a big deal.
+       : test '\$(call vr, bsub$tab  )'        = bsub
+       : test '\$(call vr,bsub)'               = bsub
+       test '\$(call vr,bsub/.)'               = bsub/.
+       test '\$(call vr,bsub/mu.c++)'          = bsub/mu.c++
+       test '\$(call vr,bsub/foo/pu.cxx)'      = bsub/foo/pu.cxx
+       test '\$(call vr,bsub/foo )'            = bsub/foo
+       test '\$(call vr,bsub/foo/bar)'         = bsub/foo/bar
+       test '\$(call vr,nonesuch)'             = \$(srcdir)/nonesuch
+       test '\$(call vr, $tab  nonesuch2  )'   = \$(srcdir)/nonesuch2
+       test '\$(call vr, sub/none)'            = \$(srcdir)/sub/none
+
+test-vpath: test-common
+       test '\$(call vr,ssub)'                   = \$(srcdir)/ssub
+       test '\$(call vr,ssub/foo )'              = \$(srcdir)/ssub/foo
+       test '\$(call vr, ssub/foo/bar)'          = \$(srcdir)/ssub/foo/bar
+       test '\$(call vr,Makefile.in )'           = \$(srcdir)/Makefile.in
+       test '\$(call vr,zap/paz.c)'              = \$(srcdir)/zap/paz.c
+       test '\$(call vr,configure $tab)'         = \$(srcdir)/configure
+       test '\$(call vr,    configure.in$tab  )' = \$(srcdir)/configure.in
+
+test-intree: test-common
+       test '\$(call vr,ssub)'                   = ssub
+       test '\$(call vr,ssub/foo )'              = ssub/foo
+       test '\$(call vr, ssub/foo/bar)'          = ssub/foo/bar
+       test '\$(call vr,Makefile.in )'           = Makefile.in
+       test '\$(call vr,zap/paz.c)'              = zap/paz.c
+       test '\$(call vr,configure $tab)'         = configure
+       test '\$(call vr,    configure.in$tab  )' = configure.in
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+mkdir zap ssub ssub/foo ssub/foo/bar
+: > zap/paz.c
+
+./configure
+$MAKE test-intree
+$MAKE distclean
+
+mkdir build
+cd build
+../configure
+$MAKE test-vpath
+cd ..
+
+ocwd=`pwd` || fatal_ "couldn't get current working directory"
+mkdir build2 build2/subbuild
+cd build2/subbuild
+"$ocwd"/configure
+$MAKE test-vpath
+
+: