[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-ng] [PATCH 3/4] [ng] vpath: define generic make function for V
From: |
Stefano Lattarini |
Subject: |
[Automake-ng] [PATCH 3/4] [ng] vpath: define generic make function for VPATH rewrites |
Date: |
Wed, 1 Feb 2012 10:09:20 +0100 |
This change generalize and make available to all the Automake
generated Makefiles a common idiom dealing with VPATH rewrites.
This idiom has been introduced in the 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 | 4 --
lib/am/header-vars.am | 5 ++
tests/list-of-tests.mk | 1 +
tests/vpath-rewrite.test | 100 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 106 insertions(+), 4 deletions(-)
create mode 100755 tests/vpath-rewrite.test
diff --git a/lib/am/depend2.am b/lib/am/depend2.am
index 59dd90e..df5db1e 100644
--- a/lib/am/depend2.am
+++ b/lib/am/depend2.am
@@ -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.
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index f412470..65a12af 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -17,6 +17,11 @@
VPATH = @srcdir@
+## 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)))
+
## 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
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index d590868..77f0d00 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -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
index 0000000..03378d7
--- /dev/null
+++ b/tests/vpath-rewrite.test
@@ -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 does 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
+
+:
--
1.7.7.3