automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-NG] [PATCH 2/3] [ng] depcomp: unify rules for '.o' and '.obj'


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH 2/3] [ng] depcomp: unify rules for '.o' and '.obj' objects
Date: Fri, 8 Jun 2012 12:49:12 +0200

This change just reduces code duplication and size of the generated
Makefiles a little.  No actual semantic change is intended.

* automake.in (handle_languages): Drop the '%OBJOBJ%' transform.
* lib/am/depend2.am (am__o_src): New, return the path of the source
file corresponding to the target compiled object unchanged when the
object has the '.o' suffix, and returns a proper invocation of
'$(CYGPATH_W)' on that same source file when the object has the
'.obj' suffix.
Using the new $(am__o_src) function, unify rules for the creation of
'.o' and '.obj' objects into a rule for the creation of '.$(OBJEXT)'
objects.
* t/ext.sh: Adjust grepping checks.
* t/ext2.sh: Likewise.
* t/libtool3.sh: Likewise.
* t/objc-basic.sh: Likewise.
* t/objcxx-basic.sh: Likewise.
* t/silent-many-gcc.sh: Likewise.
* t/silent-many-generic.sh: Likewise.
* t/specflg6.sh: Likewise.
* t/subdir3.sh: Likewise.
* t/subobj4.sh: Likewise.
* t/suffix.sh: Likewise.
* t/suffix2.sh: Likewise.
* t/empty2.sh: Enhance a little.
* t/empty3.sh: Likewise.
* t/specflg.sh: Likewise, and adjust comments.
* t/specflg2.sh: Likewise.
* t/pr87.sh: Remove an obsolete check (obsolete since our switch
from suffix rules to pattern rules for C compilation recipes).

Signed-off-by: Stefano Lattarini <address@hidden>
---
 automake.in              |    2 --
 lib/am/depend2.am        |   31 ++++++-------------------------
 t/empty2.sh              |    5 +++--
 t/empty3.sh              |    4 +++-
 t/ext.sh                 |    4 ++--
 t/ext2.sh                |    2 +-
 t/libtool3.sh            |    8 ++++----
 t/objc-basic.sh          |    2 +-
 t/objcxx-basic.sh        |    2 +-
 t/pr87.sh                |   13 -------------
 t/silent-many-gcc.sh     |    2 +-
 t/silent-many-generic.sh |    2 +-
 t/specflg.sh             |   10 ++++++----
 t/specflg2.sh            |   15 +++++++++------
 t/specflg6.sh            |    4 ++--
 t/subdir3.sh             |    2 +-
 t/subobj4.sh             |    2 +-
 t/suffix.sh              |   14 +++++---------
 t/suffix2.sh             |   15 ++++++---------
 19 files changed, 53 insertions(+), 86 deletions(-)

diff --git a/automake.in b/automake.in
index 176e882..e7034e0 100644
--- a/automake.in
+++ b/automake.in
@@ -1395,7 +1395,6 @@ sub handle_languages
                             SOURCE    => '$<',
                             SOURCEFLAG => $sourceflags{$ext} || '',
                             OBJ       => '$@',
-                            OBJOBJ    => '$@',
                             LTOBJ     => '$@',
 
                             COMPILE   => '$(' . $lang->compiler . ')',
@@ -1461,7 +1460,6 @@ sub handle_languages
                             # we are actually building a new source
                             # file -- e.g. via yacc.
                             OBJ       => "$obj$myext",
-                            OBJOBJ    => "$obj.obj",
                             LTOBJ     => "$obj.lo",
 
                             VERBOSE   => $verbose,
diff --git a/lib/am/depend2.am b/lib/am/depend2.am
index b57f19a..81d2c4c 100644
--- a/lib/am/depend2.am
+++ b/lib/am/depend2.am
@@ -39,36 +39,17 @@ if %?FIRST%
 am__depbase = $(am__depdir)/$(basename $(notdir $@))
 ## Avoid useless forks when possible.
 am__ensure_depdir = $(call am__ensure_dir_exists,$(am__depdir))
+am__o_src = $(if $(filter .obj,$(suffix $@)),`$(CYGPATH_W) $<`,$<)
 endif %?FIRST%
 
 if %?NONLIBTOOL%
-?GENERIC?%.o: %%EXT%
-?!GENERIC?%OBJ%: %SOURCE%
+?GENERIC?%.$(OBJEXT): %%EXT%
+?!GENERIC?%BASE%.$(OBJEXT): %SOURCE%
 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 $@ %SOURCEFLAG%$<
