]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] compiling: remove some code duplication in depend2.am
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 31 Jan 2012 15:57:28 +0000 (16:57 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 31 Jan 2012 22:53:59 +0000 (23:53 +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
tests/fort2.test
tests/subobj4.test

index 71625916f2c72d561bb5d589c9156523d50f85fa..59dd90e8898ea94356811aba123949ca8e3f9c5e 100644 (file)
@@ -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%
index b3c994c17452ddc7c32cb457d69554e2c8380659..10b00f3772641b88a4085cd8741076c55a1d5453 100755 (executable)
@@ -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 \
+  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
+
 :
index 0a29ad023e1f071a755f92a5d12f93dc29d499eb..b3c5696f58570969d53e84deae376bf4790cda05 100755 (executable)
@@ -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 "@am__fastdepCC_FALSE@.*source=['\"]../d2/z.c['\"] " d1/Makefile.in
 
 :