|
Packit Service |
9646c7 |
# -*-Makefile-*-
|
|
Packit Service |
9646c7 |
# This Makefile fragment tries to be general-purpose enough to be
|
|
Packit Service |
9646c7 |
# used by many projects via the gnulib maintainer-makefile module.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
## Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
|
Packit Service |
9646c7 |
##
|
|
Packit Service |
9646c7 |
## This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
9646c7 |
## it under the terms of the GNU General Public License as published by
|
|
Packit Service |
9646c7 |
## the Free Software Foundation, either version 3 of the License, or
|
|
Packit Service |
9646c7 |
## (at your option) any later version.
|
|
Packit Service |
9646c7 |
##
|
|
Packit Service |
9646c7 |
## This program is distributed in the hope that it will be useful,
|
|
Packit Service |
9646c7 |
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
9646c7 |
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
9646c7 |
## GNU General Public License for more details.
|
|
Packit Service |
9646c7 |
##
|
|
Packit Service |
9646c7 |
## You should have received a copy of the GNU General Public License
|
|
Packit Service |
9646c7 |
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# This is reported not to work with make-3.79.1
|
|
Packit Service |
9646c7 |
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
|
Packit Service |
9646c7 |
ME := maint.mk
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Diagnostic for continued use of deprecated variable.
|
|
Packit Service |
9646c7 |
# Remove in 2013
|
|
Packit Service |
9646c7 |
ifneq ($(build_aux),)
|
|
Packit Service |
9646c7 |
$(error "$(ME): \
|
|
Packit Service |
9646c7 |
set $$(_build-aux) relative to $$(srcdir) instead of $$(build_aux)")
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Do not save the original name or timestamp in the .tar.gz file.
|
|
Packit Service |
9646c7 |
# Use --rsyncable if available.
|
|
Packit Service |
9646c7 |
gzip_rsyncable := \
|
|
Packit Service |
9646c7 |
$(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null \
|
|
Packit Service |
9646c7 |
&& printf %s --rsyncable)
|
|
Packit Service |
9646c7 |
GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
GIT = git
|
|
Packit Service |
9646c7 |
VC = $(GIT)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# You can override this variable in cfg.mk to set your own regexp
|
|
Packit Service |
9646c7 |
# matching files to ignore.
|
|
Packit Service |
9646c7 |
VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# This is to preprocess robustly the output of $(VC_LIST), so that even
|
|
Packit Service |
9646c7 |
# when $(srcdir) is a pathological name like "....", the leading sed command
|
|
Packit Service |
9646c7 |
# removes only the intended prefix.
|
|
Packit Service |
9646c7 |
_dot_escaped_srcdir = $(subst .,\.,$(srcdir))
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
|
|
Packit Service |
9646c7 |
# when $(srcdir) is not ".".
|
|
Packit Service |
9646c7 |
ifeq ($(srcdir),.)
|
|
Packit Service |
9646c7 |
_prepend_srcdir_prefix =
|
|
Packit Service |
9646c7 |
else
|
|
Packit Service |
9646c7 |
_prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# In order to be able to consistently filter "."-relative names,
|
|
Packit Service |
9646c7 |
# (i.e., with no $(srcdir) prefix), this definition is careful to
|
|
Packit Service |
9646c7 |
# remove any $(srcdir) prefix, and to restore what it removes.
|
|
Packit Service |
9646c7 |
_sc_excl = \
|
|
Packit Service |
9646c7 |
$(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
|
|
Packit Service |
9646c7 |
VC_LIST_EXCEPT = \
|
|
Packit Service |
9646c7 |
$(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
|
|
Packit Service |
9646c7 |
| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
|
|
Packit Service |
9646c7 |
else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
|
|
Packit Service |
9646c7 |
| grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
|
|
Packit Service |
9646c7 |
$(_prepend_srcdir_prefix)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ifeq ($(origin prev_version_file), undefined)
|
|
Packit Service |
9646c7 |
prev_version_file = $(srcdir)/.prev-version
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
PREV_VERSION := $(shell cat $(prev_version_file) 2>/dev/null)
|
|
Packit Service |
9646c7 |
VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
|
Packit Service |
9646c7 |
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ifeq ($(VC),$(GIT))
|
|
Packit Service |
9646c7 |
this-vc-tag = v$(VERSION)
|
|
Packit Service |
9646c7 |
this-vc-tag-regexp = v$(VERSION_REGEXP)
|
|
Packit Service |
9646c7 |
else
|
|
Packit Service |
9646c7 |
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
|
|
Packit Service |
9646c7 |
tag-this-version = $(subst .,_,$(VERSION))
|
|
Packit Service |
9646c7 |
this-vc-tag = $(tag-package)-$(tag-this-version)
|
|
Packit Service |
9646c7 |
this-vc-tag-regexp = $(this-vc-tag)
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
my_distdir = $(PACKAGE)-$(VERSION)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Old releases are stored here.
|
|
Packit Service |
9646c7 |
release_archive_dir ?= ../release
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
|
|
Packit Service |
9646c7 |
# Use alpha.gnu.org for alpha and beta releases.
|
|
Packit Service |
9646c7 |
# Use ftp.gnu.org for stable releases.
|
|
Packit Service |
9646c7 |
gnu_ftp_host-alpha = alpha.gnu.org
|
|
Packit Service |
9646c7 |
gnu_ftp_host-beta = alpha.gnu.org
|
|
Packit Service |
9646c7 |
gnu_ftp_host-stable = ftp.gnu.org
|
|
Packit Service |
9646c7 |
gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE))
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ifeq ($(gnu_rel_host),ftp.gnu.org)
|
|
Packit Service |
9646c7 |
url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE)
|
|
Packit Service |
9646c7 |
else
|
|
Packit Service |
9646c7 |
url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Override this in cfg.mk if you are using a different format in your
|
|
Packit Service |
9646c7 |
# NEWS file.
|
|
Packit Service |
9646c7 |
today = $(shell date +%Y-%m-%d)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Select which lines of NEWS are searched for $(news-check-regexp).
|
|
Packit Service |
9646c7 |
# This is a sed line number spec. The default says that we search
|
|
Packit Service |
9646c7 |
# lines 1..10 of NEWS for $(news-check-regexp).
|
|
Packit Service |
9646c7 |
# If you want to search only line 3 or only lines 20-22, use "3" or "20,22".
|
|
Packit Service |
9646c7 |
news-check-lines-spec ?= 1,10
|
|
Packit Service |
9646c7 |
news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prevent programs like 'sort' from considering distinct strings to be equal.
|
|
Packit Service |
9646c7 |
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
|
|
Packit Service |
9646c7 |
export LC_ALL = C
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
## --------------- ##
|
|
Packit Service |
9646c7 |
## Sanity checks. ##
|
|
Packit Service |
9646c7 |
## --------------- ##
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
_cfg_mk := $(shell test -f $(srcdir)/cfg.mk && echo '$(srcdir)/cfg.mk')
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Collect the names of rules starting with 'sc_'.
|
|
Packit Service |
9646c7 |
syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
|
|
Packit Service |
9646c7 |
$(srcdir)/$(ME) $(_cfg_mk)))
|
|
Packit Service |
9646c7 |
.PHONY: $(syntax-check-rules)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0)
|
|
Packit Service |
9646c7 |
local-checks-available += $(syntax-check-rules)
|
|
Packit Service |
9646c7 |
else
|
|
Packit Service |
9646c7 |
local-checks-available += no-vc-detected
|
|
Packit Service |
9646c7 |
no-vc-detected:
|
|
Packit Service |
9646c7 |
@echo "No version control files detected; skipping syntax check"
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
.PHONY: $(local-checks-available)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Arrange to print the name of each syntax-checking rule just before running it.
|
|
Packit Service |
9646c7 |
$(syntax-check-rules): %: %.m
|
|
Packit Service |
9646c7 |
sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
|
|
Packit Service |
9646c7 |
.PHONY: $(sc_m_rules_)
|
|
Packit Service |
9646c7 |
$(sc_m_rules_):
|
|
Packit Service |
9646c7 |
@echo $(patsubst sc_%.m, %, $@)
|
|
Packit Service |
9646c7 |
@date +%s.%N > .sc-start-$(basename $@)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Compute and print the elapsed time for each syntax-check rule.
|
|
Packit Service |
9646c7 |
sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules))
|
|
Packit Service |
9646c7 |
.PHONY: $(sc_z_rules_)
|
|
Packit Service |
9646c7 |
$(sc_z_rules_): %.z: %
|
|
Packit Service |
9646c7 |
@end=$$(date +%s.%N); \
|
|
Packit Service |
9646c7 |
start=$$(cat .sc-start-$*); \
|
|
Packit Service |
9646c7 |
rm -f .sc-start-$*; \
|
|
Packit Service |
9646c7 |
awk -v s=$$start -v e=$$end \
|
|
Packit Service |
9646c7 |
'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
|
|
Packit Service |
9646c7 |
# that computes and prints elapsed time.
|
|
Packit Service |
9646c7 |
local-check := \
|
|
Packit Service |
9646c7 |
$(patsubst sc_%, sc_%.z, \
|
|
Packit Service |
9646c7 |
$(filter-out $(local-checks-to-skip), $(local-checks-available)))
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
syntax-check: $(local-check)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# _sc_search_regexp
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# This macro searches for a given construct in the selected files and
|
|
Packit Service |
9646c7 |
# then takes some action.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Parameters (shell variables):
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# prohibit | require
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Regular expression (ERE) denoting either a forbidden construct
|
|
Packit Service |
9646c7 |
# or a required construct. Those arguments are exclusive.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# exclude
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Regular expression (ERE) denoting lines to ignore that matched
|
|
Packit Service |
9646c7 |
# a prohibit construct. For example, this can be used to exclude
|
|
Packit Service |
9646c7 |
# comments that mention why the nearby code uses an alternative
|
|
Packit Service |
9646c7 |
# construct instead of the simpler prohibited construct.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# in_vc_files | in_files
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# grep-E-style regexp denoting the files to check. If no files
|
|
Packit Service |
9646c7 |
# are specified the default are all the files that are under
|
|
Packit Service |
9646c7 |
# version control.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# containing | non_containing
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Select the files (non) containing strings matching this regexp.
|
|
Packit Service |
9646c7 |
# If both arguments are specified then CONTAINING takes
|
|
Packit Service |
9646c7 |
# precedence.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# with_grep_options
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Extra options for grep.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# ignore_case
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Ignore case.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# halt
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Message to display before to halting execution.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Finally, you may exempt files based on an ERE matching file names.
|
|
Packit Service |
9646c7 |
# For example, to exempt from the sc_space_tab check all files with the
|
|
Packit Service |
9646c7 |
# .diff suffix, set this Make variable:
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# exclude_file_name_regexp--sc_space_tab = \.diff$
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
|
|
Packit Service |
9646c7 |
# when filtering by name via in_files, we explicitly filter out matching
|
|
Packit Service |
9646c7 |
# names here as well.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Initialize each, so that envvar settings cannot interfere.
|
|
Packit Service |
9646c7 |
export require =
|
|
Packit Service |
9646c7 |
export prohibit =
|
|
Packit Service |
9646c7 |
export exclude =
|
|
Packit Service |
9646c7 |
export in_vc_files =
|
|
Packit Service |
9646c7 |
export in_files =
|
|
Packit Service |
9646c7 |
export containing =
|
|
Packit Service |
9646c7 |
export non_containing =
|
|
Packit Service |
9646c7 |
export halt =
|
|
Packit Service |
9646c7 |
export with_grep_options =
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# By default, _sc_search_regexp does not ignore case.
|
|
Packit Service |
9646c7 |
export ignore_case =
|
|
Packit Service |
9646c7 |
_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
define _sc_say_and_exit
|
|
Packit Service |
9646c7 |
dummy=; : so we do not need a semicolon before each use; \
|
|
Packit Service |
9646c7 |
{ printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; };
|
|
Packit Service |
9646c7 |
endef
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
define _sc_search_regexp
|
|
Packit Service |
9646c7 |
dummy=; : so we do not need a semicolon before each use; \
|
|
Packit Service |
9646c7 |
\
|
|
Packit Service |
9646c7 |
: Check arguments; \
|
|
Packit Service |
9646c7 |
test -n "$$prohibit" && test -n "$$require" \
|
|
Packit Service |
9646c7 |
&& { msg='Cannot specify both prohibit and require' \
|
|
Packit Service |
9646c7 |
$(_sc_say_and_exit) } || :; \
|
|
Packit Service |
9646c7 |
test -z "$$prohibit" && test -z "$$require" \
|
|
Packit Service |
9646c7 |
&& { msg='Should specify either prohibit or require' \
|
|
Packit Service |
9646c7 |
$(_sc_say_and_exit) } || :; \
|
|
Packit Service |
9646c7 |
test -z "$$prohibit" && test -n "$$exclude" \
|
|
Packit Service |
9646c7 |
&& { msg='Use of exclude requires a prohibit pattern' \
|
|
Packit Service |
9646c7 |
$(_sc_say_and_exit) } || :; \
|
|
Packit Service |
9646c7 |
test -n "$$in_vc_files" && test -n "$$in_files" \
|
|
Packit Service |
9646c7 |
&& { msg='Cannot specify both in_vc_files and in_files' \
|
|
Packit Service |
9646c7 |
$(_sc_say_and_exit) } || :; \
|
|
Packit Service |
9646c7 |
test "x$$halt" != x \
|
|
Packit Service |
9646c7 |
|| { msg='halt not defined' $(_sc_say_and_exit) }; \
|
|
Packit Service |
9646c7 |
\
|
|
Packit Service |
9646c7 |
: Filter by file name; \
|
|
Packit Service |
9646c7 |
if test -n "$$in_files"; then \
|
|
Packit Service |
9646c7 |
files=$$(find $(srcdir) | grep -E "$$in_files" \
|
|
Packit Service |
9646c7 |
| grep -Ev '$(exclude_file_name_regexp--$@)'); \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
files=$$($(VC_LIST_EXCEPT)); \
|
|
Packit Service |
9646c7 |
if test -n "$$in_vc_files"; then \
|
|
Packit Service |
9646c7 |
files=$$(echo "$$files" | grep -E "$$in_vc_files"); \
|
|
Packit Service |
9646c7 |
fi; \
|
|
Packit Service |
9646c7 |
fi; \
|
|
Packit Service |
9646c7 |
\
|
|
Packit Service |
9646c7 |
: Filter by content; \
|
|
Packit Service |
9646c7 |
test -n "$$files" && test -n "$$containing" \
|
|
Packit Service |
9646c7 |
&& { files=$$(grep -l "$$containing" $$files); } || :; \
|
|
Packit Service |
9646c7 |
test -n "$$files" && test -n "$$non_containing" \
|
|
Packit Service |
9646c7 |
&& { files=$$(grep -vl "$$non_containing" $$files); } || :; \
|
|
Packit Service |
9646c7 |
\
|
|
Packit Service |
9646c7 |
: Check for the construct; \
|
|
Packit Service |
9646c7 |
if test -n "$$files"; then \
|
|
Packit Service |
9646c7 |
if test -n "$$prohibit"; then \
|
|
Packit Service |
9646c7 |
grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
|
|
Packit Service |
9646c7 |
| grep -vE "$${exclude:-^$$}" \
|
|
Packit Service |
9646c7 |
&& { msg="$$halt" $(_sc_say_and_exit) } || :; \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
|
|
Packit Service |
9646c7 |
| grep . \
|
|
Packit Service |
9646c7 |
&& { msg="$$halt" $(_sc_say_and_exit) } || :; \
|
|
Packit Service |
9646c7 |
fi \
|
|
Packit Service |
9646c7 |
else :; \
|
|
Packit Service |
9646c7 |
fi || :;
|
|
Packit Service |
9646c7 |
endef
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_avoid_if_before_free:
|
|
Packit Service |
9646c7 |
@$(srcdir)/$(_build-aux)/useless-if-before-free \
|
|
Packit Service |
9646c7 |
$(useless_free_options) \
|
|
Packit Service |
9646c7 |
$$($(VC_LIST_EXCEPT) | grep -v useless-if-before-free) && \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_cast_of_argument_to_free:
|
|
Packit Service |
9646c7 |
@prohibit='\
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_cast_of_x_alloc_return_value:
|
|
Packit Service |
9646c7 |
@prohibit='\*\) *x(m|c|re)alloc\>' \
|
|
Packit Service |
9646c7 |
halt="don't cast x*alloc return value" \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_cast_of_alloca_return_value:
|
|
Packit Service |
9646c7 |
@prohibit='\*\) *alloca\>' \
|
|
Packit Service |
9646c7 |
halt="don't cast alloca return value" \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_space_tab:
|
|
Packit Service |
9646c7 |
@prohibit='[ ] ' \
|
|
Packit Service |
9646c7 |
halt='found SPACE-TAB sequence; remove the SPACE' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't use *scanf or the old ato* functions in "real" code.
|
|
Packit Service |
9646c7 |
# They provide no error checking mechanism.
|
|
Packit Service |
9646c7 |
# Instead, use strto* functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_atoi_atof:
|
|
Packit Service |
9646c7 |
@prohibit='\<([fs]?scanf|ato([filq]|ll)) *\(' \
|
|
Packit Service |
9646c7 |
halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Use STREQ rather than comparing strcmp == 0, or != 0.
|
|
Packit Service |
9646c7 |
sp_ = strcmp *\(.+\)
|
|
Packit Service |
9646c7 |
sc_prohibit_strcmp:
|
|
Packit Service |
9646c7 |
@prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \
|
|
Packit Service |
9646c7 |
exclude=':# *define STRN?EQ\(' \
|
|
Packit Service |
9646c7 |
halt='$(ME): replace strcmp calls above with STREQ/STRNEQ' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Pass EXIT_*, not number, to usage, exit, and error (when exiting)
|
|
Packit Service |
9646c7 |
# Convert all uses automatically, via these two commands:
|
|
Packit Service |
9646c7 |
# git grep -l '\
|
|
Packit Service |
9646c7 |
# | grep -vEf .x-sc_prohibit_magic_number_exit \
|
|
Packit Service |
9646c7 |
# | xargs --no-run-if-empty \
|
|
Packit Service |
9646c7 |
# perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
|
|
Packit Service |
9646c7 |
# git grep -l '\
|
|
Packit Service |
9646c7 |
# | grep -vEf .x-sc_prohibit_magic_number_exit \
|
|
Packit Service |
9646c7 |
# | xargs --no-run-if-empty \
|
|
Packit Service |
9646c7 |
# perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
|
|
Packit Service |
9646c7 |
sc_prohibit_magic_number_exit:
|
|
Packit Service |
9646c7 |
@prohibit='(^|[^.])\<(usage|exit) ?\([0-9]|\
|
|
Packit Service |
9646c7 |
halt='use EXIT_* values rather than magic number' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
|
Packit Service |
9646c7 |
# since when that parameter is 0, error does not exit. Use '0' instead.
|
|
Packit Service |
9646c7 |
sc_error_exit_success:
|
|
Packit Service |
9646c7 |
@prohibit='error *\(EXIT_SUCCESS,' \
|
|
Packit Service |
9646c7 |
in_vc_files='\.[chly]$$' \
|
|
Packit Service |
9646c7 |
halt='found error (EXIT_SUCCESS' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# "FATAL:" should be fully upper-cased in error messages
|
|
Packit Service |
9646c7 |
# "WARNING:" should be fully upper-cased, or fully lower-cased
|
|
Packit Service |
9646c7 |
sc_error_message_warn_fatal:
|
|
Packit Service |
9646c7 |
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
| grep -E '"Warning|"Fatal|"fatal' && \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Error messages should not start with a capital letter
|
|
Packit Service |
9646c7 |
sc_error_message_uppercase:
|
|
Packit Service |
9646c7 |
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
| grep -E '"[A-Z]' \
|
|
Packit Service |
9646c7 |
| grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): found capitalized error message' 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Error messages should not end with a period
|
|
Packit Service |
9646c7 |
sc_error_message_period:
|
|
Packit Service |
9646c7 |
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
| grep -E '[^."]\."' && \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): found error message ending in period' 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_file_system:
|
|
Packit Service |
9646c7 |
@prohibit=file''system \
|
|
Packit Service |
9646c7 |
ignore_case=1 \
|
|
Packit Service |
9646c7 |
halt='found use of "file''system"; spell it "file system"' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't use cpp tests of this symbol. All code assumes config.h is included.
|
|
Packit Service |
9646c7 |
sc_prohibit_have_config_h:
|
|
Packit Service |
9646c7 |
@prohibit='^# *if.*HAVE''_CONFIG_H' \
|
|
Packit Service |
9646c7 |
halt='found use of HAVE''_CONFIG_H; remove' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Nearly all .c files must include <config.h>. However, we also permit this
|
|
Packit Service |
9646c7 |
# via inclusion of a package-specific header, if cfg.mk specified one.
|
|
Packit Service |
9646c7 |
# config_h_header must be suitable for grep -E.
|
|
Packit Service |
9646c7 |
config_h_header ?= <config\.h>
|
|
Packit Service |
9646c7 |
sc_require_config_h:
|
|
Packit Service |
9646c7 |
@require='^# *include $(config_h_header)' \
|
|
Packit Service |
9646c7 |
in_vc_files='\.c$$' \
|
|
Packit Service |
9646c7 |
halt='the above files do not include <config.h>' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# You must include <config.h> before including any other header file.
|
|
Packit Service |
9646c7 |
# This can possibly be via a package-specific header, if given by cfg.mk.
|
|
Packit Service |
9646c7 |
sc_require_config_h_first:
|
|
Packit Service |
9646c7 |
@if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
|
|
Packit Service |
9646c7 |
fail=0; \
|
|
Packit Service |
9646c7 |
for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
|
|
Packit Service |
9646c7 |
grep '^# *include\>' $$i | sed 1q \
|
|
Packit Service |
9646c7 |
| grep -E '^# *include $(config_h_header)' > /dev/null \
|
|
Packit Service |
9646c7 |
|| { echo $$i; fail=1; }; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
test $$fail = 1 && \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): the above files include some other header' \
|
|
Packit Service |
9646c7 |
'before <config.h>' 1>&2; exit 1; } || :; \
|
|
Packit Service |
9646c7 |
else :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_HAVE_MBRTOWC:
|
|
Packit Service |
9646c7 |
@prohibit='\bHAVE_MBRTOWC\b' \
|
|
Packit Service |
9646c7 |
halt="do not use $$prohibit; it is always defined" \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# To use this "command" macro, you must first define two shell variables:
|
|
Packit Service |
9646c7 |
# h: the header name, with no enclosing <> or ""
|
|
Packit Service |
9646c7 |
# re: a regular expression that matches IFF something provided by $h is used.
|
|
Packit Service |
9646c7 |
define _sc_header_without_use
|
|
Packit Service |
9646c7 |
dummy=; : so we do not need a semicolon before each use; \
|
|
Packit Service |
9646c7 |
h_esc=`echo '[<"]'"$$h"'[">]'|sed 's/\./\\\\./g'`; \
|
|
Packit Service |
9646c7 |
if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
|
|
Packit Service |
9646c7 |
files=$$(grep -l '^# *include '"$$h_esc" \
|
|
Packit Service |
9646c7 |
$$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
|
|
Packit Service |
9646c7 |
grep -LE "$$re" $$files | grep . && \
|
|
Packit Service |
9646c7 |
{ echo "$(ME): the above files include $$h but don't use it" \
|
|
Packit Service |
9646c7 |
1>&2; exit 1; } || :; \
|
|
Packit Service |
9646c7 |
else :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
endef
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of assert.h without an actual use of assert.
|
|
Packit Service |
9646c7 |
sc_prohibit_assert_without_use:
|
|
Packit Service |
9646c7 |
@h='assert.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of close-stream.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_close_stream_without_use:
|
|
Packit Service |
9646c7 |
@h='close-stream.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of getopt.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_getopt_without_use:
|
|
Packit Service |
9646c7 |
@h='getopt.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include quotearg.h unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_quotearg_without_use:
|
|
Packit Service |
9646c7 |
@h='quotearg.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include quote.h unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_quote_without_use:
|
|
Packit Service |
9646c7 |
@h='quote.h' re='\<quote((_n)? *\(|_quoting_options\>)' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include this header unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_long_options_without_use:
|
|
Packit Service |
9646c7 |
@h='long-options.h' re='\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include this header unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_inttostr_without_use:
|
|
Packit Service |
9646c7 |
@h='inttostr.h' re='\<(off|[iu]max|uint)tostr *\(' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include this header unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_ignore_value_without_use:
|
|
Packit Service |
9646c7 |
@h='ignore-value.h' re='\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include this header unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_error_without_use:
|
|
Packit Service |
9646c7 |
@h='error.h' \
|
|
Packit Service |
9646c7 |
re='\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include xalloc.h unless you use one of its functions.
|
|
Packit Service |
9646c7 |
# Consider these symbols:
|
|
Packit Service |
9646c7 |
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
|
|
Packit Service |
9646c7 |
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
|
|
Packit Service |
9646c7 |
# Divide into two sets on case, and filter each through this:
|
|
Packit Service |
9646c7 |
# | sort | perl -MRegexp::Assemble -le \
|
|
Packit Service |
9646c7 |
# 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
|
|
Packit Service |
9646c7 |
# Note this was produced by the above:
|
|
Packit Service |
9646c7 |
# _xa1 = \
|
|
Packit Service |
9646c7 |
#x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
|
|
Packit Service |
9646c7 |
# But we can do better, in at least two ways:
|
|
Packit Service |
9646c7 |
# 1) take advantage of two "dup"-suffixed strings:
|
|
Packit Service |
9646c7 |
# x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
|
|
Packit Service |
9646c7 |
# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
|
|
Packit Service |
9646c7 |
# "char|[cmz]"
|
|
Packit Service |
9646c7 |
# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
|
|
Packit Service |
9646c7 |
_xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
|
|
Packit Service |
9646c7 |
_xa2 = X([CZ]|N?M)ALLOC
|
|
Packit Service |
9646c7 |
sc_prohibit_xalloc_without_use:
|
|
Packit Service |
9646c7 |
@h='xalloc.h' \
|
|
Packit Service |
9646c7 |
re='\<($(_xa1)|$(_xa2)) *\('\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Extract function names:
|
|
Packit Service |
9646c7 |
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
|
|
Packit Service |
9646c7 |
_hash_re = \
|
|
Packit Service |
9646c7 |
clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning
|
|
Packit Service |
9646c7 |
_hash_fn = \<($(_hash_re)) *\(
|
|
Packit Service |
9646c7 |
_hash_struct = (struct )?\<[Hh]ash_(table|tuning)\>
|
|
Packit Service |
9646c7 |
sc_prohibit_hash_without_use:
|
|
Packit Service |
9646c7 |
@h='hash.h' \
|
|
Packit Service |
9646c7 |
re='$(_hash_fn)|$(_hash_struct)'\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_cloexec_without_use:
|
|
Packit Service |
9646c7 |
@h='cloexec.h' re='\<(set_cloexec_flag|dup_cloexec) *\(' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_posixver_without_use:
|
|
Packit Service |
9646c7 |
@h='posixver.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_same_without_use:
|
|
Packit Service |
9646c7 |
@h='same.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_hash_pjw_without_use:
|
|
Packit Service |
9646c7 |
@h='hash-pjw.h' \
|
|
Packit Service |
9646c7 |
re='\<hash_pjw\>' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_safe_read_without_use:
|
|
Packit Service |
9646c7 |
@h='safe-read.h' re='(\<SAFE_READ_ERROR\>|\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_argmatch_without_use:
|
|
Packit Service |
9646c7 |
@h='argmatch.h' \
|
|
Packit Service |
9646c7 |
re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_canonicalize_without_use:
|
|
Packit Service |
9646c7 |
@h='canonicalize.h' \
|
|
Packit Service |
9646c7 |
re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode|file_name)' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_root_dev_ino_without_use:
|
|
Packit Service |
9646c7 |
@h='root-dev-ino.h' \
|
|
Packit Service |
9646c7 |
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_openat_without_use:
|
|
Packit Service |
9646c7 |
@h='openat.h' \
|
|
Packit Service |
9646c7 |
re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of c-ctype.h without an actual use.
|
|
Packit Service |
9646c7 |
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
|
|
Packit Service |
9646c7 |
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
|
|
Packit Service |
9646c7 |
sc_prohibit_c_ctype_without_use:
|
|
Packit Service |
9646c7 |
@h='c-ctype.h' re='\
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
_empty =
|
|
Packit Service |
9646c7 |
_sp = $(_empty) $(_empty)
|
|
Packit Service |
9646c7 |
# The following list was generated by running:
|
|
Packit Service |
9646c7 |
# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
|
|
Packit Service |
9646c7 |
# | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
|
|
Packit Service |
9646c7 |
_sig_functions = \
|
|
Packit Service |
9646c7 |
bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
|
|
Packit Service |
9646c7 |
sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
|
|
Packit Service |
9646c7 |
siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
|
|
Packit Service |
9646c7 |
sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
|
|
Packit Service |
9646c7 |
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
|
|
Packit Service |
9646c7 |
# The following were extracted from "man signal.h" manually.
|
|
Packit Service |
9646c7 |
_sig_types_and_consts = \
|
|
Packit Service |
9646c7 |
MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
|
|
Packit Service |
9646c7 |
SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
|
|
Packit Service |
9646c7 |
SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
|
|
Packit Service |
9646c7 |
SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
|
|
Packit Service |
9646c7 |
sigstack sigval stack_t ucontext_t
|
|
Packit Service |
9646c7 |
# generated via this:
|
|
Packit Service |
9646c7 |
# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
|
|
Packit Service |
9646c7 |
_sig_names = \
|
|
Packit Service |
9646c7 |
SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
|
|
Packit Service |
9646c7 |
SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
|
|
Packit Service |
9646c7 |
SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
|
|
Packit Service |
9646c7 |
SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
|
|
Packit Service |
9646c7 |
SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
|
|
Packit Service |
9646c7 |
SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
|
|
Packit Service |
9646c7 |
SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
|
|
Packit Service |
9646c7 |
SIGXCPU SIGXFSZ
|
|
Packit Service |
9646c7 |
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of signal.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_signal_without_use:
|
|
Packit Service |
9646c7 |
@h='signal.h' \
|
|
Packit Service |
9646c7 |
re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include stdio--.h unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_stdio--_without_use:
|
|
Packit Service |
9646c7 |
@h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\(' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include stdio-safer.h unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_stdio-safer_without_use:
|
|
Packit Service |
9646c7 |
@h='stdio-safer.h' re='\<((f(re)?|p)open|tmpfile)_safer *\(' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of strings.h without a sensible use.
|
|
Packit Service |
9646c7 |
# Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible.
|
|
Packit Service |
9646c7 |
sc_prohibit_strings_without_use:
|
|
Packit Service |
9646c7 |
@h='strings.h' \
|
|
Packit Service |
9646c7 |
re='\<(strn?casecmp|ffs(ll)?)\>' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Get the list of symbol names with this:
|
|
Packit Service |
9646c7 |
# perl -lne '/^# *define ([A-Z]\w+)\(/ and print $1' lib/intprops.h|fmt
|
|
Packit Service |
9646c7 |
_intprops_names = \
|
|
Packit Service |
9646c7 |
TYPE_IS_INTEGER TYPE_TWOS_COMPLEMENT TYPE_ONES_COMPLEMENT \
|
|
Packit Service |
9646c7 |
TYPE_SIGNED_MAGNITUDE TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM \
|
|
Packit Service |
9646c7 |
INT_BITS_STRLEN_BOUND INT_STRLEN_BOUND INT_BUFSIZE_BOUND \
|
|
Packit Service |
9646c7 |
INT_ADD_RANGE_OVERFLOW INT_SUBTRACT_RANGE_OVERFLOW \
|
|
Packit Service |
9646c7 |
INT_NEGATE_RANGE_OVERFLOW INT_MULTIPLY_RANGE_OVERFLOW \
|
|
Packit Service |
9646c7 |
INT_DIVIDE_RANGE_OVERFLOW INT_REMAINDER_RANGE_OVERFLOW \
|
|
Packit Service |
9646c7 |
INT_LEFT_SHIFT_RANGE_OVERFLOW INT_ADD_OVERFLOW INT_SUBTRACT_OVERFLOW \
|
|
Packit Service |
9646c7 |
INT_NEGATE_OVERFLOW INT_MULTIPLY_OVERFLOW INT_DIVIDE_OVERFLOW \
|
|
Packit Service |
9646c7 |
INT_REMAINDER_OVERFLOW INT_LEFT_SHIFT_OVERFLOW
|
|
Packit Service |
9646c7 |
_intprops_syms_re = $(subst $(_sp),|,$(strip $(_intprops_names)))
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of intprops.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_intprops_without_use:
|
|
Packit Service |
9646c7 |
@h='intprops.h' \
|
|
Packit Service |
9646c7 |
re='\<($(_intprops_syms_re)) *\(' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of stddef.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_stddef_without_use:
|
|
Packit Service |
9646c7 |
@h='stddef.h' \
|
|
Packit Service |
9646c7 |
re='\<($(_stddef_syms_re))\>' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
_de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)?
|
|
Packit Service |
9646c7 |
_de2 = (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(64)?
|
|
Packit Service |
9646c7 |
_de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
|
|
Packit Service |
9646c7 |
_dirent_syms_re = $(_de1)|$(_de2)|$(_de3)
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of dirent.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_dirent_without_use:
|
|
Packit Service |
9646c7 |
@h='dirent.h' \
|
|
Packit Service |
9646c7 |
re='\<($(_dirent_syms_re))\>' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit the inclusion of verify.h without an actual use.
|
|
Packit Service |
9646c7 |
sc_prohibit_verify_without_use:
|
|
Packit Service |
9646c7 |
@h='verify.h' \
|
|
Packit Service |
9646c7 |
re='\<(verify(true|expr)?|static_assert) *\(' \
|
|
Packit Service |
9646c7 |
$(_sc_header_without_use)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't include xfreopen.h unless you use one of its functions.
|
|
Packit Service |
9646c7 |
sc_prohibit_xfreopen_without_use:
|
|
Packit Service |
9646c7 |
@h='xfreopen.h' re='\
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_obsolete_symbols:
|
|
Packit Service |
9646c7 |
@prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
|
|
Packit Service |
9646c7 |
halt='do not use HAVE''_FCNTL_H or O'_NDELAY \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Each nonempty ChangeLog line must start with a year number, or a TAB.
|
|
Packit Service |
9646c7 |
sc_changelog:
|
|
Packit Service |
9646c7 |
@prohibit='^[^12 ]' \
|
|
Packit Service |
9646c7 |
in_vc_files='^ChangeLog$$' \
|
|
Packit Service |
9646c7 |
halt='found unexpected prefix in a ChangeLog' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Ensure that each .c file containing a "main" function also
|
|
Packit Service |
9646c7 |
# calls set_program_name.
|
|
Packit Service |
9646c7 |
sc_program_name:
|
|
Packit Service |
9646c7 |
@require='set_program_name *\(m?argv\[0\]\);' \
|
|
Packit Service |
9646c7 |
in_vc_files='\.c$$' \
|
|
Packit Service |
9646c7 |
containing='\
|
|
Packit Service |
9646c7 |
halt='the above files do not call set_program_name' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Ensure that each .c file containing a "main" function also
|
|
Packit Service |
9646c7 |
# calls bindtextdomain.
|
|
Packit Service |
9646c7 |
sc_bindtextdomain:
|
|
Packit Service |
9646c7 |
@require='bindtextdomain *\(' \
|
|
Packit Service |
9646c7 |
in_vc_files='\.c$$' \
|
|
Packit Service |
9646c7 |
containing='\
|
|
Packit Service |
9646c7 |
halt='the above files do not call bindtextdomain' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Require that the final line of each test-lib.sh-using test be this one:
|
|
Packit Service |
9646c7 |
# Exit $fail
|
|
Packit Service |
9646c7 |
# Note: this test requires GNU grep's --label= option.
|
|
Packit Service |
9646c7 |
Exit_witness_file ?= tests/test-lib.sh
|
|
Packit Service |
9646c7 |
Exit_base := $(notdir $(Exit_witness_file))
|
|
Packit Service |
9646c7 |
sc_require_test_exit_idiom:
|
|
Packit Service |
9646c7 |
@if test -f $(srcdir)/$(Exit_witness_file); then \
|
|
Packit Service |
9646c7 |
die=0; \
|
|
Packit Service |
9646c7 |
for i in $$(grep -l -F 'srcdir/$(Exit_base)' \
|
|
Packit Service |
9646c7 |
$$($(VC_LIST) tests)); do \
|
|
Packit Service |
9646c7 |
tail -n1 $$i | grep '^Exit .' > /dev/null \
|
|
Packit Service |
9646c7 |
&& : || { die=1; echo $$i; } \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
test $$die = 1 && \
|
|
Packit Service |
9646c7 |
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \
|
|
Packit Service |
9646c7 |
echo 1>&2 'Exit something'; \
|
|
Packit Service |
9646c7 |
exit 1; } || :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_trailing_blank:
|
|
Packit Service |
9646c7 |
@prohibit='[ ]$$' \
|
|
Packit Service |
9646c7 |
halt='found trailing blank(s)' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Match lines like the following, but where there is only one space
|
|
Packit Service |
9646c7 |
# between the options and the description:
|
|
Packit Service |
9646c7 |
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
|
|
Packit Service |
9646c7 |
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
|
|
Packit Service |
9646c7 |
sc_two_space_separator_in_usage:
|
|
Packit Service |
9646c7 |
@prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
|
|
Packit Service |
9646c7 |
halt='help2man requires at least two spaces between an option and its description'\
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# A regexp matching function names like "error" that may be used
|
|
Packit Service |
9646c7 |
# to emit translatable messages.
|
|
Packit Service |
9646c7 |
_gl_translatable_diag_func_re ?= error
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Look for diagnostics that aren't marked for translation.
|
|
Packit Service |
9646c7 |
# This won't find any for which error's format string is on a separate line.
|
|
Packit Service |
9646c7 |
sc_unmarked_diagnostics:
|
|
Packit Service |
9646c7 |
@prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
|
|
Packit Service |
9646c7 |
exclude='(_|ngettext ?)\(' \
|
|
Packit Service |
9646c7 |
halt='$(ME): found unmarked diagnostic(s)' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Avoid useless parentheses like those in this example:
|
|
Packit Service |
9646c7 |
# #if defined (SYMBOL) || defined (SYM2)
|
|
Packit Service |
9646c7 |
sc_useless_cpp_parens:
|
|
Packit Service |
9646c7 |
@prohibit='^# *if .*defined *\(' \
|
|
Packit Service |
9646c7 |
halt='found useless parentheses in cpp directive' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# List headers for which HAVE_HEADER_H is always true, assuming you are
|
|
Packit Service |
9646c7 |
# using the appropriate gnulib module. CAUTION: for each "unnecessary"
|
|
Packit Service |
9646c7 |
# #if HAVE_HEADER_H that you remove, be sure that your project explicitly
|
|
Packit Service |
9646c7 |
# requires the gnulib module that guarantees the usability of that header.
|
|
Packit Service |
9646c7 |
gl_assured_headers_ = \
|
|
Packit Service |
9646c7 |
cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g'
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Convert the list of names to upper case, and replace each space with "|".
|
|
Packit Service |
9646c7 |
az_ = abcdefghijklmnopqrstuvwxyz
|
|
Packit Service |
9646c7 |
AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
Packit Service |
9646c7 |
gl_header_upper_case_or_ = \
|
|
Packit Service |
9646c7 |
$$($(gl_assured_headers_) \
|
|
Packit Service |
9646c7 |
| tr $(az_)/.- $(AZ_)___ \
|
|
Packit Service |
9646c7 |
| tr -s ' ' '|' \
|
|
Packit Service |
9646c7 |
)
|
|
Packit Service |
9646c7 |
sc_prohibit_always_true_header_tests:
|
|
Packit Service |
9646c7 |
@or=$(gl_header_upper_case_or_); \
|
|
Packit Service |
9646c7 |
re="HAVE_($$or)_H"; \
|
|
Packit Service |
9646c7 |
prohibit='\<'"$$re"'\>' \
|
|
Packit Service |
9646c7 |
halt=$$(printf '%s\n' \
|
|
Packit Service |
9646c7 |
'do not test the above HAVE_<header>_H symbol(s);' \
|
|
Packit Service |
9646c7 |
' with the corresponding gnulib module, they are always true') \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# ==================================================================
|
|
Packit Service |
9646c7 |
gl_other_headers_ ?= \
|
|
Packit Service |
9646c7 |
intprops.h \
|
|
Packit Service |
9646c7 |
openat.h \
|
|
Packit Service |
9646c7 |
stat-macros.h
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Perl -lne code to extract "significant" cpp-defined symbols from a
|
|
Packit Service |
9646c7 |
# gnulib header file, eliminating a few common false-positives.
|
|
Packit Service |
9646c7 |
# The exempted names below are defined only conditionally in gnulib,
|
|
Packit Service |
9646c7 |
# and hence sometimes must/may be defined in application code.
|
|
Packit Service |
9646c7 |
gl_extract_significant_defines_ = \
|
|
Packit Service |
9646c7 |
/^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
|
|
Packit Service |
9646c7 |
&& $$2 !~ /(?:rpl_|_used_without_)/\
|
|
Packit Service |
9646c7 |
&& $$1 !~ /^(?:NSIG|ENODATA)$$/\
|
|
Packit Service |
9646c7 |
&& $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\
|
|
Packit Service |
9646c7 |
and print $$1
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Create a list of regular expressions matching the names
|
|
Packit Service |
9646c7 |
# of macros that are guaranteed to be defined by parts of gnulib.
|
|
Packit Service |
9646c7 |
define def_sym_regex
|
|
Packit Service |
9646c7 |
gen_h=$(gl_generated_headers_); \
|
|
Packit Service |
9646c7 |
(cd $(gnulib_dir)/lib; \
|
|
Packit Service |
9646c7 |
for f in *.in.h $(gl_other_headers_); do \
|
|
Packit Service |
9646c7 |
test -f $$f \
|
|
Packit Service |
9646c7 |
&& perl -lne '$(gl_extract_significant_defines_)' $$f; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
) | sort -u \
|
|
Packit Service |
9646c7 |
| sed 's/^/^ *# *(define|undef) */;s/$$/\\>/'
|
|
Packit Service |
9646c7 |
endef
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't define macros that we already get from gnulib header files.
|
|
Packit Service |
9646c7 |
sc_prohibit_always-defined_macros:
|
|
Packit Service |
9646c7 |
@if test -d $(gnulib_dir); then \
|
|
Packit Service |
9646c7 |
case $$(echo all: | grep -l -f - Makefile) in Makefile);; *) \
|
|
Packit Service |
9646c7 |
echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \
|
|
Packit Service |
9646c7 |
esac; \
|
|
Packit Service |
9646c7 |
$(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
&& { echo '$(ME): define the above via some gnulib .h file' \
|
|
Packit Service |
9646c7 |
1>&2; exit 1; } || :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
# ==================================================================
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Prohibit checked in backup files.
|
|
Packit Service |
9646c7 |
sc_prohibit_backup_files:
|
|
Packit Service |
9646c7 |
@$(VC_LIST) | grep '~$$' && \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): found version controlled backup file' 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Require the latest GPL.
|
|
Packit Service |
9646c7 |
sc_GPL_version:
|
|
Packit Service |
9646c7 |
@prohibit='either ''version [^3]' \
|
|
Packit Service |
9646c7 |
halt='GPL vN, N!=3' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Require the latest GFDL. Two regexp, since some .texi files end up
|
|
Packit Service |
9646c7 |
# line wrapping between 'Free Documentation License,' and 'Version'.
|
|
Packit Service |
9646c7 |
_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
|
|
Packit Service |
9646c7 |
sc_GFDL_version:
|
|
Packit Service |
9646c7 |
@prohibit='$(_GFDL_regexp)' \
|
|
Packit Service |
9646c7 |
halt='GFDL vN, N!=3' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Don't use Texinfo's @acronym{}.
|
|
Packit Service |
9646c7 |
# http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00321.html
|
|
Packit Service |
9646c7 |
texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$
|
|
Packit Service |
9646c7 |
sc_texinfo_acronym:
|
|
Packit Service |
9646c7 |
@prohibit='@acronym\{' \
|
|
Packit Service |
9646c7 |
in_vc_files='$(texinfo_suffix_re_)' \
|
|
Packit Service |
9646c7 |
halt='found use of Texinfo @acronym{}' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
cvs_keywords = \
|
|
Packit Service |
9646c7 |
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_cvs_keyword:
|
|
Packit Service |
9646c7 |
@prohibit='\$$($(cvs_keywords))\$$' \
|
|
Packit Service |
9646c7 |
halt='do not use CVS keyword expansion' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# This Perl code is slightly obfuscated. Not only is each "$" doubled
|
|
Packit Service |
9646c7 |
# because it's in a Makefile, but the $$c's are comments; we cannot
|
|
Packit Service |
9646c7 |
# use "#" due to the way the script ends up concatenated onto one line.
|
|
Packit Service |
9646c7 |
# It would be much more concise, and would produce better output (including
|
|
Packit Service |
9646c7 |
# counts) if written as:
|
|
Packit Service |
9646c7 |
# perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
|
|
Packit Service |
9646c7 |
# but that would be far less efficient, reading the entire contents
|
|
Packit Service |
9646c7 |
# of each file, rather than just the last two bytes of each.
|
|
Packit Service |
9646c7 |
# In addition, while the code below detects both blank lines and a missing
|
|
Packit Service |
9646c7 |
# newline at EOF, the above detects only the former.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# This is a perl script that is expected to be the single-quoted argument
|
|
Packit Service |
9646c7 |
# to a command-line "-le". The remaining arguments are file names.
|
|
Packit Service |
9646c7 |
# Print the name of each file that does not end in exactly one newline byte.
|
|
Packit Service |
9646c7 |
# I.e., warn if there are blank lines (2 or more newlines), or if the
|
|
Packit Service |
9646c7 |
# last byte is not a newline. However, currently we don't complain
|
|
Packit Service |
9646c7 |
# about any file that contains exactly one byte.
|
|
Packit Service |
9646c7 |
# Exit nonzero if at least one such file is found, otherwise, exit 0.
|
|
Packit Service |
9646c7 |
# Warn about, but otherwise ignore open failure. Ignore seek/read failure.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Use this if you want to remove trailing empty lines from selected files:
|
|
Packit Service |
9646c7 |
# perl -pi -0777 -e 's/\n\n+$/\n/' files...
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
require_exactly_one_NL_at_EOF_ = \
|
|
Packit Service |
9646c7 |
foreach my $$f (@ARGV) \
|
|
Packit Service |
9646c7 |
{ \
|
|
Packit Service |
9646c7 |
open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \
|
|
Packit Service |
9646c7 |
my $$p = sysseek (F, -2, 2); \
|
|
Packit Service |
9646c7 |
my $$c = "seek failure probably means file has < 2 bytes; ignore"; \
|
|
Packit Service |
9646c7 |
my $$last_two_bytes; \
|
|
Packit Service |
9646c7 |
defined $$p and $$p = sysread F, $$last_two_bytes, 2; \
|
|
Packit Service |
9646c7 |
close F; \
|
|
Packit Service |
9646c7 |
$$c = "ignore read failure"; \
|
|
Packit Service |
9646c7 |
$$p && ($$last_two_bytes eq "\n\n" \
|
|
Packit Service |
9646c7 |
|| substr ($$last_two_bytes,1) ne "\n") \
|
|
Packit Service |
9646c7 |
and (print $$f), $$fail=1; \
|
|
Packit Service |
9646c7 |
} \
|
|
Packit Service |
9646c7 |
END { exit defined $$fail }
|
|
Packit Service |
9646c7 |
sc_prohibit_empty_lines_at_EOF:
|
|
Packit Service |
9646c7 |
@perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
|| { echo '$(ME): empty line(s) or no newline at EOF' \
|
|
Packit Service |
9646c7 |
1>&2; exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
|
|
Packit Service |
9646c7 |
# This is a bit of a kludge, since it prevents use of the string
|
|
Packit Service |
9646c7 |
# even in comments, but for now it does the job with no false positives.
|
|
Packit Service |
9646c7 |
sc_prohibit_stat_st_blocks:
|
|
Packit Service |
9646c7 |
@prohibit='[.>]st_blocks' \
|
|
Packit Service |
9646c7 |
halt='do not use st_blocks; use ST_NBLOCKS' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Make sure we don't define any S_IS* macros in src/*.c files.
|
|
Packit Service |
9646c7 |
# They're already defined via gnulib's sys/stat.h replacement.
|
|
Packit Service |
9646c7 |
sc_prohibit_S_IS_definition:
|
|
Packit Service |
9646c7 |
@prohibit='^ *# *define *S_IS' \
|
|
Packit Service |
9646c7 |
halt='do not define S_IS* macros; include <sys/stat.h>' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Perl block to convert a match to FILE_NAME:LINENO:TEST,
|
|
Packit Service |
9646c7 |
# that is shared by two definitions below.
|
|
Packit Service |
9646c7 |
perl_filename_lineno_text_ = \
|
|
Packit Service |
9646c7 |
-e ' {' \
|
|
Packit Service |
9646c7 |
-e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \
|
|
Packit Service |
9646c7 |
-e ' ($$v = $$&) =~ s/\n/\\n/g;' \
|
|
Packit Service |
9646c7 |
-e ' print "$$ARGV:$$n:$$v\n";' \
|
|
Packit Service |
9646c7 |
-e ' }'
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
prohibit_doubled_word_RE_ ?= \
|
|
Packit Service |
9646c7 |
/\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims
|
|
Packit Service |
9646c7 |
prohibit_doubled_word_ = \
|
|
Packit Service |
9646c7 |
-e 'while ($(prohibit_doubled_word_RE_))' \
|
|
Packit Service |
9646c7 |
$(perl_filename_lineno_text_)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Define this to a regular expression that matches
|
|
Packit Service |
9646c7 |
# any filename:dd:match lines you want to ignore.
|
|
Packit Service |
9646c7 |
# The default is to ignore no matches.
|
|
Packit Service |
9646c7 |
ignore_doubled_word_match_RE_ ?= ^$$
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_doubled_word:
|
|
Packit Service |
9646c7 |
@perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
| grep -vE '$(ignore_doubled_word_match_RE_)' \
|
|
Packit Service |
9646c7 |
| grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# A regular expression matching undesirable combinations of words like
|
|
Packit Service |
9646c7 |
# "can not"; this matches them even when the two words appear on different
|
|
Packit Service |
9646c7 |
# lines, but not when there is an intervening delimiter like "#" or "*".
|
|
Packit Service |
9646c7 |
# Similarly undesirable, "See @xref{...}", since an @xref should start
|
|
Packit Service |
9646c7 |
# a sentence. Explicitly prohibit any prefix of "see" or "also".
|
|
Packit Service |
9646c7 |
# Also prohibit a prefix matching "\w+ +".
|
|
Packit Service |
9646c7 |
# @pxref gets the same see/also treatment and should be parenthesized;
|
|
Packit Service |
9646c7 |
# presume it must *not* start a sentence.
|
|
Packit Service |
9646c7 |
bad_xref_re_ ?= (?:[\w,:;] +|(?:see|also)\s+)\@xref\{
|
|
Packit Service |
9646c7 |
bad_pxref_re_ ?= (?:[.!?]|(?:see|also))\s+\@pxref\{
|
|
Packit Service |
9646c7 |
prohibit_undesirable_word_seq_RE_ ?= \
|
|
Packit Service |
9646c7 |
/(?:\bcan\s+not\b|$(bad_xref_re_)|$(bad_pxref_re_))/gims
|
|
Packit Service |
9646c7 |
prohibit_undesirable_word_seq_ = \
|
|
Packit Service |
9646c7 |
-e 'while ($(prohibit_undesirable_word_seq_RE_))' \
|
|
Packit Service |
9646c7 |
$(perl_filename_lineno_text_)
|
|
Packit Service |
9646c7 |
# Define this to a regular expression that matches
|
|
Packit Service |
9646c7 |
# any filename:dd:match lines you want to ignore.
|
|
Packit Service |
9646c7 |
# The default is to ignore no matches.
|
|
Packit Service |
9646c7 |
ignore_undesirable_word_sequence_RE_ ?= ^$$
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_prohibit_undesirable_word_seq:
|
|
Packit Service |
9646c7 |
@perl -n -0777 $(prohibit_undesirable_word_seq_) \
|
|
Packit Service |
9646c7 |
$$($(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
| grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep . \
|
|
Packit Service |
9646c7 |
&& { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
|
|
Packit Service |
9646c7 |
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
|
|
Packit Service |
9646c7 |
# Using test's -a and -o operators is not portable.
|
|
Packit Service |
9646c7 |
# We prefer test over [, since the latter is spelled [[ in configure.ac.
|
|
Packit Service |
9646c7 |
sc_prohibit_test_minus_ao:
|
|
Packit Service |
9646c7 |
@prohibit='(\
|
|
Packit Service |
9646c7 |
halt='$(_ptm1); $(_ptm2)' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Avoid a test bashism.
|
|
Packit Service |
9646c7 |
sc_prohibit_test_double_equal:
|
|
Packit Service |
9646c7 |
@prohibit='(\
|
|
Packit Service |
9646c7 |
containing='#! */bin/[a-z]*sh' \
|
|
Packit Service |
9646c7 |
halt='use "test x = x", not "test x =''= x"' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Each program that uses proper_name_utf8 must link with one of the
|
|
Packit Service |
9646c7 |
# ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
|
|
Packit Service |
9646c7 |
# The perl -0777 invocation below extracts the possibly-multi-line
|
|
Packit Service |
9646c7 |
# definition of LDADD from the appropriate Makefile.am and exits 0
|
|
Packit Service |
9646c7 |
# when it contains "ICONV".
|
|
Packit Service |
9646c7 |
sc_proper_name_utf8_requires_ICONV:
|
|
Packit Service |
9646c7 |
@progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
|
|
Packit Service |
9646c7 |
if test "x$$progs" != x; then \
|
|
Packit Service |
9646c7 |
fail=0; \
|
|
Packit Service |
9646c7 |
for p in $$progs; do \
|
|
Packit Service |
9646c7 |
dir=$$(dirname "$$p"); \
|
|
Packit Service |
9646c7 |
perl -0777 \
|
|
Packit Service |
9646c7 |
-ne 'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \
|
|
Packit Service |
9646c7 |
$$dir/Makefile.am && continue; \
|
|
Packit Service |
9646c7 |
base=$$(basename "$$p" .c); \
|
|
Packit Service |
9646c7 |
grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
|
|
Packit Service |
9646c7 |
|| { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
test $$fail = 1 && \
|
|
Packit Service |
9646c7 |
{ echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
|
|
Packit Service |
9646c7 |
exit 1; } || :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Warn about "c0nst struct Foo const foo[]",
|
|
Packit Service |
9646c7 |
# but not about "char const *const foo" or "#define const const".
|
|
Packit Service |
9646c7 |
sc_redundant_const:
|
|
Packit Service |
9646c7 |
@prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
|
|
Packit Service |
9646c7 |
halt='redundant "const" in declarations' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_const_long_option:
|
|
Packit Service |
9646c7 |
@prohibit='^ *static.*struct option ' \
|
|
Packit Service |
9646c7 |
exclude='const struct option|struct option const' \
|
|
Packit Service |
9646c7 |
halt='$(ME): add "const" to the above declarations' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
NEWS_hash = \
|
|
Packit Service |
9646c7 |
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
|
|
Packit Service |
9646c7 |
$(srcdir)/NEWS \
|
|
Packit Service |
9646c7 |
| perl -0777 -pe \
|
|
Packit Service |
9646c7 |
's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \
|
|
Packit Service |
9646c7 |
| md5sum - \
|
|
Packit Service |
9646c7 |
| sed 's/ .*//')
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Ensure that we don't accidentally insert an entry into an old NEWS block.
|
|
Packit Service |
9646c7 |
sc_immutable_NEWS:
|
|
Packit Service |
9646c7 |
@if test -f $(srcdir)/NEWS; then \
|
|
Packit Service |
9646c7 |
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
|
|
Packit Service |
9646c7 |
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Update the hash stored above. Do this after each release and
|
|
Packit Service |
9646c7 |
# for any corrections to old entries.
|
|
Packit Service |
9646c7 |
update-NEWS-hash: NEWS
|
|
Packit Service |
9646c7 |
perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \
|
|
Packit Service |
9646c7 |
$(srcdir)/cfg.mk
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Ensure that we use only the standard $(VAR) notation,
|
|
Packit Service |
9646c7 |
# not @...@ in Makefile.am, now that we can rely on automake
|
|
Packit Service |
9646c7 |
# to emit a definition for each substituted variable.
|
|
Packit Service |
9646c7 |
# However, there is still one case in which @VAR@ use is not just
|
|
Packit Service |
9646c7 |
# legitimate, but actually required: when augmenting an automake-defined
|
|
Packit Service |
9646c7 |
# variable with a prefix. For example, gettext uses this:
|
|
Packit Service |
9646c7 |
# MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
|
|
Packit Service |
9646c7 |
# otherwise, makeinfo would put German or French (current locale)
|
|
Packit Service |
9646c7 |
# navigation hints in the otherwise-English documentation.
|
|
Packit Service |
9646c7 |
#
|
|
Packit Service |
9646c7 |
# Allow the package to add exceptions via a hook in cfg.mk;
|
|
Packit Service |
9646c7 |
# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
|
|
Packit Service |
9646c7 |
# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
|
|
Packit Service |
9646c7 |
_makefile_at_at_check_exceptions ?=
|
|
Packit Service |
9646c7 |
sc_makefile_at_at_check:
|
|
Packit Service |
9646c7 |
@perl -ne '/\@\w+\@/' \
|
|
Packit Service |
9646c7 |
-e ' && !/(\w+)\s+=.*\@\1\@$$/' \
|
|
Packit Service |
9646c7 |
-e ''$(_makefile_at_at_check_exceptions) \
|
|
Packit Service |
9646c7 |
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
|
|
Packit Service |
9646c7 |
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \
|
|
Packit Service |
9646c7 |
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
news-check: NEWS
|
|
Packit Service |
9646c7 |
if sed -n $(news-check-lines-spec)p $(srcdir)/NEWS \
|
|
Packit Service |
9646c7 |
| grep -E $(news-check-regexp) >/dev/null; then \
|
|
Packit Service |
9646c7 |
:; \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_makefile_TAB_only_indentation:
|
|
Packit Service |
9646c7 |
@prohibit='^ [ ]{8}' \
|
|
Packit Service |
9646c7 |
in_vc_files='akefile|\.mk$$' \
|
|
Packit Service |
9646c7 |
halt='found TAB-8-space indentation' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_m4_quote_check:
|
|
Packit Service |
9646c7 |
@prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
|
|
Packit Service |
9646c7 |
in_vc_files='(^configure\.ac|\.m4)$$' \
|
|
Packit Service |
9646c7 |
halt='quote the first arg to AC_DEF*' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
fix_po_file_diag = \
|
|
Packit Service |
9646c7 |
'you have changed the set of files with translatable diagnostics;\n\
|
|
Packit Service |
9646c7 |
apply the above patch\n'
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Verify that all source files using _() are listed in po/POTFILES.in.
|
|
Packit Service |
9646c7 |
po_file ?= $(srcdir)/po/POTFILES.in
|
|
Packit Service |
9646c7 |
generated_files ?= $(srcdir)/lib/*.[ch]
|
|
Packit Service |
9646c7 |
sc_po_check:
|
|
Packit Service |
9646c7 |
@if test -f $(po_file); then \
|
|
Packit Service |
9646c7 |
grep -E -v '^(#|$$)' $(po_file) \
|
|
Packit Service |
9646c7 |
| grep -v '^src/false\.c$$' | sort > $@-1; \
|
|
Packit Service |
9646c7 |
files=; \
|
|
Packit Service |
9646c7 |
for file in $$($(VC_LIST_EXCEPT)) $(generated_files); do \
|
|
Packit Service |
9646c7 |
test -r $$file || continue; \
|
|
Packit Service |
9646c7 |
case $$file in \
|
|
Packit Service |
9646c7 |
*.m4|*.mk) continue ;; \
|
|
Packit Service |
9646c7 |
*.?|*.??) ;; \
|
|
Packit Service |
9646c7 |
*) continue;; \
|
|
Packit Service |
9646c7 |
esac; \
|
|
Packit Service |
9646c7 |
case $$file in \
|
|
Packit Service |
9646c7 |
*.[ch]) \
|
|
Packit Service |
9646c7 |
base=`expr " $$file" : ' \(.*\)\..'`; \
|
|
Packit Service |
9646c7 |
{ test -f $$base.l || test -f $$base.y; } && continue;; \
|
|
Packit Service |
9646c7 |
esac; \
|
|
Packit Service |
9646c7 |
files="$$files $$file"; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
|
|
Packit Service |
9646c7 |
| sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2; \
|
|
Packit Service |
9646c7 |
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|
|
Packit Service |
9646c7 |
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
|
|
Packit Service |
9646c7 |
rm -f $@-1 $@-2; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Sometimes it is useful to change the PATH environment variable
|
|
Packit Service |
9646c7 |
# in Makefiles. When doing so, it's better not to use the Unix-centric
|
|
Packit Service |
9646c7 |
# path separator of ':', but rather the automake-provided '$(PATH_SEPARATOR)'.
|
|
Packit Service |
9646c7 |
msg = '$(ME): Do not use ":" above; use $$(PATH_SEPARATOR) instead'
|
|
Packit Service |
9646c7 |
sc_makefile_path_separator_check:
|
|
Packit Service |
9646c7 |
@prohibit='PATH[=].*:' \
|
|
Packit Service |
9646c7 |
in_vc_files='akefile|\.mk$$' \
|
|
Packit Service |
9646c7 |
halt=$(msg) \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Check that 'make alpha' will not fail at the end of the process,
|
|
Packit Service |
9646c7 |
# i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release)
|
|
Packit Service |
9646c7 |
# and is read-only.
|
|
Packit Service |
9646c7 |
writable-files:
|
|
Packit Service |
9646c7 |
if test -d $(release_archive_dir); then \
|
|
Packit Service |
9646c7 |
for file in $(DIST_ARCHIVES); do \
|
|
Packit Service |
9646c7 |
for p in ./ $(release_archive_dir)/; do \
|
|
Packit Service |
9646c7 |
test -e $$p$$file || continue; \
|
|
Packit Service |
9646c7 |
test -w $$p$$file \
|
|
Packit Service |
9646c7 |
|| { echo ERROR: $$p$$file is not writable; fail=1; }; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
test "$$fail" && exit 1 || : ; \
|
|
Packit Service |
9646c7 |
else :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
v_etc_file = $(gnulib_dir)/lib/version-etc.c
|
|
Packit Service |
9646c7 |
sample-test = tests/sample-test
|
|
Packit Service |
9646c7 |
texi = doc/$(PACKAGE).texi
|
|
Packit Service |
9646c7 |
# Make sure that the copyright date in $(v_etc_file) is up to date.
|
|
Packit Service |
9646c7 |
# Do the same for the $(sample-test) and the main doc/.texi file.
|
|
Packit Service |
9646c7 |
sc_copyright_check:
|
|
Packit Service |
9646c7 |
@require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \
|
|
Packit Service |
9646c7 |
in_files=$(v_etc_file) \
|
|
Packit Service |
9646c7 |
halt='out of date copyright in $(v_etc_file); update it' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
@require='# Copyright \(C\) '$$(date +%Y)' Free' \
|
|
Packit Service |
9646c7 |
in_vc_files=$(sample-test) \
|
|
Packit Service |
9646c7 |
halt='out of date copyright in $(sample-test); update it' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
@require='Copyright @copyright\{\} .*'$$(date +%Y)' Free' \
|
|
Packit Service |
9646c7 |
in_vc_files=$(texi) \
|
|
Packit Service |
9646c7 |
halt='out of date copyright in $(texi); update it' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# If tests/help-version exists and seems to be new enough, assume that its
|
|
Packit Service |
9646c7 |
# use of init.sh and path_prepend_ is correct, and ensure that every other
|
|
Packit Service |
9646c7 |
# use of init.sh is identical.
|
|
Packit Service |
9646c7 |
# This is useful because help-version cross-checks prog --version
|
|
Packit Service |
9646c7 |
# with $(VERSION), which verifies that its path_prepend_ invocation
|
|
Packit Service |
9646c7 |
# sets PATH correctly. This is an inexpensive way to ensure that
|
|
Packit Service |
9646c7 |
# the other init.sh-using tests also get it right.
|
|
Packit Service |
9646c7 |
_hv_file ?= $(srcdir)/tests/help-version
|
|
Packit Service |
9646c7 |
_hv_regex_weak ?= ^ *\. .*/init\.sh"
|
|
Packit Service |
9646c7 |
# Fix syntax-highlighters "
|
|
Packit Service |
9646c7 |
_hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh"
|
|
Packit Service |
9646c7 |
sc_cross_check_PATH_usage_in_tests:
|
|
Packit Service |
9646c7 |
@if test -f $(_hv_file); then \
|
|
Packit Service |
9646c7 |
grep -l 'VERSION mismatch' $(_hv_file) >/dev/null \
|
|
Packit Service |
9646c7 |
|| { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \
|
|
Packit Service |
9646c7 |
exit 0; }; \
|
|
Packit Service |
9646c7 |
grep -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \
|
|
Packit Service |
9646c7 |
|| { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; }; \
|
|
Packit Service |
9646c7 |
good=$$(grep -E '$(_hv_regex_strong)' $(_hv_file)); \
|
|
Packit Service |
9646c7 |
grep -LFx "$$good" \
|
|
Packit Service |
9646c7 |
$$(grep -lE '$(_hv_regex_weak)' $$($(VC_LIST_EXCEPT))) \
|
|
Packit Service |
9646c7 |
| grep . && \
|
|
Packit Service |
9646c7 |
{ echo "$(ME): the above files use path_prepend_ inconsistently" \
|
|
Packit Service |
9646c7 |
1>&2; exit 1; } || :; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# BRE regex of file contents to identify a test script.
|
|
Packit Service |
9646c7 |
_test_script_regex ?= \<init\.sh\>
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# In tests, use "compare expected actual", not the reverse.
|
|
Packit Service |
9646c7 |
sc_prohibit_reversed_compare_failure:
|
|
Packit Service |
9646c7 |
@prohibit='\
|
|
Packit Service |
9646c7 |
containing='$(_test_script_regex)' \
|
|
Packit Service |
9646c7 |
halt='reversed compare arguments' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# #if HAVE_... will evaluate to false for any non numeric string.
|
|
Packit Service |
9646c7 |
# That would be flagged by using -Wundef, however gnulib currently
|
|
Packit Service |
9646c7 |
# tests many undefined macros, and so we can't enable that option.
|
|
Packit Service |
9646c7 |
# So at least preclude common boolean strings as macro values.
|
|
Packit Service |
9646c7 |
sc_Wundef_boolean:
|
|
Packit Service |
9646c7 |
@prohibit='^#define.*(yes|no|true|false)$$' \
|
|
Packit Service |
9646c7 |
in_files='$(CONFIG_INCLUDE)' \
|
|
Packit Service |
9646c7 |
halt='Use 0 or 1 for macro values' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
|
|
Packit Service |
9646c7 |
# not be constant, or might overflow a stack. In general, use PATH_MAX as
|
|
Packit Service |
9646c7 |
# a limit, not an array or alloca size.
|
|
Packit Service |
9646c7 |
sc_prohibit_path_max_allocation:
|
|
Packit Service |
9646c7 |
@prohibit='(\balloca *\([^)]*|\[[^]]*)PATH_MAX' \
|
|
Packit Service |
9646c7 |
halt='Avoid stack allocations of size PATH_MAX' \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
sc_vulnerable_makefile_CVE-2009-4029:
|
|
Packit Service |
9646c7 |
@prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
|
|
Packit Service |
9646c7 |
in_files=$$(find $(srcdir) -name Makefile.in) \
|
|
Packit Service |
9646c7 |
halt=$$(printf '%s\n' \
|
|
Packit Service |
9646c7 |
'the above files are vulnerable; beware of running' \
|
|
Packit Service |
9646c7 |
' "make dist*" rules, and upgrade to fixed automake' \
|
|
Packit Service |
9646c7 |
' see http://bugzilla.redhat.com/542609 for details') \
|
|
Packit Service |
9646c7 |
$(_sc_search_regexp)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
vc-diff-check:
|
|
Packit Service |
9646c7 |
(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
|
|
Packit Service |
9646c7 |
if test -s vc-diffs; then \
|
|
Packit Service |
9646c7 |
cat vc-diffs; \
|
|
Packit Service |
9646c7 |
echo "Some files are locally modified:" 1>&2; \
|
|
Packit Service |
9646c7 |
exit 1; \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
rm vc-diffs; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
rel-files = $(DIST_ARCHIVES)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
gnulib_dir ?= $(srcdir)/gnulib
|
|
Packit Service |
9646c7 |
gnulib-version = $$(cd $(gnulib_dir) && git describe)
|
|
Packit Service |
9646c7 |
bootstrap-tools ?= autoconf,automake,gnulib
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# If it's not already specified, derive the GPG key ID from
|
|
Packit Service |
9646c7 |
# the signed tag we've just applied to mark this release.
|
|
Packit Service |
9646c7 |
gpg_key_ID ?= \
|
|
Packit Service |
9646c7 |
$$(git cat-file tag v$(VERSION) \
|
|
Packit Service |
9646c7 |
| gpgv --status-fd 1 --keyring /dev/null - - 2>/dev/null \
|
|
Packit Service |
9646c7 |
| sed -n '/^\[GNUPG:\] ERRSIG /{s///;s/ .*//p;q}')
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
translation_project_ ?= coordinator@translationproject.org
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Make info-gnu the default only for a stable release.
|
|
Packit Service |
9646c7 |
ifeq ($(RELEASE_TYPE),stable)
|
|
Packit Service |
9646c7 |
announcement_Cc_ ?= $(translation_project_), $(PACKAGE_BUGREPORT)
|
|
Packit Service |
9646c7 |
announcement_mail_headers_ ?= \
|
|
Packit Service |
9646c7 |
To: info-gnu@gnu.org \
|
|
Packit Service |
9646c7 |
Cc: $(announcement_Cc_) \
|
|
Packit Service |
9646c7 |
Mail-Followup-To: $(PACKAGE_BUGREPORT)
|
|
Packit Service |
9646c7 |
else
|
|
Packit Service |
9646c7 |
announcement_Cc_ ?= $(translation_project_)
|
|
Packit Service |
9646c7 |
announcement_mail_headers_ ?= \
|
|
Packit Service |
9646c7 |
To: $(PACKAGE_BUGREPORT) \
|
|
Packit Service |
9646c7 |
Cc: $(announcement_Cc_)
|
|
Packit Service |
9646c7 |
endif
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
announcement: NEWS ChangeLog $(rel-files)
|
|
Packit Service |
9646c7 |
@$(srcdir)/$(_build-aux)/announce-gen \
|
|
Packit Service |
9646c7 |
--mail-headers='$(announcement_mail_headers_)' \
|
|
Packit Service |
9646c7 |
--release-type=$(RELEASE_TYPE) \
|
|
Packit Service |
9646c7 |
--package=$(PACKAGE) \
|
|
Packit Service |
9646c7 |
--prev=$(PREV_VERSION) \
|
|
Packit Service |
9646c7 |
--curr=$(VERSION) \
|
|
Packit Service |
9646c7 |
--gpg-key-id=$(gpg_key_ID) \
|
|
Packit Service |
9646c7 |
--news=$(srcdir)/NEWS \
|
|
Packit Service |
9646c7 |
--bootstrap-tools=$(bootstrap-tools) \
|
|
Packit Service |
9646c7 |
$$(case ,$(bootstrap-tools), in (*,gnulib,*) \
|
|
Packit Service |
9646c7 |
echo --gnulib-version=$(gnulib-version);; esac) \
|
|
Packit Service |
9646c7 |
--no-print-checksums \
|
|
Packit Service |
9646c7 |
$(addprefix --url-dir=, $(url_dir_list))
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
## ---------------- ##
|
|
Packit Service |
9646c7 |
## Updating files. ##
|
|
Packit Service |
9646c7 |
## ---------------- ##
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ftp-gnu = ftp://ftp.gnu.org/gnu
|
|
Packit Service |
9646c7 |
www-gnu = http://www.gnu.org
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
upload_dest_dir_ ?= $(PACKAGE)
|
|
Packit Service |
9646c7 |
emit_upload_commands:
|
|
Packit Service |
9646c7 |
@echo =====================================
|
|
Packit Service |
9646c7 |
@echo =====================================
|
|
Packit Service |
9646c7 |
@echo "$(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \\"
|
|
Packit Service |
9646c7 |
@echo " --to $(gnu_rel_host):$(upload_dest_dir_) \\"
|
|
Packit Service |
9646c7 |
@echo " $(rel-files)"
|
|
Packit Service |
9646c7 |
@echo '# send the ~/announce-$(my_distdir) e-mail'
|
|
Packit Service |
9646c7 |
@echo =====================================
|
|
Packit Service |
9646c7 |
@echo =====================================
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
define emit-commit-log
|
|
Packit Service |
9646c7 |
printf '%s\n' 'maint: post-release administrivia' '' \
|
|
Packit Service |
9646c7 |
'* NEWS: Add header line for next release.' \
|
|
Packit Service |
9646c7 |
'* .prev-version: Record previous version.' \
|
|
Packit Service |
9646c7 |
'* cfg.mk (old_NEWS_hash): Auto-update.'
|
|
Packit Service |
9646c7 |
endef
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
.PHONY: no-submodule-changes
|
|
Packit Service |
9646c7 |
no-submodule-changes:
|
|
Packit Service |
9646c7 |
if test -d $(srcdir)/.git; then \
|
|
Packit Service |
9646c7 |
diff=$$(cd $(srcdir) && git submodule -q foreach \
|
|
Packit Service |
9646c7 |
git diff-index --name-only HEAD) \
|
|
Packit Service |
9646c7 |
|| exit 1; \
|
|
Packit Service |
9646c7 |
case $$diff in '') ;; \
|
|
Packit Service |
9646c7 |
*) echo '$(ME): submodule files are locally modified:'; \
|
|
Packit Service |
9646c7 |
echo "$$diff"; exit 1;; esac; \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
: ; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
submodule-checks ?= no-submodule-changes public-submodule-commit
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Ensure that each sub-module commit we're using is public.
|
|
Packit Service |
9646c7 |
# Without this, it is too easy to tag and release code that
|
|
Packit Service |
9646c7 |
# cannot be built from a fresh clone.
|
|
Packit Service |
9646c7 |
.PHONY: public-submodule-commit
|
|
Packit Service |
9646c7 |
public-submodule-commit:
|
|
Packit Service |
9646c7 |
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
|
|
Packit Service |
9646c7 |
cd $(srcdir) && \
|
|
Packit Service |
9646c7 |
git submodule --quiet foreach test '$$(git rev-parse $$sha1)' \
|
|
Packit Service |
9646c7 |
= '$$(git merge-base origin $$sha1)' \
|
|
Packit Service |
9646c7 |
|| { echo '$(ME): found non-public submodule commit' >&2; \
|
|
Packit Service |
9646c7 |
exit 1; }; \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
: ; \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
# This rule has a high enough utility/cost ratio that it should be a
|
|
Packit Service |
9646c7 |
# dependent of "check" by default. However, some of us do occasionally
|
|
Packit Service |
9646c7 |
# commit a temporary change that deliberately points to a non-public
|
|
Packit Service |
9646c7 |
# submodule commit, and want to be able to use rules like "make check".
|
|
Packit Service |
9646c7 |
# In that case, run e.g., "make check gl_public_submodule_commit="
|
|
Packit Service |
9646c7 |
# to disable this test.
|
|
Packit Service |
9646c7 |
gl_public_submodule_commit ?= public-submodule-commit
|
|
Packit Service |
9646c7 |
check: $(gl_public_submodule_commit)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
.PHONY: alpha beta stable
|
|
Packit Service |
9646c7 |
ALL_RECURSIVE_TARGETS += alpha beta stable
|
|
Packit Service |
9646c7 |
alpha beta stable: $(local-check) writable-files $(submodule-checks)
|
|
Packit Service |
9646c7 |
test $@ = stable \
|
|
Packit Service |
9646c7 |
&& { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
|
|
Packit Service |
9646c7 |
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|
|
Packit Service |
9646c7 |
|| :
|
|
Packit Service |
9646c7 |
$(MAKE) vc-diff-check
|
|
Packit Service |
9646c7 |
$(MAKE) news-check
|
|
Packit Service |
9646c7 |
$(MAKE) distcheck
|
|
Packit Service |
9646c7 |
$(MAKE) dist
|
|
Packit Service |
9646c7 |
$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
|
|
Packit Service |
9646c7 |
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Override this in cfg.mk if you follow different procedures.
|
|
Packit Service |
9646c7 |
release-prep-hook ?= release-prep
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?]
|
|
Packit Service |
9646c7 |
.PHONY: release-prep
|
|
Packit Service |
9646c7 |
release-prep:
|
|
Packit Service |
9646c7 |
case $$RELEASE_TYPE in alpha|beta|stable) ;; \
|
|
Packit Service |
9646c7 |
*) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
|
|
Packit Service |
9646c7 |
$(MAKE) --no-print-directory -s announcement > ~/announce-$(my_distdir)
|
|
Packit Service |
9646c7 |
if test -d $(release_archive_dir); then \
|
|
Packit Service |
9646c7 |
ln $(rel-files) $(release_archive_dir); \
|
|
Packit Service |
9646c7 |
chmod a-w $(rel-files); \
|
|
Packit Service |
9646c7 |
fi
|
|
Packit Service |
9646c7 |
echo $(VERSION) > $(prev_version_file)
|
|
Packit Service |
9646c7 |
$(MAKE) update-NEWS-hash
|
|
Packit Service |
9646c7 |
perl -pi -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' NEWS
|
|
Packit Service |
9646c7 |
$(emit-commit-log) > .ci-msg
|
|
Packit Service |
9646c7 |
$(VC) commit -F .ci-msg -a
|
|
Packit Service |
9646c7 |
rm .ci-msg
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Override this with e.g., -s $(srcdir)/some_other_name.texi
|
|
Packit Service |
9646c7 |
# if the default $(PACKAGE)-derived name doesn't apply.
|
|
Packit Service |
9646c7 |
gendocs_options_ ?=
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
.PHONY: web-manual
|
|
Packit Service |
9646c7 |
web-manual:
|
|
Packit Service |
9646c7 |
@test -z "$(manual_title)" \
|
|
Packit Service |
9646c7 |
&& { echo define manual_title in cfg.mk 1>&2; exit 1; } || :
|
|
Packit Service |
9646c7 |
@cd '$(srcdir)/doc'; \
|
|
Packit Service |
9646c7 |
$(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \
|
|
Packit Service |
9646c7 |
-o '$(abs_builddir)/doc/manual' \
|
|
Packit Service |
9646c7 |
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \
|
|
Packit Service |
9646c7 |
"$(PACKAGE_NAME) - $(manual_title)"
|
|
Packit Service |
9646c7 |
@echo " *** Upload the doc/manual directory to web-cvs."
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Code Coverage
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
init-coverage:
|
|
Packit Service |
9646c7 |
$(MAKE) $(AM_MAKEFLAGS) clean
|
|
Packit Service |
9646c7 |
lcov --directory . --zerocounters
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
COVERAGE_CCOPTS ?= "-g --coverage"
|
|
Packit Service |
9646c7 |
COVERAGE_OUT ?= doc/coverage
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
build-coverage:
|
|
Packit Service |
9646c7 |
$(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS)
|
|
Packit Service |
9646c7 |
$(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check
|
|
Packit Service |
9646c7 |
mkdir -p $(COVERAGE_OUT)
|
|
Packit Service |
9646c7 |
lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \
|
|
Packit Service |
9646c7 |
--capture
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
gen-coverage:
|
|
Packit Service |
9646c7 |
genhtml --output-directory $(COVERAGE_OUT) \
|
|
Packit Service |
9646c7 |
$(COVERAGE_OUT)/$(PACKAGE).info \
|
|
Packit Service |
9646c7 |
--highlight --frames --legend \
|
|
Packit Service |
9646c7 |
--title "$(PACKAGE_NAME)"
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
coverage: init-coverage build-coverage gen-coverage
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Update gettext files.
|
|
Packit Service |
9646c7 |
PACKAGE ?= $(shell basename $(PWD))
|
|
Packit Service |
9646c7 |
PO_DOMAIN ?= $(PACKAGE)
|
|
Packit Service |
9646c7 |
POURL = http://translationproject.org/latest/$(PO_DOMAIN)/
|
|
Packit Service |
9646c7 |
PODIR ?= po
|
|
Packit Service |
9646c7 |
refresh-po:
|
|
Packit Service |
9646c7 |
rm -f $(PODIR)/*.po && \
|
|
Packit Service |
9646c7 |
echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
|
|
Packit Service |
9646c7 |
wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
|
|
Packit Service |
9646c7 |
echo 'en@boldquot' > $(PODIR)/LINGUAS && \
|
|
Packit Service |
9646c7 |
echo 'en@quot' >> $(PODIR)/LINGUAS && \
|
|
Packit Service |
9646c7 |
ls $(PODIR)/*.po | sed 's/\.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Running indent once is not idempotent, but running it twice is.
|
|
Packit Service |
9646c7 |
INDENT_SOURCES ?= $(C_SOURCES)
|
|
Packit Service |
9646c7 |
.PHONY: indent
|
|
Packit Service |
9646c7 |
indent:
|
|
Packit Service |
9646c7 |
indent $(INDENT_SOURCES)
|
|
Packit Service |
9646c7 |
indent $(INDENT_SOURCES)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# If you want to set UPDATE_COPYRIGHT_* environment variables,
|
|
Packit Service |
9646c7 |
# put the assignments in this variable.
|
|
Packit Service |
9646c7 |
update-copyright-env ?=
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Run this rule once per year (usually early in January)
|
|
Packit Service |
9646c7 |
# to update all FSF copyright year lists in your project.
|
|
Packit Service |
9646c7 |
# If you have an additional project-specific rule,
|
|
Packit Service |
9646c7 |
# add it in cfg.mk along with a line 'update-copyright: prereq'.
|
|
Packit Service |
9646c7 |
# By default, exclude all variants of COPYING; you can also
|
|
Packit Service |
9646c7 |
# add exemptions (such as ChangeLog..* for rotated change logs)
|
|
Packit Service |
9646c7 |
# in the file .x-update-copyright.
|
|
Packit Service |
9646c7 |
.PHONY: update-copyright
|
|
Packit Service |
9646c7 |
update-copyright:
|
|
Packit Service |
9646c7 |
grep -l -w Copyright \
|
|
Packit Service |
9646c7 |
$$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \
|
|
Packit Service |
9646c7 |
| $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
|
|
Packit Service |
9646c7 |
# overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# NOTE: to override any _gl_TS_* default value, you must
|
|
Packit Service |
9646c7 |
# define the variable(s) using "export" in cfg.mk.
|
|
Packit Service |
9646c7 |
_gl_TS_dir ?= src
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ALL_RECURSIVE_TARGETS += sc_tight_scope
|
|
Packit Service |
9646c7 |
sc_tight_scope: tight-scope.mk
|
|
Packit Service |
9646c7 |
@fail=0; \
|
|
Packit Service |
9646c7 |
if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \
|
|
Packit Service |
9646c7 |
> /dev/null \
|
|
Packit Service |
9646c7 |
&& ! grep -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
|
|
Packit Service |
9646c7 |
> /dev/null 2>&1; then \
|
|
Packit Service |
9646c7 |
echo '$(ME): skipping $@'; \
|
|
Packit Service |
9646c7 |
else \
|
|
Packit Service |
9646c7 |
$(MAKE) -s -C $(_gl_TS_dir) \
|
|
Packit Service |
9646c7 |
-f Makefile \
|
|
Packit Service |
9646c7 |
-f $(abs_top_srcdir)/cfg.mk \
|
|
Packit Service |
9646c7 |
-f $(abs_top_builddir)/$< \
|
|
Packit Service |
9646c7 |
_gl_tight_scope \
|
|
Packit Service |
9646c7 |
|| fail=1; \
|
|
Packit Service |
9646c7 |
fi; \
|
|
Packit Service |
9646c7 |
rm -f $<; \
|
|
Packit Service |
9646c7 |
exit $$fail
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
tight-scope.mk: $(ME)
|
|
Packit Service |
9646c7 |
@rm -f $@ $@-t
|
|
Packit Service |
9646c7 |
@perl -ne '/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME) > $@-t
|
|
Packit Service |
9646c7 |
@chmod a=r $@-t && mv $@-t $@
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
ifeq (a,b)
|
|
Packit Service |
9646c7 |
# TS-start
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Most functions should have static scope.
|
|
Packit Service |
9646c7 |
# Any that don't must be marked with 'extern', but 'main'
|
|
Packit Service |
9646c7 |
# and 'usage' are exceptions: they're always extern, but
|
|
Packit Service |
9646c7 |
# do not need to be marked. Symbols matching '__.*' are
|
|
Packit Service |
9646c7 |
# reserved by the compiler, so are automatically excluded below.
|
|
Packit Service |
9646c7 |
_gl_TS_unmarked_extern_functions ?= main usage
|
|
Packit Service |
9646c7 |
_gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\S+) *\(/
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# If your project uses a macro like "XTERN", then put
|
|
Packit Service |
9646c7 |
# the following in cfg.mk to override this default:
|
|
Packit Service |
9646c7 |
# export _gl_TS_extern = extern|XTERN
|
|
Packit Service |
9646c7 |
_gl_TS_extern ?= extern
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# The second nm|grep checks for file-scope variables with 'extern' scope.
|
|
Packit Service |
9646c7 |
# Without gnulib's progname module, you might put program_name here.
|
|
Packit Service |
9646c7 |
# Symbols matching '__.*' are reserved by the compiler,
|
|
Packit Service |
9646c7 |
# so are automatically excluded below.
|
|
Packit Service |
9646c7 |
_gl_TS_unmarked_extern_vars ?=
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# NOTE: the _match variables are perl expressions -- not mere regular
|
|
Packit Service |
9646c7 |
# expressions -- so that you can extend them to match other patterns
|
|
Packit Service |
9646c7 |
# and easily extract matched variable names.
|
|
Packit Service |
9646c7 |
# For example, if your project declares some global variables via
|
|
Packit Service |
9646c7 |
# a macro like this: GLOBAL(type, var_name, initializer), then you
|
|
Packit Service |
9646c7 |
# can override this definition to automatically extract those names:
|
|
Packit Service |
9646c7 |
# export _gl_TS_var_match = \
|
|
Packit Service |
9646c7 |
# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
|
|
Packit Service |
9646c7 |
_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# The names of object files in (or relative to) $(_gl_TS_dir).
|
|
Packit Service |
9646c7 |
_gl_TS_obj_files ?= *.$(OBJEXT)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
# Files in which to search for the one-line style extern declarations.
|
|
Packit Service |
9646c7 |
# $(_gl_TS_dir)-relative.
|
|
Packit Service |
9646c7 |
_gl_TS_headers ?= $(noinst_HEADERS)
|
|
Packit Service |
9646c7 |
|
|
Packit Service |
9646c7 |
.PHONY: _gl_tight_scope
|
|
Packit Service |
9646c7 |
_gl_tight_scope: $(bin_PROGRAMS)
|
|
Packit Service |
9646c7 |
t=exceptions-$$$$; \
|
|
Packit Service |
9646c7 |
trap 's=$$?; rm -f $$t; exit $$s' 0; \
|
|
Packit Service |
9646c7 |
for sig in 1 2 3 13 15; do \
|
|
Packit Service |
9646c7 |
eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
|
|
Packit Service |
9646c7 |
done; \
|
|
Packit Service |
9646c7 |
src=`for f in $(SOURCES); do \
|
|
Packit Service |
9646c7 |
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
|
Packit Service |
9646c7 |
hdr=`for f in $(_gl_TS_headers); do \
|
|
Packit Service |
9646c7 |
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
|
Packit Service |
9646c7 |
( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_functions); \
|
|
Packit Service |
9646c7 |
grep -h -A1 '^extern .*[^;]$$' $$src \
|
|
Packit Service |
9646c7 |
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
|
|
Packit Service |
9646c7 |
perl -lne \
|
|
Packit Service |
9646c7 |
'$(_gl_TS_function_match) and print "^$$1\$$"' $$hdr; \
|
|
Packit Service |
9646c7 |
) | sort -u > $$t; \
|
|
Packit Service |
9646c7 |
nm -e $(_gl_TS_obj_files) | sed -n 's/.* T //p'|grep -Ev -f $$t \
|
|
Packit Service |
9646c7 |
&& { echo the above functions should have static scope >&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || : ; \
|
|
Packit Service |
9646c7 |
( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars); \
|
|
Packit Service |
9646c7 |
perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' $$hdr *.h \
|
|
Packit Service |
9646c7 |
) | sort -u > $$t; \
|
|
Packit Service |
9646c7 |
nm -e $(_gl_TS_obj_files) | sed -n 's/.* [BCDGRS] //p' \
|
|
Packit Service |
9646c7 |
| sort -u | grep -Ev -f $$t \
|
|
Packit Service |
9646c7 |
&& { echo the above variables should have static scope >&2; \
|
|
Packit Service |
9646c7 |
exit 1; } || :
|
|
Packit Service |
9646c7 |
# TS-end
|
|
Packit Service |
9646c7 |
endif
|