automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [PATCH 1/4] [ng] am: prefer pattern rules over old-fashion


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH 1/4] [ng] am: prefer pattern rules over old-fashioned suffix rules
Date: Thu, 10 May 2012 14:29:47 +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 <address@hidden>
---
 lib/am/depend2.am      |    6 +++---
 lib/am/lang-compile.am |    8 +++-----
 lib/am/lex.am          |    2 +-
 lib/am/texibuild.am    |    8 ++++----
 lib/am/texinfos.am     |    2 +-
 lib/am/yacc.am         |    2 +-
 t/cxx.sh               |   34 ----------------------------------
 t/ext.sh               |   16 +++++++---------
 t/nodep.sh             |   40 ----------------------------------------
 t/objc-basic.sh        |    4 +++-
 t/objcxx-basic.sh      |    4 +++-
 t/suffix.sh            |   14 +++++++-------
 t/suffix2.sh           |   17 ++++++++---------
 t/txinfo6.sh           |    2 +-
 14 files changed, 42 insertions(+), 117 deletions(-)
 delete mode 100755 t/cxx.sh
 delete mode 100755 t/nodep.sh

diff --git a/lib/am/depend2.am b/lib/am/depend2.am
index 9adae8f..81660c1 100644
--- a/lib/am/depend2.am
+++ b/lib/am/depend2.am
@@ -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)
diff --git a/lib/am/lang-compile.am b/lib/am/lang-compile.am
index 04cafb3..b974197 100644
--- a/lib/am/lang-compile.am
+++ b/lib/am/lang-compile.am
@@ -22,18 +22,16 @@
 
 ## 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%
diff --git a/lib/am/lex.am b/lib/am/lex.am
index e257d31..bc553f4 100644
--- a/lib/am/lex.am
+++ b/lib/am/lex.am
@@ -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) \
diff --git a/lib/am/texibuild.am b/lib/am/texibuild.am
index a49022e..73abd1f 100644
--- a/lib/am/texibuild.am
+++ b/lib/am/texibuild.am
@@ -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
diff --git a/lib/am/texinfos.am b/lib/am/texinfos.am
index e78cded..fa1b642 100644
--- a/lib/am/texinfos.am
+++ b/lib/am/texinfos.am
@@ -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%
diff --git a/lib/am/yacc.am b/lib/am/yacc.am
index 04cdc99..4815087 100644
--- a/lib/am/yacc.am
+++ b/lib/am/yacc.am
@@ -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
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
diff --git a/t/ext.sh b/t/ext.sh
index 08643ac..02ceab5 100755
--- 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
index 1002c54..0000000
--- a/t/nodep.sh
+++ /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
diff --git a/t/objc-basic.sh b/t/objc-basic.sh
index f608fbc..f3234d7 100755
--- a/t/objc-basic.sh
+++ b/t/objc-basic.sh
@@ -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
 
 :
diff --git a/t/objcxx-basic.sh b/t/objcxx-basic.sh
index 3835ab4..29aa982 100755
--- a/t/objcxx-basic.sh
+++ b/t/objcxx-basic.sh
@@ -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
 
 :
diff --git a/t/suffix.sh b/t/suffix.sh
index 600aedf..0d72782 100755
--- a/t/suffix.sh
+++ b/t/suffix.sh
@@ -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
 
diff --git a/t/suffix2.sh b/t/suffix2.sh
index 6dd2616..fb17ee3 100755
--- a/t/suffix2.sh
+++ b/t/suffix2.sh
@@ -14,20 +14,19 @@
 # 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
 
 :
diff --git a/t/txinfo6.sh b/t/txinfo6.sh
index b289efe..b13c51f 100755
--- a/t/txinfo6.sh
+++ b/t/txinfo6.sh
@@ -28,6 +28,6 @@ echo '@setfilename foo.info' > foo.txi
 $ACLOCAL
 $AUTOMAKE
 
-grep '^\.txi\.info: *$' Makefile.in
+grep '^%\.info: %\.txi$' Makefile.in
 
 :
-- 
1.7.9.5




reply via email to

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