bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Akim Demaille <akim.demaille@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Gnulib bugs <bug-gnulib@gnu.org>
Subject: Re: maintainer-makefile: catch uses of $< in non-implicit rules
Date: Sat, 18 May 2019 11:51:19 +0200	[thread overview]
Message-ID: <D39FC8E2-4CD9-4D2D-85C9-6D4147C9AE08@gmail.com> (raw)
In-Reply-To: <f84ff046-9abf-d440-16bb-01268340552e@cs.ucla.edu>

Hi Paul!

> Le 18 mai 2019 à 09:52, Paul Eggert <eggert@cs.ucla.edu> a écrit :
> 
> Akim Demaille wrote:
>> +  };									\
> 
> Thanks, that looks good except I don't see why some of the lines like the above have semicolons while others don't.

You're right, more consistency wouldn't hurt.  Because everything ends in a single line, some of them are needed (separators of statements of compound statements), others aren't.

How about this?

commit 2e801e81bb362429d0e252d076233bfdac20e367
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Sat May 18 08:46:00 2019 +0200

    maintainer-makefile: catch uses of $< in non-implicit rules
    
    * top/maint.mk (sc_prohibit_magic_number_exit): New.

diff --git a/ChangeLog b/ChangeLog
index 1918041f0..8d5a4ca6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-18  Akim Demaille  <akim@lrde.epita.fr>
+
+	maintainer-makefile: catch uses of $< in non-implicit rules
+	* top/maint.mk (sc_prohibit_magic_number_exit): New.
+
 2019-05-14  Paul Eggert  <eggert@cs.ucla.edu>
 
 	close-stream, closein, closeout: simplify
diff --git a/top/maint.mk b/top/maint.mk
index e9d5ee7d4..3dbe9c378 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -408,6 +408,41 @@ sc_prohibit_magic_number_exit:
 	halt='use EXIT_* values rather than magic number'		\
 	  $(_sc_search_regexp)
 
+# Check that we don't use $< in non-implicit Makefile rules.
+#
+# To find the Makefiles, trace AC_CONFIG_FILES.  Using VC_LIST would
+# miss the Makefiles that are not under VC control (e.g., symlinks
+# installed for gettext).  "Parsing" (recursive) uses of SUBDIRS seems
+# too delicate.
+#
+# Use GNU Make's --print-data-base to normalize the rules into some
+# easy to parse format: they are separated by two \n.  Look for the
+# "section" about non-pattern rules (marked with "# Files") inside
+# which there are still the POSIX Make like implicit rules (".c.o").
+sc_prohibit_gnu_make_extensions_awk_ =					\
+  BEGIN {								\
+      RS = "\n\n";							\
+      in_rules = 0;							\
+  }									\
+  /^\# Files/ {								\
+      in_rules = 1;							\
+  }									\
+  /\$$</ && in_rules && $$0 !~ /^(.*\n)*\.\w+(\.\w+)?:/ {		\
+      print "Error: " file ": $$< in a non implicit rule\n" $$0;	\
+      status = 1;							\
+  }									\
+  END {									\
+     exit status;							\
+  }
+sc_prohibit_gnu_make_extensions:
+	(cd $(srcdir) && autoconf --trace AC_CONFIG_FILES:'$$1') |	\
+	  tr ' ' '\n' |							\
+	  $(SED) -ne '/Makefile/{s/\.in$$//;p;}' |			\
+	  while read m; do						\
+	    $(MAKE) -qp -f $$m .DUMMY-TARGET 2>/dev/null |		\
+	      awk -v file=$$m -e '$($@_awk_)' || exit 1;		\
+	  done
+
 # Using EXIT_SUCCESS as the first argument to error is misleading,
 # since when that parameter is 0, error does not exit.  Use '0' instead.
 sc_error_exit_success:



  reply	other threads:[~2019-05-18  9:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-18  7:44 maintainer-makefile: catch uses of $< in non-implicit rules Akim Demaille
2019-05-18  7:52 ` Paul Eggert
2019-05-18  9:51   ` Akim Demaille [this message]
2019-05-18 18:21     ` Paul Eggert
2019-05-19  5:42       ` Akim Demaille
2019-06-17  9:57         ` Tim Rühsen
2019-06-17  9:59           ` Akim Demaille
2019-06-17 10:04             ` Tim Rühsen
2019-06-22 15:53               ` Akim Demaille
2019-06-24  9:42                 ` Tim Rühsen
2019-06-24 15:56                   ` Akim Demaille
2019-06-25 13:12                     ` Tim Rühsen
2019-06-25 13:24                     ` Tim Rühsen
2019-06-25 14:37                       ` Bruno Haible
2019-06-25 14:39                         ` Tim Rühsen
2019-06-25 14:46                         ` Tim Rühsen
2019-07-10  9:07                       ` Tim Rühsen
2019-07-10  9:38                         ` Tim Rühsen
2019-07-10 10:21                           ` Tim Rühsen
2019-07-10 19:32                             ` Akim Demaille
2019-07-11  8:00                               ` Tim Rühsen
2019-07-11  8:46                               ` Tim Rühsen
2019-07-19  7:40                                 ` Bernhard Voelker
2019-07-19  7:30     ` Bernhard Voelker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D39FC8E2-4CD9-4D2D-85C9-6D4147C9AE08@gmail.com \
    --to=akim.demaille@gmail.com \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).