[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-ng] [PATCH 2/4] [ng] compiling: remove some code duplication i
From: |
Stefano Lattarini |
Subject: |
[Automake-ng] [PATCH 2/4] [ng] compiling: remove some code duplication in depend2.am |
Date: |
Wed, 1 Feb 2012 10:09:19 +0100 |
* lib/am/depend2.am (am__cooked_source_0, am__cooked_source_1): New
helper variables.
Use them in several compilation rules to avoid code duplication.
* tests/subobj4.test: Adjust.
* tests/fort2.test: Likewise.
---
lib/am/depend2.am | 41 +++++++++++-------------------------
tests/fort2.test | 57 ++++++++++++++++++++++++++++++++++++++++-----------
tests/subobj4.test | 3 +-
3 files changed, 59 insertions(+), 42 deletions(-)
diff --git a/lib/am/depend2.am b/lib/am/depend2.am
index 7162591..59dd90e 100644
--- a/lib/am/depend2.am
+++ b/lib/am/depend2.am
@@ -47,6 +47,11 @@ am__ensure_depdir = test -d $(am__depdir) || $(MKDIR_P)
$(am__depdir)
## 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.
+am__cooked_source_1 = $<
+
endif %?FIRST%
if %?NONLIBTOOL%
@@ -56,9 +61,7 @@ if %FASTDEP%
%SILENT%$(am__ensure_depdir)
## In fast-dep mode, we can always use -o.
%VERBOSE%%COMPILE% -MT $@ -MD -MP -MF $(am__depbase).Tpo %-c% -o $@ \
-?GENERIC? %SOURCEFLAG%%SOURCE%
-## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %SOURCEFLAG%$(call am__vpath_rewrite, %SOURCE%)
+ %SOURCEFLAG%$(am__cooked_source_%GENERIC%)
%SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Po
else !%FASTDEP%
if %AMDEP%
@@ -66,14 +69,8 @@ if %AMDEP%
%VERBOSE%source='%SOURCE%' object='%OBJ%' libtool=no @AMDEPBACKSLASH@
DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@
endif %AMDEP%
-if %?GENERIC%
-?-o? %VERBOSE-NODEP%%COMPILE% %-c% %-o% %OBJ% %SOURCEFLAG%%SOURCE%
-?!-o? %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%%SOURCE%
-else !%?GENERIC%
-## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?-o? %VERBOSE-NODEP%%COMPILE% %-c% %-o% %OBJ% %SOURCEFLAG%$(call
am__vpath_rewrite, %SOURCE%)
-?!-o? %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%$(call am__vpath_rewrite,
%SOURCE%)
-endif !%?GENERIC%
+?-o? %VERBOSE-NODEP%%COMPILE% %-c% %-o% %OBJ%
%SOURCEFLAG%$(am__cooked_source_%GENERIC%)
+?!-o? %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%$(am__cooked_source_%GENERIC%)
endif !%FASTDEP%
?GENERIC?%EXT%.obj:
@@ -82,9 +79,7 @@ if %FASTDEP%
%SILENT%$(am__ensure_depdir)
## In fast-dep mode, we can always use -o.
%VERBOSE%%COMPILE% -MT $@ -MD -MP -MF $(am__depbase).Tpo %-c% -o $@ \
-?GENERIC? %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'`
-## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %SOURCEFLAG%`$(CYGPATH_W) $(call am__vpath_rewrite,%SOURCE%)`
+ %SOURCEFLAG%`$(CYGPATH_W) $(am__cooked_source_%GENERIC%)`
%SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Po
else !%FASTDEP%
if %AMDEP%
@@ -92,14 +87,8 @@ if %AMDEP%
%VERBOSE%source='%SOURCE%' object='%OBJOBJ%' libtool=no @AMDEPBACKSLASH@
DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@
endif %AMDEP%
-if %?GENERIC%
-?-o? %VERBOSE-NODEP%%COMPILE% %-c% %-o% %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W)
'%SOURCE%'`
-?!-o? %VERBOSE-NODEP%%COMPILE% %-c% `$(CYGPATH_W) %SOURCEFLAG%'%SOURCE%'`
-else !%?GENERIC%
-## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?-o? %VERBOSE-NODEP%%COMPILE% %-c% %-o% %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W)
$(call am__vpath_rewrite, %SOURCE%)`
-?!-o? %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%`$(CYGPATH_W) $(call
am__vpath_rewrite, %SOURCE%)`
-endif !%?GENERIC%
+?-o? %VERBOSE-NODEP%%COMPILE% %-c% %-o% %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W)
$(am__cooked_source_%GENERIC%)`
+?!-o? %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%`$(CYGPATH_W)
$(am__cooked_source_%GENERIC%)`
endif !%FASTDEP%
endif %?NONLIBTOOL%
@@ -110,9 +99,7 @@ if %FASTDEP%
%SILENT%$(am__ensure_depdir)
## In fast-dep mode, we can always use -o.
%VERBOSE%%LTCOMPILE% -MT $@ -MD -MP -MF $(am__depbase).Tpo %-c% -o $@ \
-?GENERIC? %SOURCEFLAG%%SOURCE%
-## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %SOURCEFLAG%$(call am__vpath_rewrite, %SOURCE%)
+ %SOURCEFLAG%$(am__cooked_source_%GENERIC%)
%SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Plo
else !%FASTDEP%
if %AMDEP%
@@ -121,8 +108,6 @@ if %AMDEP%
DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@
endif %AMDEP%
## We can always use `-o' with Libtool.
-?GENERIC? %VERBOSE-NODEP%%LTCOMPILE% %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE%
-## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC? %VERBOSE-NODEP%%LTCOMPILE% %-c% -o %LTOBJ% %SOURCEFLAG%$(call
am__vpath_rewrite, %SOURCE%)
+ %VERBOSE-NODEP%%LTCOMPILE% %-c% -o %LTOBJ%
%SOURCEFLAG%$(am__cooked_source_%GENERIC%)
endif !%FASTDEP%
endif %?LIBTOOL%
diff --git a/tests/fort2.test b/tests/fort2.test
index b3c994c..10b00f3 100755
--- a/tests/fort2.test
+++ b/tests/fort2.test
@@ -19,6 +19,7 @@
# Cf. fort1.test and link_f90_only.test.
+required=gfortran # Required only in order to run ./configure.
. ./defs || Exit 1
mkdir sub
@@ -30,32 +31,62 @@ AC_FC_SRCEXT([f95])
AC_FC_SRCEXT([f03])
AC_FC_SRCEXT([f08])
AC_FC_SRCEXT([blabla])
+AC_OUTPUT
END
cat >Makefile.am <<'END'
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.in >t
+mv -f t configure.in
+
+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 FC=fake-fc \
+ address@hidden address@hidden address@hidden address@hidden \
+ > 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 .* address@hidden .* hello\.f90 ' out
+grep ' fake-fc .* address@hidden .* foo\.f95 ' out
+grep ' fake-fc .* address@hidden .* sub/bar\.f95 ' out
+grep ' fake-fc .* address@hidden .* hi\.f03 ' out
+grep ' fake-fc .* address@hidden .* sub/howdy\.f03 ' out
+grep ' fake-fc .* address@hidden .* greets\.f08 ' out
+grep ' fake-fc .* address@hidden .* sub/bonjour\.f08 ' out
+grep ' fake-fc .* --gby .* address@hidden .* bye\.f95 ' out
+grep ' fake-fc .* --gby .* address@hidden .* 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/tests/subobj4.test b/tests/subobj4.test
index 0a29ad0..b3c5696 100755
--- a/tests/subobj4.test
+++ b/tests/subobj4.test
@@ -48,6 +48,7 @@ END
$ACLOCAL
$AUTOMAKE
-grep '\$(CC) .*\.\./d2/z\.c' d1/Makefile.in
+grep '^z\.o:.* \.\./d2/z\.c *$' d1/Makefile.in
+grep "@address@hidden'\"]../d2/z.c['\"] " d1/Makefile.in
:
--
1.7.7.3