]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] am: prefer pattern rules over old-fashioned suffix rules
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 9 May 2012 12:04:31 +0000 (14:04 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 10 May 2012 11:17:51 +0000 (13:17 +0200)
The use of pattern rules is cleaner, safer, and vouched for in the
GNU make manual itself.  Moreover, it will allow us to obtain some
simplifications in the automake script and the documentation in
future changes.

* lib/am/texinfos.am: Turn this suffix rules into pattern rules.
* lib/am/texibuild.am: Likewise.
* lib/am/depend2.am: Likewise.
* lib/am/yacc.am: Likewise.
* lib/am/lex.am: Likewise.
* lib/am/lang-compile.am: Likewise.  Also, since we are at it, remove
extra blank lines and quote 'like this' rather than `like this'.
* t/ext.sh: Adjust.
* t/objc-basic.sh: Likewise.
* t/objcxx-basic.sh: Likewise.
* t/txinfo6.sh: Likewise.
* t/suffix.sh: Likewise.
* t/suffix2.sh: Likewise.  Also, define a dummy LIBTOOL in Makefile.am
instead of requiring the libtool macros.
* t/cxx.sh: Remove as obsolete.
* t/nodep.sh: Likewise.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
14 files changed:
lib/am/depend2.am
lib/am/lang-compile.am
lib/am/lex.am
lib/am/texibuild.am
lib/am/texinfos.am
lib/am/yacc.am
t/cxx.sh [deleted file]
t/ext.sh
t/nodep.sh [deleted file]
t/objc-basic.sh
t/objcxx-basic.sh
t/suffix.sh
t/suffix2.sh
t/txinfo6.sh

index 9adae8fa3205168e7b9fb8d46007aa56cc315814..81660c18ecc79f87cfc360b1fef2ec0e5c8fd845 100644 (file)
@@ -42,7 +42,7 @@ am__ensure_depdir = test -d $(am__depdir) || $(MKDIR_P) $(am__depdir)
 endif %?FIRST%
 
 if %?NONLIBTOOL%
-?GENERIC?%EXT%.o:
+?GENERIC?%.o: %%EXT%
 ?!GENERIC?%OBJ%: %SOURCE%
 if %FASTDEP%
        %SILENT%$(am__ensure_depdir)
@@ -60,7 +60,7 @@ endif %AMDEP%
 ?!-o?  %VERBOSE-NODEP%%COMPILE% %-c% %SOURCEFLAG%$<
 endif !%FASTDEP%
 
-?GENERIC?%EXT%.obj:
+?GENERIC?%.obj: %%EXT%
 ?!GENERIC?%OBJOBJ%: %SOURCE%
 if %FASTDEP%
        %SILENT%$(am__ensure_depdir)
@@ -80,7 +80,7 @@ endif !%FASTDEP%
 endif %?NONLIBTOOL%
 
 if %?LIBTOOL%
-?GENERIC?%EXT%.lo:
+?GENERIC?%.lo: %%EXT%
 ?!GENERIC?%LTOBJ%: %SOURCE%
 if %FASTDEP%
        %SILENT%$(am__ensure_depdir)
index 04cafb357c7c8a9b35cbab337f03a0e73340ed1c..b974197afad54c784851b2ab7fd1f46134605c81 100644 (file)
 
 ## We also handle the case of preprocessing '.F' files into '.f' files.
 if %?PPF77%
-.F.f:
+%.f: %.F
        $(F77COMPILE) -F $<
 endif %?PPF77%
 
-
-
 ## -------- ##
 ## Ratfor.  ##
 ## -------- ##
 
-## We also handle the case of preprocessing `.r' files into `.f' files.
+## We also handle the case of preprocessing '.r' files into '.f' files.
 if %?RATFOR%
-.r.f:
+%.f: %.r
        $(RCOMPILE) -F $<
 endif %?RATFOR%
index e257d3147f131a5b4c474c346d7a9fbdf2b8b0f2..bc553f4c3c1b2fe30d53b3a84289f2aa5e3073fa 100644 (file)
@@ -21,7 +21,7 @@ if %?FIRST%
 endif %?FIRST%
 endif %?MAINTAINER-MODE%
 
-?GENERIC?%EXT%%DERIVED-EXT%:
+?GENERIC?%%DERIVED-EXT%: %%EXT%
 ?!GENERIC?%OBJ%: %SOURCE%
 ?SUBDIROBJ?    %SILENT%test -d $(dir $@) || $(MKDIR_P) $(dir $@)
 ?GENERIC?      %VERBOSE%$(am__skipyacc) \
index a49022e3fffffd5a05945c790ededd649d8bf128..73abd1f0fdec060e162b75bdc902656ee89cef9d 100644 (file)
@@ -15,7 +15,7 @@
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-?GENERIC_INFO?%SOURCE_SUFFIX%%DEST_SUFFIX%:
+?GENERIC_INFO?%%DEST_SUFFIX%: %%SOURCE_SUFFIX%
 ?!GENERIC_INFO?%DEST_INFO_PREFIX%%DEST_SUFFIX%: %SOURCE_INFO% %DEPS%
 ## It is wrong to have 'info' files dependent on %DIRSTAMP%, because
 ## 'info' files are distributed and %DIRSTAMP% isn't: a distributed file
@@ -59,7 +59,7 @@
 
 INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
 
-?GENERIC?%SOURCE_SUFFIX%.dvi:
+?GENERIC?%.dvi: %%SOURCE_SUFFIX%
 ?!GENERIC?%DEST_PREFIX%.dvi: %SOURCE% %DEPS% %DIRSTAMP%
        %AM_V_TEXI2DVI%TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
 ## Must set MAKEINFO like this so that version.texi will be found even
@@ -74,7 +74,7 @@ INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
 ?GENERIC?      $(TEXI2DVI) %TEXIQUIET% --clean %SOURCE% %TEXIDEVNULL%
 ?!GENERIC?     $(TEXI2DVI) %TEXIQUIET% --clean -o $@ `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% %TEXIDEVNULL%
 
-?GENERIC?%SOURCE_SUFFIX%.pdf:
+?GENERIC?%.pdf: %%SOURCE_SUFFIX%
 ?!GENERIC?%DEST_PREFIX%.pdf: %SOURCE% %DEPS% %DIRSTAMP%
        %AM_V_TEXI2PDF%TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
 ## Must set MAKEINFO like this so that version.texi will be found even
@@ -89,7 +89,7 @@ INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
 ?GENERIC?      $(TEXI2PDF) %TEXIQUIET% --clean %SOURCE% %TEXIDEVNULL%
 ?!GENERIC?     $(TEXI2PDF) %TEXIQUIET% --clean -o $@ `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% %TEXIDEVNULL%
 
-?GENERIC?%SOURCE_SUFFIX%.html:
+?GENERIC?%.html: %%SOURCE_SUFFIX%
 ?!GENERIC?%DEST_PREFIX%.html: %SOURCE% %DEPS% %DIRSTAMP%
 ## When --split (the default) is used, makeinfo will output a
 ## directory.  However it will not update the time stamp of a
index e78cdede601551e6a6532d95240cfe2b926d969d..fa1b64227b3e6a7f78dda6cdd7938459174ebb12 100644 (file)
@@ -34,7 +34,7 @@ endif %?LOCAL-TEXIS%
 ## The way to make PostScript, for those who want it.
 if %?LOCAL-TEXIS%
 DVIPS = dvips
-.dvi.ps:
+%.ps: %.dvi
        %AM_V_DVIPS%TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
        $(DVIPS) %TEXIQUIET% -o $@ $<
 endif %?LOCAL-TEXIS%
index 04cdc99a348a27262f391a71955afdd56d9e4e6c..4815087c63838f6edbdb7016ef15bc63f606e6ae 100644 (file)
@@ -41,7 +41,7 @@ am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \
                   -e s/c++$$/h++/ -e s/c$$/h/
 endif %?FIRST%
 
-?GENERIC?%EXT%%DERIVED-EXT%:
+?GENERIC?%%DERIVED-EXT%: %%EXT%
 ?!GENERIC?%OBJ%: %SOURCE%
 ?SUBDIROBJ?    %SILENT%test -d $(dir $@) || $(MKDIR_P) $(dir $@)
        %VERBOSE% \
diff --git a/t/cxx.sh b/t/cxx.sh
deleted file mode 100755 (executable)
index 63e55b8..0000000
--- a/t/cxx.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test that '.c++' extension works.
-# From Ralf Corsepius.
-
-. ./defs || Exit 1
-
-cat >> configure.ac << 'END'
-AC_PROG_CXX
-END
-
-cat > Makefile.am << 'END'
-bin_PROGRAMS = hello
-hello_SOURCES = hello.c++
-END
-
-$ACLOCAL
-$AUTOMAKE
-
-grep '^\.SUFFIXES:.*c[+][+]' Makefile.in
index 08643ac26eb4be3307c8dd1678bd92edb4e8afed..02ceab5982b8bb422acf31e891333a231eb76aa5 100755 (executable)
--- a/t/ext.sh
+++ b/t/ext.sh
@@ -34,13 +34,11 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-for ext in f for f90 f95 F F90 F95 r m mm upc
-do
-   # Some versions of the BSD shell wrongly exit when 'set -e' is active
-   # if the last command within a compound statement fails and is guarded
-   # by an && only.  So we play safe and use the following idiom, instead
-   # of the apparently simpler 'grep ... && Exit 1'.
-   if grep "^$ext\.o:" Makefile.in; then Exit 1; else :; fi
-   grep "^\.$ext\.o:" Makefile.in
+$FGREP '%.o' 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
 done
-Exit 0
+
+:
diff --git a/t/nodep.sh b/t/nodep.sh
deleted file mode 100755 (executable)
index 1002c54..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure no-dependencies option does the right thing.
-# Bug report from Greg A. Woods.
-
-. ./defs || Exit 1
-
-cat > Makefile.am << 'END'
-AUTOMAKE_OPTIONS = no-dependencies
-bin_PROGRAMS = zardoz
-zardoz_SOURCES = y.c
-END
-
-cat >> configure.ac << 'END'
-AC_PROG_CC
-END
-
-mkdir x
-
-: > y.c
-
-$ACLOCAL
-$AUTOMAKE
-
-$FGREP -v '$(filter --%,' Makefile.in | grep '%' && Exit 1
-Exit 0
index f608fbc83ca78661d6b82301dd625ec2fd3318f9..f3234d7cc68e69a2de478b1c3db1531a909d672b 100755 (executable)
@@ -33,6 +33,8 @@ echo AC_PROG_OBJC >> configure.ac
 
 $ACLOCAL
 $AUTOMAKE
-$EGREP '^\.SUFFIXES:.* \.m( |$)' Makefile.in
+$FGREP '$(OBJC)' Makefile.in
+$FGREP '$(OBJCLD)' Makefile.in
+grep '^%\.o: %\.m$' Makefile.in
 
 :
index 3835ab47c215190f155b638ffdeef204899f6296..29aa9829bc0ed577541d3286dd1052551ffb60b8 100755 (executable)
@@ -35,6 +35,8 @@ END
 
 $ACLOCAL
 $AUTOMAKE
-$EGREP '^\.SUFFIXES:.* \.mm( |$)' Makefile.in
+$FGREP '$(OBJCXX)' Makefile.in
+$FGREP '$(OBJCXXLD)' Makefile.in
+grep '^%\.o: %\.mm$' Makefile.in
 
 :
index 600aedf1e273157db84e7b8380f7f568573a76d5..0d72782c7db83b49d8fb57db8ce74670f7454ecb 100755 (executable)
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure proper suffix rules for C compilation are produced, and
+# Make sure proper pattern rules for C compilation are produced, and
 # only once.
 # See also related test 'suffix2.test'.
 
@@ -45,14 +45,14 @@ for use_arlib in false :; do
   $ACLOCAL
 
   $AUTOMAKE $am_warns -i
-  grep '^ *\.c' Makefile.in # For debugging.
-  test `grep -c '^\.c\.o:' Makefile.in` -eq 1
-  test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+  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 '^ *\.c' Makefile.in # For debugging.
-  test `grep -c '^\.c\.o:' Makefile.in` -eq 1
-  test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+  grep '%\.[co]' Makefile.in # For debugging.
+  test `grep -c '^%\.o: %\.c$' Makefile.in` -eq 1
+  test `grep -c '^%\.obj: %\.c$' Makefile.in` -eq 1
 
 done
 
index 6dd26164da242ab87ebd82327c54ed963ced682f..fb17ee393ed3f53d61be3004012bda282dcbc615 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure proper suffix rules for C compilation are produced,
+# Make sure proper pattern rules for C compilation are produced,
 # and only once, even for libtool libraries.
 # See also related test 'suffix.test'.
-required=libtoolize
 
 . ./defs || Exit 1
 
 cat >> configure.ac << 'END'
 AC_PROG_CC
 AM_PROG_AR
-AC_PROG_LIBTOOL
 END
 
 cat > Makefile.am << 'END'
+LIBTOOL = who cares
 lib_LTLIBRARIES = libltdl.la
 libltdl_la_SOURCES = ltdl.c ltdl.h
 END
@@ -42,13 +41,13 @@ END
 $ACLOCAL
 
 $AUTOMAKE -a
-grep '^ *\.c' Makefile.in # For debugging.
-test `grep -c '^\.c\.o:' Makefile.in` -eq 1
-test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+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 '^ *\.c' Makefile.in # For debugging.
-test `grep -c '^\.c\.o:' Makefile.in` -eq 1
-test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+grep '%.[co]' Makefile.in # For debugging.
+test `grep -c '^%\.o: %\.c$' Makefile.in` -eq 1
+test `grep -c '^%\.obj: %\.c$' Makefile.in` -eq 1
 
 :
index b289efee4060844f6f832b91f44f9b84d1dda62f..b13c51f869d999c532d1b2b69b63ff06e7006e6a 100755 (executable)
@@ -28,6 +28,6 @@ echo '@setfilename foo.info' > foo.txi
 $ACLOCAL
 $AUTOMAKE
 
-grep '^\.txi\.info: *$' Makefile.in
+grep '^%\.info: %\.txi$' Makefile.in
 
 :