-       %SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Po
-else !%FASTDEP%
-if !%AMDEP%
-       %SILENT%$(am__ensure_target_dir_exists)
-else %AMDEP%
-       %SILENT%$(am__ensure_depdir)
-       %VERBOSE%source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-       DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@
-endif %AMDEP%
-?-o?   %VERBOSE-NODEP%%COMPILE% %-c% %-o% $@ %SOURCEFLAG%$<
-?!-o?  %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%$<
-endif !%FASTDEP%
-
-?GENERIC?%.obj: %%EXT%
-?!GENERIC?%OBJOBJ%: %SOURCE%
-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 $@ %SOURCEFLAG%`$(CYGPATH_W) $<`
+                %-c% -o $@ %SOURCEFLAG%$(am__o_src)
        %SILENT%$(am__mv) $(am__depbase).Tpo $(am__depbase).Po
 else !%FASTDEP%
 if !%AMDEP%
@@ -78,8 +59,8 @@ else %AMDEP%
        %VERBOSE%source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
        DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@
 endif %AMDEP%
-?-o?   %VERBOSE-NODEP%%COMPILE% %-c% %-o% $@ %SOURCEFLAG%`$(CYGPATH_W) $<`
-?!-o?  %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%`$(CYGPATH_W) $<`
+?-o?   %VERBOSE-NODEP%%COMPILE% %-c% %-o% $@ %SOURCEFLAG%$(am__o_src)
+?!-o?  %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%$(am__o_src)
 endif !%FASTDEP%
 endif %?NONLIBTOOL%
 
diff --git a/t/empty2.sh b/t/empty2.sh
index 7d12423..224c26d 100755
--- a/t/empty2.sh
+++ b/t/empty2.sh
@@ -31,5 +31,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep 'pavel\.[co]' Makefile.in && Exit 1
-Exit 0
+grep 'pavel\.' Makefile.in && Exit 1
+
+:
diff --git a/t/empty3.sh b/t/empty3.sh
index 6aabfba..4721db5 100755
--- a/t/empty3.sh
+++ b/t/empty3.sh
@@ -29,4 +29,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep 'pavel\.[co]' Makefile.in
+$FGREP ' pavel.c' Makefile.in
+
+:
diff --git a/t/ext.sh b/t/ext.sh
index 02ceab5..72ff211 100755
--- a/t/ext.sh
+++ b/t/ext.sh
@@ -34,11 +34,11 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-$FGREP '%.o' Makefile.in  # For debugging.
+$FGREP '%.$(OBJEXT)' Makefile.in  # For debugging.
 
 for ext in f for f90 f95 F F90 F95 r m mm upc; do
    grep "%.*: %$ext" Makefile.in && Exit 1
-   grep "^%\.o: %\.$ext$" Makefile.in
+   grep "^%\.\$(OBJEXT): %\.$ext$" Makefile.in
 done
 
 :
diff --git a/t/ext2.sh b/t/ext2.sh
index ac5b777..a114580 100755
--- a/t/ext2.sh
+++ b/t/ext2.sh
@@ -35,7 +35,7 @@ EOF
 $ACLOCAL
 $AUTOMAKE
 
-grep '\.o:' Makefile.in > rules
+grep '\.$(OBJEXT):' Makefile.in > rules
 cat rules
 
 # Here is an example of bogus output.  The rules are output several
diff --git a/t/libtool3.sh b/t/libtool3.sh
index dbcd519..2f18b15 100755
--- a/t/libtool3.sh
+++ b/t/libtool3.sh
@@ -75,11 +75,11 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing --copy
 
-# We need explicit rules to build 1.o and a.lo.  Make sure
-# Automake did not output additional rules for 1.lo and and a.lo.
-$FGREP '1.o:' Makefile.in
+# We need explicit rules to build 1.$(OBJEXT) and a.lo.  Make sure
+# Automake did not output additional rules for 1.lo and a.lo.
+$FGREP '1.$(OBJEXT):' Makefile.in
 $FGREP '1.lo:' Makefile.in && Exit 1
-$FGREP 'a.o:' Makefile.in && Exit 1
+$FGREP 'a.$(OBJEXT):' Makefile.in && Exit 1
 $FGREP 'a.lo:' Makefile.in
 
 ./configure
diff --git a/t/objc-basic.sh b/t/objc-basic.sh
index f3234d7..464887b 100755
--- a/t/objc-basic.sh
+++ b/t/objc-basic.sh
@@ -35,6 +35,6 @@ $ACLOCAL
 $AUTOMAKE
 $FGREP '$(OBJC)' Makefile.in
 $FGREP '$(OBJCLD)' Makefile.in
