[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint.mk: generalize/improve the tight-scope rule
From: |
Jim Meyering |
Subject: |
Re: [PATCH] maint.mk: generalize/improve the tight-scope rule |
Date: |
Mon, 23 May 2011 17:31:34 +0200 |
Jim Meyering wrote:
> FYI,
> Changes, in case anyone else is using this:
> - XTERN is no longer supported, by default.
> See the comments for how to customize it if you rely on this.
> - you now get a diagnostic when the tight-scope syntax-check test is skipped
> Subject: [PATCH] maint.mk: generalize/improve the tight-scope rule
>
> * top/maint.mk: Emit a warning when the test is skipped.
> (_gl_TS_dir): Add $(srcdir)/ prefix.
> (_gl_TS_function_match): Simplify, rather than trying
> to enumerate common types. Otherwise, it would fail to match an
> "extern unsigned char const *" declaration in idutils.
> (_gl_TS_extern): Do not endorse use of "XTERN", but do provide
> a way to support use of that type of macro.
First, that was incomplete. There were two more
places in which _gl_TS_extern should be used.
Now that I've begun using the new rule via diffutils,
I've found that further changes are required.
At first, I thought to use something like this:
# GNU Makefile snippet to see if _gl_TS_headers retains its default
# in the sub-make that we'll run in the else block.
_gl_TS_mk_test = \
ifneq ($$(_gl_TS_headers),$$(noinst_HEADERS))\n$$(error x)\nelse\nR:\nendif\n
ALL_RECURSIVE_TARGETS += sc_tight_scope
sc_tight_scope: tight-scope.mk
@if printf '$(_gl_TS_mk_test)' \
| $(MAKE) -s -f $< -f cfg.mk -f - R \
&& ! grep -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
> /dev/null 2>&1; then \
echo '$(ME): skipping $@'; \
else \
$(MAKE) -s -C $(_gl_TS_dir) \
-f Makefile \
-f $(abs_top_srcdir)/cfg.mk \
-f $(abs_top_builddir)/$< \
_gl_tight_scope \
|| fail=1; \
fi
@rm -f $<
But that first test was too complicated, requiring
that cfg.mk be modified to accommodate the fact that
srcdir is not defined, yet used like this:
include $(srcdir)/dist-check.mk
The solution is the patch below,
and to change the include to be "-"-prefixed:
-include $(srcdir)/dist-check.mk
so that in the submake (usually from src/),
the lack of dist-check.mk doesn't cause failure
or even a diagnostic.
>From 483bd08221cccf613ae5bb5738076113150579b0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 23 May 2011 17:15:30 +0200
Subject: [PATCH] maint.mk: more tight_scope improvements
* top/maint.mk: (_gl_TS_var_match): Use $(_gl_TS_extern) here, too.
(_gl_TS_headers): Define only in if-0'd block.
(_gl_TS_dir): Omit the $(srcdir)/ prefix. Sometimes we need it,
sometimes we must *not* use it. Adjust uses accordingly.
(sc_tight_scope): Use much simpler grep-based test to determine
whether we skip this rule.
---
ChangeLog | 8 ++++++++
top/maint.mk | 32 ++++++++++++++++++--------------
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f206cd4..3208380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-05-23 Jim Meyering <address@hidden>
+ maint.mk: more tight_scope improvements
+ * top/maint.mk: (_gl_TS_var_match): Use $(_gl_TS_extern) here, too.
+ (_gl_TS_headers): Define only in if-0'd block.
+ (_gl_TS_dir): Omit the $(srcdir)/ prefix. Sometimes we need it,
+ sometimes we must *not* use it. Adjust uses accordingly.
+ (sc_tight_scope): Use much simpler grep-based test to determine
+ whether we skip this rule.
+
maint.mk: generalize/improve the tight-scope rule
* top/maint.mk: Emit a warning when the test is skipped.
(_gl_TS_dir): Add $(srcdir)/ prefix.
diff --git a/top/maint.mk b/top/maint.mk
index 58e8004..9f20900 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -1353,27 +1353,27 @@ update-copyright:
$$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \
| $(update-copyright-env) xargs $(build_aux)/$@
-# NOTE: This test is skipped with a warning if $(_gl_TS_headers) still
-# has its default value and $(_gl_TS_dir)/Makefile.am does not mention
-# noinst_HEADERS.
+# This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
+# overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
# NOTE: to override any _gl_TS_* default value, you must
# define the variable(s) using "export" in cfg.mk.
-_gl_TS_dir ?= $(srcdir)/src
-
-# The file(s) to search for extern declarations.
-_gl_TS_headers ?= $(noinst_HEADERS)
+_gl_TS_dir ?= src
ALL_RECURSIVE_TARGETS += sc_tight_scope
sc_tight_scope: tight-scope.mk
- @if test 'x$(_gl_TS_headers)' = 'x$(noinst_HEADERS)' \
- && ! grep -w noinst_HEADERS $(_gl_TS_dir)/Makefile.am \
+ @if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \
+ > /dev/null \
+ && ! grep -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
> /dev/null 2>&1; then \
echo '$(ME): skipping $@'; \
else \
- $(MAKE) -s -C $(_gl_TS_dir) -f $(abs_builddir)/$< \
- -f Makefile _gl_tight_scope \
- || fail=1; \
+ $(MAKE) -s -C $(_gl_TS_dir) \
+ -f Makefile \
+ -f $(abs_top_srcdir)/cfg.mk \
+ -f $(abs_top_builddir)/$< \
+ _gl_tight_scope \
+ || fail=1; \
fi
@rm -f $<
@@ -1411,12 +1411,16 @@ _gl_TS_unmarked_extern_vars ?=
# a macro like this: GLOBAL(type, var_name, initializer), then you
# can override this definition to automatically extract those names:
# export _gl_TS_var_match = \
-# /^(?:extern|XTERN) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
-_gl_TS_var_match ?= /^(?:extern|XTERN) .*?(\w+)(\[.*?\])?;/
+# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
+_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/
# The names of object files in (or relative to) $(_gl_TS_dir).
_gl_TS_obj_files ?= *.$(OBJEXT)
+# Files in which to search for the one-line style extern declarations.
+# $(_gl_TS_dir)-relative.
+_gl_TS_headers ?= $(noinst_HEADERS)
+
.PHONY: _gl_tight_scope
_gl_tight_scope: $(bin_PROGRAMS)
t=exceptions-$$$$; \
--
1.7.5.2.1.g56b30