From 823af0e1feadceb9bfc16f61486ab3c1bf6990cf Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Tue, 31 Jan 2012 16:57:28 +0100 Subject: [PATCH] [ng] compiling: remove some code duplication in depend2.am * 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 71625916f..59dd90e88 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 b3c994c17..10b00f377 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 \ + 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 + : diff --git a/tests/subobj4.test b/tests/subobj4.test index 0a29ad023..b3c5696f5 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 "@am__fastdepCC_FALSE@.*source=['\"]../d2/z.c['\"] " d1/Makefile.in : -- 2.47.2