-grep '^%\.o: %\.m$' Makefile.in
+grep '^%\.$(OBJEXT): %\.m$' Makefile.in
 
 :
diff --git a/t/objcxx-basic.sh b/t/objcxx-basic.sh
index 29aa982..1c807dc 100755
--- a/t/objcxx-basic.sh
+++ b/t/objcxx-basic.sh
@@ -37,6 +37,6 @@ $ACLOCAL
 $AUTOMAKE
 $FGREP '$(OBJCXX)' Makefile.in
 $FGREP '$(OBJCXXLD)' Makefile.in
-grep '^%\.o: %\.mm$' Makefile.in
+grep '^%\.$(OBJEXT): %\.mm$' Makefile.in
 
 :
diff --git a/t/pr87.sh b/t/pr87.sh
index 121328d..c6cb90a 100755
--- a/t/pr87.sh
+++ b/t/pr87.sh
@@ -55,19 +55,6 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-# Regression test for bug where '.c.o:' is followed by blank line.
-(while read line; do
-    if test "$line" = ".c.o:"; then
-       read next
-       if test -z "$next"; then
-         Exit 1
-       else
-          : # For shells with broken 'set -e'.
-       fi
-       break
-    fi
- done) < foo/Makefile.in || Exit 1
-
 cd build
 ../configure
 $MAKE distcheck
diff --git a/t/silent-many-gcc.sh b/t/silent-many-gcc.sh
index 8ad0720..46d4e45 100755
--- a/t/silent-many-gcc.sh
+++ b/t/silent-many-gcc.sh
@@ -196,7 +196,7 @@ $FGREP am_cv_CC_dependencies_compiler_type configure
 $FGREP am_cv_CXX_dependencies_compiler_type configure
 # Ensure per-target rules are used, to ensure their coverage below.
 # (We do not do an exhaustive check, that wouldn't be practical).
-$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'bar-bar.$(OBJEXT)' Makefile.in
 $FGREP 'fo2-foo5.c' Makefile.in
 $FGREP 'fo2-foo6.c' Makefile.in
 
diff --git a/t/silent-many-generic.sh b/t/silent-many-generic.sh
index cd37672..4e6c6f9 100755
--- a/t/silent-many-generic.sh
+++ b/t/silent-many-generic.sh
@@ -223,7 +223,7 @@ $AUTOCONF
 
 # Ensure per-target rules are used, to ensure their coverage below.
 # (We do not do an exhaustive check, that wouldn't be practical).
-$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'bar-bar.$(OBJEXT)' Makefile.in
 $FGREP 'fo2-foo5.c' Makefile.in
 $FGREP 'fo2-foo6.c' Makefile.in
 
diff --git a/t/specflg.sh b/t/specflg.sh
index 9d5c73c..6cb6b36 100755
--- a/t/specflg.sh
+++ b/t/specflg.sh
@@ -39,13 +39,15 @@ grep 'required.*compile' stderr
 
 $AUTOMAKE
 
-# Look for $(COMPILE) -c in .c.o rule.
+$FGREP 'foo-foo.$(OBJEXT)' Makefile.in
+
+# Watch against "$(COMPILE) -c" in "%.o: %.c" rule.
 grep 'COMPILE. [^-]' Makefile.in && Exit 1
 
-# Look for foo-foo.o.
-grep '[^-]foo\.o' Makefile.in && Exit 1
+# Watch against "foo.$(OBJEXT)", "foo.o" and "foo.obj".
+grep '[^-]foo\.[o$]' Makefile.in && Exit 1
 
 # Regression test for missing space.
 $FGREP ')-c' Makefile.in && Exit 1
 
-Exit 0
+:
diff --git a/t/specflg2.sh b/t/specflg2.sh
index 9f9569c..aff03b8 100755
--- a/t/specflg2.sh
+++ b/t/specflg2.sh
@@ -45,15 +45,18 @@ grep 'required.*compile' stderr
 
 $AUTOMAKE
 
-# Look for $(COMPILE) -c in .c.o rule.
+$FGREP 'libfoo_a-foo.$(OBJEXT)' Makefile.in
+$FGREP 'libfoo_a-bar.$(OBJEXT)' Makefile.in
+
+# Watch against "$(COMPILE) -c" in the "%.o: %c" rule.
 grep 'COMPILE. [^-]' Makefile.in && Exit 1
 
