]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] depcomp: unify rules for '.o' and '.obj' objects
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 7 Jun 2012 00:26:17 +0000 (02:26 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 8 Jun 2012 10:40:23 +0000 (12:40 +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 <stefano.lattarini@gmail.com>
19 files changed:
automake.in
lib/am/depend2.am
t/empty2.sh
t/empty3.sh
t/ext.sh
t/ext2.sh
t/libtool3.sh
t/objc-basic.sh
t/objcxx-basic.sh
t/pr87.sh
t/silent-many-gcc.sh
t/silent-many-generic.sh
t/specflg.sh
t/specflg2.sh
t/specflg6.sh
t/subdir3.sh
t/subobj4.sh
t/suffix.sh
t/suffix2.sh

index 176e882944852015019b91371097c7c681c822b9..e7034e00f8a98b8985c30c470e1f1e2623fe54fd 100644 (file)
@@ -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,
index b57f19aaec4e3c7cf4150cdf8d902025c691dabc..81d2c4c269c8c97463f8d43add63667a5b9814ca 100644 (file)
@@ -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%
 
index 7d124230106e527559523c5feff7380ee560b9c1..224c26dc19f63e4194607e9ab2a3d52227eb5321 100755 (executable)
@@ -31,5 +31,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep 'pavel\.[co]' Makefile.in && Exit 1
-Exit 0
+grep 'pavel\.' Makefile.in && Exit 1
+
+:
index 6aabfbaa9a4ded7621b2bb43e10ae953cdc89257..4721db562eb2026f7da137c4a34f256327b49fdd 100755 (executable)
@@ -29,4 +29,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep 'pavel\.[co]' Makefile.in
+$FGREP ' pavel.c' Makefile.in
+
+:
index 02ceab5982b8bb422acf31e891333a231eb76aa5..72ff211e88219fb87f0ac82f3738a01bdcc0e16b 100755 (executable)
--- 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
 
 :
index ac5b7772e402b3cddfd3f8c629c6fcc55a1df448..a1145807c9574c8abc1a231812b7ec07c54658e8 100755 (executable)
--- 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
index dbcd519d99bb23660efad1b350484b673c8de683..2f18b150d54ce5c3b47267862aeaeeb995dee5d0 100755 (executable)
@@ -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
index f3234d7cc68e69a2de478b1c3db1531a909d672b..464887bc5cfd6641ff698f083f4475711f5324c6 100755 (executable)
@@ -35,6 +35,6 @@ $ACLOCAL
 $AUTOMAKE
 $FGREP '$(OBJC)' Makefile.in
 $FGREP '$(OBJCLD)' Makefile.in
-grep '^%\.o: %\.m$' Makefile.in
+grep '^%\.$(OBJEXT): %\.m$' Makefile.in
 
 :
index 29aa9829bc0ed577541d3286dd1052551ffb60b8..1c807dccd4a693f5c19b8183ca8e2ebef4b7c525 100755 (executable)
@@ -37,6 +37,6 @@ $ACLOCAL
 $AUTOMAKE
 $FGREP '$(OBJCXX)' Makefile.in
 $FGREP '$(OBJCXXLD)' Makefile.in
-grep '^%\.o: %\.mm$' Makefile.in
+grep '^%\.$(OBJEXT): %\.mm$' Makefile.in
 
 :
index 121328d6332460ef4d4b673ac4c1134975ff94a1..c6cb90abc637bb8513fa4897761ab7706acb3dc1 100755 (executable)
--- 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
index 8ad07205acb6ee2c61ee1bb27002c6926274e3ff..46d4e45710b84c0e577e3dde214b7ff0521b4431 100755 (executable)
@@ -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
 
index cd376721aa7e497e4862930150aa377ae350dbba..4e6c6f928643a8a67f7b8bb84afb6844d7a203ec 100755 (executable)
@@ -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
 
index 9d5c73ca07f38eaa498fbda947c3b2455592d14d..6cb6b363c995616c439b462a78388d68f890fe65 100755 (executable)
@@ -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
+:
index 9f9569c8d33d4fdc2e4dbb2b5fc05a56c095dce7..aff03b8c8018b40404cc5b83b41b1b52a4baaaeb 100755 (executable)
@@ -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
+:
index f420cdfd252d87832cf1dea83c5a7063dbe13471..cc585e9ddb898b1de0558c8e0213d65a75456f10 100755 (executable)
@@ -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"
 
index d9b160fa8374e5f9715ce2cd6bd2181db0937e6f..984fe43b6781f675a9f95d02d50aa31afe222e59 100755 (executable)
@@ -31,6 +31,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '^z\.o: x/z\.c$' Makefile.in
+grep '^z\.\$(OBJEXT): x/z\.c$' Makefile.in
 
 :
index 6aeb19df6b8c3873446ab639715420bcbc4a8622..fda35ebebbeb61bb960d6b66dc6c7dbdc2edacd5 100755 (executable)
@@ -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
 
 :
index 0d72782c7db83b49d8fb57db8ce74670f7454ecb..c60f734f4e72dd430554403bf71e0e685802573e 100755 (executable)
@@ -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
 
index fb17ee393ed3f53d61be3004012bda282dcbc615..bca816988797c2aa9d43871446de29a7c8a41135 100755 (executable)
@@ -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
 
 :