From e30f842b24caf0027cedb4d84ee337d43817ab0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 8 Jan 2021 16:52:29 +0000 Subject: [PATCH] build: remove all logic unrelated to syntax-check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The standard maint.mk from gnulib provides alot more than just the 'syntax-check' target. This can all be purged to give a more minimal file. Signed-off-by: Daniel P. Berrangé --- GNUmakefile | 42 ---- build-aux/cfg.mk | 3 - build-aux/maint.mk | 516 --------------------------------------------- 3 files changed, 561 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 27a9f45..69ed348 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -50,48 +50,6 @@ include Makefile include $(srcdir)/$(_build-aux)/cfg.mk include $(srcdir)/$(_build-aux)/maint.mk -# Ensure that $(VERSION) is up to date for dist-related targets, but not -# for others: rerunning autoreconf and recompiling everything isn't cheap. -_have-git-version-gen := \ - $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes) -ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL)) - _is-dist-target ?= $(filter-out %clean, \ - $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS))) - _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS))) - ifneq (,$(_is-dist-target)$(_is-install-target)) - _curr-ver := $(shell cd $(srcdir) \ - && $(_build-aux)/git-version-gen \ - .tarball-version \ - $(git-version-gen-tag-sed-script)) - ifneq ($(_curr-ver),$(VERSION)) - ifeq ($(_curr-ver),UNKNOWN) - $(info WARNING: unable to verify if $(VERSION) is the correct version) - else - ifneq (,$(_is-install-target)) - # GNU Coding Standards state that 'make install' should not cause - # recompilation after 'make all'. But as long as changing the version - # string alters config.h, the cost of having 'make all' always have an - # up-to-date version is prohibitive. So, as a compromise, we merely - # warn when installing a version string that is out of date; the user - # should run 'autoreconf' (or something like 'make distcheck') to - # fix the version, 'make all' to propagate it, then 'make install'. - $(info WARNING: version string $(VERSION) is out of date;) - $(info run '$(MAKE) _version' to fix it) - else - $(info INFO: running autoreconf for new version string: $(_curr-ver)) -GNUmakefile: _version - touch GNUmakefile - endif - endif - endif - endif -endif - -.PHONY: _version -_version: - cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf) - $(MAKE) $(AM_MAKEFLAGS) Makefile - else .DEFAULT_GOAL := abort-due-to-no-makefile diff --git a/build-aux/cfg.mk b/build-aux/cfg.mk index 41553fc..cb46e31 100644 --- a/build-aux/cfg.mk +++ b/build-aux/cfg.mk @@ -107,9 +107,6 @@ sc_copyright_format: halt='spell Red Hat as two words' \ $(_sc_search_regexp) -# We don't use this feature of maint.mk. -prev_version_file = /dev/null - exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch] exclude_file_name_regexp--sc_prohibit_strcmp = ^*/*.[ch] diff --git a/build-aux/maint.mk b/build-aux/maint.mk index 30de25a..ef3fb4f 100644 --- a/build-aux/maint.mk +++ b/build-aux/maint.mk @@ -21,20 +21,6 @@ # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) ME := $(_build-aux)/maint.mk -# Diagnostic for continued use of deprecated variable. -# Remove in 2013 -ifneq ($(build_aux),) - $(error "$(ME): \ -set $$(_build-aux) relative to $$(srcdir) instead of $$(build_aux)") -endif - -# Do not save the original name or timestamp in the .tar.gz file. -# Use --rsyncable if available. -gzip_rsyncable := \ - $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null \ - && printf %s --rsyncable) -GZIP_ENV = '--no-name --best $(gzip_rsyncable)' - GIT = git VC = $(GIT) @@ -69,53 +55,8 @@ VC_LIST_EXCEPT = \ | grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \ $(_prepend_srcdir_prefix) -ifeq ($(origin prev_version_file), undefined) - prev_version_file = $(srcdir)/.prev-version -endif - -PREV_VERSION := $(shell cat $(prev_version_file) 2>/dev/null) -VERSION_REGEXP = $(subst .,\.,$(VERSION)) -PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION)) - -ifeq ($(VC),$(GIT)) -this-vc-tag = v$(VERSION) -this-vc-tag-regexp = v$(VERSION_REGEXP) -else -tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]') -tag-this-version = $(subst .,_,$(VERSION)) -this-vc-tag = $(tag-package)-$(tag-this-version) -this-vc-tag-regexp = $(this-vc-tag) -endif my_distdir = $(PACKAGE)-$(VERSION) -# Old releases are stored here. -release_archive_dir ?= ../release - -# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right. -# Use alpha.gnu.org for alpha and beta releases. -# Use ftp.gnu.org for stable releases. -gnu_ftp_host-alpha = alpha.gnu.org -gnu_ftp_host-beta = alpha.gnu.org -gnu_ftp_host-stable = ftp.gnu.org -gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE)) - -ifeq ($(gnu_rel_host),ftp.gnu.org) -url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE) -else -url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE) -endif - -# Override this in cfg.mk if you are using a different format in your -# NEWS file. -today = $(shell date +%Y-%m-%d) - -# Select which lines of NEWS are searched for $(news-check-regexp). -# This is a sed line number spec. The default says that we search -# lines 1..10 of NEWS for $(news-check-regexp). -# If you want to search only line 3 or only lines 20-22, use "3" or "20,22". -news-check-lines-spec ?= 1,10 -news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)' - # Prevent programs like 'sort' from considering distinct strings to be equal. # Doing it here saves us from having to set LC_ALL elsewhere in this file. export LC_ALL = C @@ -731,72 +672,6 @@ sc_useless_cpp_parens: halt='found useless parentheses in cpp directive' \ $(_sc_search_regexp) -# List headers for which HAVE_HEADER_H is always true, assuming you are -# using the appropriate gnulib module. CAUTION: for each "unnecessary" -# #if HAVE_HEADER_H that you remove, be sure that your project explicitly -# requires the gnulib module that guarantees the usability of that header. -gl_assured_headers_ = \ - cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g' - -# Convert the list of names to upper case, and replace each space with "|". -az_ = abcdefghijklmnopqrstuvwxyz -AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ -gl_header_upper_case_or_ = \ - $$($(gl_assured_headers_) \ - | tr $(az_)/.- $(AZ_)___ \ - | tr -s ' ' '|' \ - ) -sc_prohibit_always_true_header_tests: - @or=$(gl_header_upper_case_or_); \ - re="HAVE_($$or)_H"; \ - prohibit='\<'"$$re"'\>' \ - halt=$$(printf '%s\n' \ - 'do not test the above HAVE_
_H symbol(s);' \ - ' with the corresponding gnulib module, they are always true') \ - $(_sc_search_regexp) - -# ================================================================== -gl_other_headers_ ?= \ - intprops.h \ - openat.h \ - stat-macros.h - -# Perl -lne code to extract "significant" cpp-defined symbols from a -# gnulib header file, eliminating a few common false-positives. -# The exempted names below are defined only conditionally in gnulib, -# and hence sometimes must/may be defined in application code. -gl_extract_significant_defines_ = \ - /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\ - && $$2 !~ /(?:rpl_|_used_without_)/\ - && $$1 !~ /^(?:NSIG|ENODATA)$$/\ - && $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\ - and print $$1 - -# Create a list of regular expressions matching the names -# of macros that are guaranteed to be defined by parts of gnulib. -define def_sym_regex - gen_h=$(gl_generated_headers_); \ - (cd $(gnulib_dir)/lib; \ - for f in *.in.h $(gl_other_headers_); do \ - test -f $$f \ - && perl -lne '$(gl_extract_significant_defines_)' $$f; \ - done; \ - ) | sort -u \ - | sed 's/^/^ *# *(define|undef) */;s/$$/\\>/' -endef - -# Don't define macros that we already get from gnulib header files. -sc_prohibit_always-defined_macros: - @if test -d $(gnulib_dir); then \ - case $$(echo all: | grep -l -f - Makefile) in Makefile);; *) \ - echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \ - esac; \ - $(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT)) \ - && { echo '$(ME): define the above via some gnulib .h file' \ - 1>&2; exit 1; } || :; \ - fi -# ================================================================== - # Prohibit checked in backup files. sc_prohibit_backup_files: @$(VC_LIST) | grep '~$$' && \ @@ -988,27 +863,6 @@ sc_const_long_option: echo 1>&2 '$(ME): add "const" to the above declarations'; \ exit 1; } || : -NEWS_hash = \ - $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ - $(srcdir)/NEWS \ - | perl -0777 -pe \ - 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \ - | md5sum - \ - | sed 's/ .*//') - -# Ensure that we don't accidentally insert an entry into an old NEWS block. -sc_immutable_NEWS: - @if test -f $(srcdir)/NEWS; then \ - test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \ - { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \ - fi - -# Update the hash stored above. Do this after each release and -# for any corrections to old entries. -update-NEWS-hash: NEWS - perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \ - $(srcdir)/$(_build-aux)/cfg.mk - # Ensure that we use only the standard $(VAR) notation, # not @...@ in Makefile.am, now that we can rely on automake # to emit a definition for each substituted variable. @@ -1031,15 +885,6 @@ sc_makefile_at_at_check: $$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \ && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : -news-check: NEWS - if sed -n $(news-check-lines-spec)p $(srcdir)/NEWS \ - | grep -E $(news-check-regexp) >/dev/null; then \ - :; \ - else \ - echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ - exit 1; \ - fi - sc_makefile_TAB_only_indentation: @prohibit='^ [ ]{8}' \ in_vc_files='akefile|\.mk$$' \ @@ -1100,41 +945,6 @@ sc_makefile_path_separator_check: halt=$(msg) \ $(_sc_search_regexp) -# Check that `make alpha' will not fail at the end of the process, -# i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release) -# and is read-only. -writable-files: - if test -d $(release_archive_dir); then \ - for file in $(DIST_ARCHIVES); do \ - for p in ./ $(release_archive_dir)/; do \ - test -e $$p$$file || continue; \ - test -w $$p$$file \ - || { echo ERROR: $$p$$file is not writable; fail=1; }; \ - done; \ - done; \ - test "$$fail" && exit 1 || : ; \ - else :; \ - fi - -v_etc_file = $(gnulib_dir)/lib/version-etc.c -sample-test = tests/sample-test -texi = doc/$(PACKAGE).texi -# Make sure that the copyright date in $(v_etc_file) is up to date. -# Do the same for the $(sample-test) and the main doc/.texi file. -sc_copyright_check: - @require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \ - in_files=$(v_etc_file) \ - halt='out of date copyright in $(v_etc_file); update it' \ - $(_sc_search_regexp) - @require='# Copyright \(C\) '$$(date +%Y)' Free' \ - in_vc_files=$(sample-test) \ - halt='out of date copyright in $(sample-test); update it' \ - $(_sc_search_regexp) - @require='Copyright @copyright\{\} .*'$$(date +%Y)' Free' \ - in_vc_files=$(texi) \ - halt='out of date copyright in $(texi); update it' \ - $(_sc_search_regexp) - # If tests/help-version exists and seems to be new enough, assume that its # use of init.sh and path_prepend_ is correct, and ensure that every other # use of init.sh is identical. @@ -1188,329 +998,3 @@ sc_vulnerable_makefile_CVE-2009-4029: ' "make dist*" rules, and upgrade to fixed automake' \ ' see http://bugzilla.redhat.com/542609 for details') \ $(_sc_search_regexp) - -vc-diff-check: - (unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || : - if test -s vc-diffs; then \ - cat vc-diffs; \ - echo "Some files are locally modified:" 1>&2; \ - exit 1; \ - else \ - rm vc-diffs; \ - fi - -rel-files = $(DIST_ARCHIVES) - -gnulib_dir ?= $(srcdir)/gnulib -gnulib-version = $$(cd $(gnulib_dir) && git describe) -bootstrap-tools ?= autoconf,automake,gnulib - -# If it's not already specified, derive the GPG key ID from -# the signed tag we've just applied to mark this release. -gpg_key_ID ?= \ - $$(git cat-file tag v$(VERSION) > .ann-sig \ - && gpgv .ann-sig - < /dev/null 2>&1 \ - | sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig) - -translation_project_ ?= coordinator@translationproject.org - -# Make info-gnu the default only for a stable release. -ifeq ($(RELEASE_TYPE),stable) - announcement_Cc_ ?= $(translation_project_), $(PACKAGE_BUGREPORT) - announcement_mail_headers_ ?= \ - To: info-gnu@gnu.org \ - Cc: $(announcement_Cc_) \ - Mail-Followup-To: $(PACKAGE_BUGREPORT) -else - announcement_Cc_ ?= $(translation_project_) - announcement_mail_headers_ ?= \ - To: $(PACKAGE_BUGREPORT) \ - Cc: $(announcement_Cc_) -endif - -announcement: NEWS ChangeLog $(rel-files) - @$(srcdir)/$(_build-aux)/announce-gen \ - --mail-headers='$(announcement_mail_headers_)' \ - --release-type=$(RELEASE_TYPE) \ - --package=$(PACKAGE) \ - --prev=$(PREV_VERSION) \ - --curr=$(VERSION) \ - --gpg-key-id=$(gpg_key_ID) \ - --news=$(srcdir)/NEWS \ - --bootstrap-tools=$(bootstrap-tools) \ - --gnulib-version=$(gnulib-version) \ - --no-print-checksums \ - $(addprefix --url-dir=, $(url_dir_list)) - -## ---------------- ## -## Updating files. ## -## ---------------- ## - -ftp-gnu = ftp://ftp.gnu.org/gnu -www-gnu = http://www.gnu.org - -upload_dest_dir_ ?= $(PACKAGE) -emit_upload_commands: - @echo ===================================== - @echo ===================================== - @echo "$(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \\" - @echo " --to $(gnu_rel_host):$(upload_dest_dir_) \\" - @echo " $(rel-files)" - @echo '# send the ~/announce-$(my_distdir) e-mail' - @echo ===================================== - @echo ===================================== - -define emit-commit-log - printf '%s\n' 'maint: post-release administrivia' '' \ - '* NEWS: Add header line for next release.' \ - '* .prev-version: Record previous version.' \ - '* cfg.mk (old_NEWS_hash): Auto-update.' -endef - -.PHONY: no-submodule-changes -no-submodule-changes: - if test -d $(srcdir)/.git; then \ - diff=$$(cd $(srcdir) && git submodule -q foreach \ - git diff-index --name-only HEAD) \ - || exit 1; \ - case $$diff in '') ;; \ - *) echo '$(ME): submodule files are locally modified:'; \ - echo "$$diff"; exit 1;; esac; \ - else \ - : ; \ - fi - -submodule-checks ?= no-submodule-changes public-submodule-commit - -# Ensure that each sub-module commit we're using is public. -# Without this, it is too easy to tag and release code that -# cannot be built from a fresh clone. -.PHONY: public-submodule-commit -public-submodule-commit: - $(AM_V_GEN)if test -d $(srcdir)/.git; then \ - cd $(srcdir) && \ - git submodule --quiet foreach test '$$(git rev-parse $$sha1)' \ - = '$$(git merge-base origin $$sha1)' \ - || { echo '$(ME): found non-public submodule commit' >&2; \ - exit 1; }; \ - else \ - : ; \ - fi -# This rule has a high enough utility/cost ratio that it should be a -# dependent of "check" by default. However, some of us do occasionally -# commit a temporary change that deliberately points to a non-public -# submodule commit, and want to be able to use rules like "make check". -# In that case, run e.g., "make check gl_public_submodule_commit=" -# to disable this test. -gl_public_submodule_commit ?= public-submodule-commit -check: $(gl_public_submodule_commit) - -.PHONY: alpha beta stable -ALL_RECURSIVE_TARGETS += alpha beta stable -alpha beta stable: $(local-check) writable-files $(submodule-checks) - test $@ = stable \ - && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \ - || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ - || : - $(MAKE) vc-diff-check - $(MAKE) news-check - $(MAKE) distcheck - $(MAKE) dist XZ_OPT=-9ev - $(MAKE) $(release-prep-hook) RELEASE_TYPE=$@ - $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@ - -# Override this in cfg.mk if you follow different procedures. -release-prep-hook ?= release-prep - -gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?] -.PHONY: release-prep -release-prep: - case $$RELEASE_TYPE in alpha|beta|stable) ;; \ - *) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac - $(MAKE) --no-print-directory -s announcement > ~/announce-$(my_distdir) - if test -d $(release_archive_dir); then \ - ln $(rel-files) $(release_archive_dir); \ - chmod a-w $(rel-files); \ - fi - echo $(VERSION) > $(prev_version_file) - $(MAKE) update-NEWS-hash - perl -pi -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' NEWS - $(emit-commit-log) > .ci-msg - $(VC) commit -F .ci-msg -a - rm .ci-msg - -# Override this with e.g., -s $(srcdir)/some_other_name.texi -# if the default $(PACKAGE)-derived name doesn't apply. -gendocs_options_ ?= - -.PHONY: web-manual -web-manual: - @test -z "$(manual_title)" \ - && { echo define manual_title in cfg.mk 1>&2; exit 1; } || : - @cd '$(srcdir)/doc'; \ - $(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \ - -o '$(abs_builddir)/doc/manual' \ - --email $(PACKAGE_BUGREPORT) $(PACKAGE) \ - "$(PACKAGE_NAME) - $(manual_title)" - @echo " *** Upload the doc/manual directory to web-cvs." - -# Code Coverage - -init-coverage: - $(MAKE) $(AM_MAKEFLAGS) clean - lcov --directory . --zerocounters - -COVERAGE_CCOPTS ?= "-g --coverage" -COVERAGE_OUT ?= doc/coverage - -build-coverage: - $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) - $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check - mkdir -p $(COVERAGE_OUT) - lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \ - --capture - -gen-coverage: - genhtml --output-directory $(COVERAGE_OUT) \ - $(COVERAGE_OUT)/$(PACKAGE).info \ - --highlight --frames --legend \ - --title "$(PACKAGE_NAME)" - -coverage: init-coverage build-coverage gen-coverage - -# Update gettext files. -PACKAGE ?= $(shell basename $(PWD)) -PO_DOMAIN ?= $(PACKAGE) -POURL = http://translationproject.org/latest/$(PO_DOMAIN)/ -PODIR ?= po -refresh-po: - rm -f $(PODIR)/*.po && \ - echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \ - wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \ - echo 'en@boldquot' > $(PODIR)/LINGUAS && \ - echo 'en@quot' >> $(PODIR)/LINGUAS && \ - ls $(PODIR)/*.po | sed 's/\.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS - - # Running indent once is not idempotent, but running it twice is. -INDENT_SOURCES ?= $(C_SOURCES) -.PHONY: indent -indent: - indent $(INDENT_SOURCES) - indent $(INDENT_SOURCES) - -# If you want to set UPDATE_COPYRIGHT_* environment variables, -# put the assignments in this variable. -update-copyright-env ?= - -# Run this rule once per year (usually early in January) -# to update all FSF copyright year lists in your project. -# If you have an additional project-specific rule, -# add it in cfg.mk along with a line 'update-copyright: prereq'. -# By default, exclude all variants of COPYING; you can also -# add exemptions (such as ChangeLog..* for rotated change logs) -# in the file .x-update-copyright. -.PHONY: update-copyright -update-copyright: - grep -l -w Copyright \ - $$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \ - | $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@ - -# 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 ?= src - -ALL_RECURSIVE_TARGETS += sc_tight_scope -sc_tight_scope: tight-scope.mk - @fail=0; \ - if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/$(_build-aux)/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 Makefile \ - -f $(abs_top_srcdir)/$(_build-aux)/cfg.mk \ - -f $(abs_top_builddir)/$< \ - _gl_tight_scope \ - || fail=1; \ - fi; \ - rm -f $<; \ - exit $$fail - -tight-scope.mk: $(ME) - @rm -f $@ $@-t - @perl -ne '/^# TS-start/.../^# TS-end/ and print' $(ME) > $@-t - @chmod a=r $@-t && mv $@-t $@ - -ifeq (a,b) -# TS-start - -# Most functions should have static scope. -# Any that don't must be marked with `extern', but `main' -# and `usage' are exceptions: they're always extern, but -# do not need to be marked. Symbols matching `__.*' are -# reserved by the compiler, so are automatically excluded below. -_gl_TS_unmarked_extern_functions ?= main usage -_gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\S+) *\(/ - -# If your project uses a macro like "XTERN", then put -# the following in cfg.mk to override this default: -# export _gl_TS_extern = extern|XTERN -_gl_TS_extern ?= extern - -# The second nm|grep checks for file-scope variables with `extern' scope. -# Without gnulib's progname module, you might put program_name here. -# Symbols matching `__.*' are reserved by the compiler, -# so are automatically excluded below. -_gl_TS_unmarked_extern_vars ?= - -# NOTE: the _match variables are perl expressions -- not mere regular -# expressions -- so that you can extend them to match other patterns -# and easily extract matched variable names. -# For example, if your project declares some global variables via -# 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 = \ -# /^(?:$(_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-$$$$; \ - trap 's=$$?; rm -f $$t; exit $$s' 0; \ - for sig in 1 2 3 13 15; do \ - eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \ - done; \ - src=`for f in $(SOURCES); do \ - test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \ - hdr=`for f in $(_gl_TS_headers); do \ - test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \ - ( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_functions); \ - grep -h -A1 '^extern .*[^;]$$' $$src \ - | grep -vE '^(extern |--)' | sed 's/ .*//'; \ - perl -lne \ - '$(_gl_TS_function_match) and print "^$$1\$$"' $$hdr; \ - ) | sort -u > $$t; \ - nm -e $(_gl_TS_obj_files) | sed -n 's/.* T //p'|grep -Ev -f $$t \ - && { echo the above functions should have static scope >&2; \ - exit 1; } || : ; \ - ( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars); \ - perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' $$hdr *.h \ - ) | sort -u > $$t; \ - nm -e $(_gl_TS_obj_files) | sed -n 's/.* [BCDGRS] //p' \ - | sort -u | grep -Ev -f $$t \ - && { echo the above variables should have static scope >&2; \ - exit 1; } || : -# TS-end -endif