-# Look for libfoo_a-foo.o.
+# Watch against "foo.$(OBJEXT)", "foo.o" and "foo.obj".
 grep foo Makefile.in
-grep '[^-]foo\.o' Makefile.in && Exit 1
+grep '[^-]foo\.[o$]' Makefile.in && Exit 1
 
-# Look for libfoo_a-bar.o.
+# Watch against "bar.$(OBJEXT)", "bar.o" and "bar.obj".
 grep bar Makefile.in
-grep '[^-]bar\.o' Makefile.in && Exit 1
+grep '[^-]bar\.[o$]' Makefile.in && Exit 1
 
-Exit 0
+:
diff --git a/t/specflg6.sh b/t/specflg6.sh
index f420cdf..cc585e9 100755
--- a/t/specflg6.sh
+++ b/t/specflg6.sh
@@ -41,7 +41,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-uncondval=`$FGREP 'foo-foo.o: foo.c' Makefile.in`
+uncondval=`$FGREP 'foo-foo.$(OBJEXT): foo.c' Makefile.in`
 
 cat >> Makefile.am << 'END'
 foo_SOURCES += $(BAR_SRCS)
@@ -49,7 +49,7 @@ END
 
 $AUTOMAKE
 
-condval=`$FGREP 'foo-foo.o: foo.c' Makefile.in`
+condval=`$FGREP 'foo-foo.$(OBJEXT): foo.c' Makefile.in`
 
 test "x$uncondval" = "x$condval"
 
diff --git a/t/subdir3.sh b/t/subdir3.sh
index d9b160f..984fe43 100755
--- a/t/subdir3.sh
+++ b/t/subdir3.sh
@@ -31,6 +31,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '^z\.o: x/z\.c$' Makefile.in
+grep '^z\.\$(OBJEXT): x/z\.c$' Makefile.in
 
 :
diff --git a/t/subobj4.sh b/t/subobj4.sh
index 6aeb19d..fda35eb 100755
--- a/t/subobj4.sh
+++ b/t/subobj4.sh
@@ -47,6 +47,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '^z\.o:.* \.\./d2/z\.c *$' d1/Makefile.in
+grep '^z\.$(OBJEXT):.* \.\./d2/z\.c *$' d1/Makefile.in
 
 :
diff --git a/t/suffix.sh b/t/suffix.sh
index 0d72782..c60f734 100755
--- a/t/suffix.sh
+++ b/t/suffix.sh
@@ -44,15 +44,11 @@ for use_arlib in false :; do
 
   $ACLOCAL
 
-  $AUTOMAKE $am_warns -i
-  grep '%\.[co]' Makefile.in # For debugging.
-  test `grep -c '^%\.o: %\.c$' Makefile.in` -eq 1
-  test `grep -c '^%\.obj: %\.c$' Makefile.in` -eq 1
-
-  $AUTOMAKE $am_warns
-  grep '%\.[co]' Makefile.in # For debugging.
-  test `grep -c '^%\.o: %\.c$' Makefile.in` -eq 1
-  test `grep -c '^%\.obj: %\.c$' Makefile.in` -eq 1
+  for o in '' '-i'; do
+    $AUTOMAKE $am_warns $o
+    grep '%\.[co$]' Makefile.in # For debugging.
+    test $(grep -c '^%\.\$(OBJEXT): %\.c$' Makefile.in) -eq 1
+  done
 
 done
 
diff --git a/t/suffix2.sh b/t/suffix2.sh
index fb17ee3..bca8169 100755
--- a/t/suffix2.sh
+++ b/t/suffix2.sh
@@ -40,14 +40,11 @@ END
 
 $ACLOCAL
 
-$AUTOMAKE -a
-grep '%\.[co]' Makefile.in # For debugging.
-test `grep -c '^%\.o: %\.c$' Makefile.in` -eq 1
-test `grep -c '^%\.obj: %\.c$' Makefile.in` -eq 1
-
-$AUTOMAKE -i
-grep '%.[co]' Makefile.in # For debugging.
-test `grep -c '^%\.o: %\.c$' Makefile.in` -eq 1
-test `grep -c '^%\.obj: %\.c$' Makefile.in` -eq 1
+for o in -a -i; do
+  $AUTOMAKE $o
+  grep '%\.[lco$]' Makefile.in # For debugging.
+  test `grep -c '^%\.$(OBJEXT): %\.c$' Makefile.in` -eq 1
+  test `grep -c '^%\.lo: %\.c$' Makefile.in` -eq 1
+done
 
 :
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]