|
0 |
# -*-Makefile-*-
|
|
1 |
# This Makefile fragment tries to be general-purpose enough to be
|
|
2 |
# used by many projects via the gnulib maintainer-makefile module.
|
|
3 |
|
|
4 |
## Copyright (C) 2001-2011 Free Software Foundation, Inc.
|
|
5 |
##
|
|
6 |
## This program is free software: you can redistribute it and/or modify
|
|
7 |
## it under the terms of the GNU General Public License as published by
|
|
8 |
## the Free Software Foundation, either version 3 of the License, or
|
|
9 |
## (at your option) any later version.
|
|
10 |
##
|
|
11 |
## This program is distributed in the hope that it will be useful,
|
|
12 |
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
## GNU General Public License for more details.
|
|
15 |
##
|
|
16 |
## You should have received a copy of the GNU General Public License
|
|
17 |
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18 |
|
|
19 |
# This is reported not to work with make-3.79.1
|
|
20 |
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
|
21 |
ME := maint.mk
|
|
22 |
|
|
23 |
# Diagnostic for continued use of deprecated variable.
|
|
24 |
# Remove in 2013
|
|
25 |
ifneq ($(build_aux),)
|
|
26 |
$(error "$(ME): \
|
|
27 |
set $$(_build-aux) relative to $$(srcdir) instead of $$(build_aux)")
|
|
28 |
endif
|
|
29 |
|
|
30 |
# Do not save the original name or timestamp in the .tar.gz file.
|
|
31 |
# Use --rsyncable if available.
|
|
32 |
gzip_rsyncable := \
|
|
33 |
$(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null \
|
|
34 |
&& printf %s --rsyncable)
|
|
35 |
GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
|
|
36 |
|
|
37 |
GIT = git
|
|
38 |
VC = $(GIT)
|
|
39 |
|
|
40 |
VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir)
|
|
41 |
|
|
42 |
# You can override this variable in cfg.mk to set your own regexp
|
|
43 |
# matching files to ignore.
|
|
44 |
VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$
|
|
45 |
|
|
46 |
# This is to preprocess robustly the output of $(VC_LIST), so that even
|
|
47 |
# when $(srcdir) is a pathological name like "....", the leading sed command
|
|
48 |
# removes only the intended prefix.
|
|
49 |
_dot_escaped_srcdir = $(subst .,\.,$(srcdir))
|
|
50 |
|
|
51 |
# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
|
|
52 |
# when $(srcdir) is not ".".
|
|
53 |
ifeq ($(srcdir),.)
|
|
54 |
_prepend_srcdir_prefix =
|
|
55 |
else
|
|
56 |
_prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
|
|
57 |
endif
|
|
58 |
|
|
59 |
# In order to be able to consistently filter "."-relative names,
|
|
60 |
# (i.e., with no $(srcdir) prefix), this definition is careful to
|
|
61 |
# remove any $(srcdir) prefix, and to restore what it removes.
|
|
62 |
_sc_excl = \
|
|
63 |
$(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
|
|
64 |
VC_LIST_EXCEPT = \
|
|
65 |
$(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
|
|
66 |
| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
|
|
67 |
else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
|
|
68 |
| grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
|
|
69 |
$(_prepend_srcdir_prefix)
|
|
70 |
|
|
71 |
ifeq ($(origin prev_version_file), undefined)
|
|
72 |
prev_version_file = $(srcdir)/.prev-version
|
|
73 |
endif
|
|
74 |
|
|
75 |
PREV_VERSION := $(shell cat $(prev_version_file) 2>/dev/null)
|
|
76 |
VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
|
77 |
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
|
|
78 |
|
|
79 |
ifeq ($(VC),$(GIT))
|
|
80 |
this-vc-tag = v$(VERSION)
|
|
81 |
this-vc-tag-regexp = v$(VERSION_REGEXP)
|
|
82 |
else
|
|
83 |
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
|
|
84 |
tag-this-version = $(subst .,_,$(VERSION))
|
|
85 |
this-vc-tag = $(tag-package)-$(tag-this-version)
|
|
86 |
this-vc-tag-regexp = $(this-vc-tag)
|
|
87 |
endif
|
|
88 |
my_distdir = $(PACKAGE)-$(VERSION)
|
|
89 |
|
|
90 |
# Old releases are stored here.
|
|
91 |
release_archive_dir ?= ../release
|
|
92 |
|
|
93 |
# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
|
|
94 |
# Use alpha.gnu.org for alpha and beta releases.
|
|
95 |
# Use ftp.gnu.org for stable releases.
|
|
96 |
gnu_ftp_host-alpha = alpha.gnu.org
|
|
97 |
gnu_ftp_host-beta = alpha.gnu.org
|
|
98 |
gnu_ftp_host-stable = ftp.gnu.org
|
|
99 |
gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE))
|
|
100 |
|
|
101 |
ifeq ($(gnu_rel_host),ftp.gnu.org)
|
|
102 |
url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE)
|
|
103 |
else
|
|
104 |
url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
|
|
105 |
endif
|
|
106 |
|
|
107 |
# Override this in cfg.mk if you are using a different format in your
|
|
108 |
# NEWS file.
|
|
109 |
today = $(shell date +%Y-%m-%d)
|
|
110 |
|
|
111 |
# Select which lines of NEWS are searched for $(news-check-regexp).
|
|
112 |
# This is a sed line number spec. The default says that we search
|
|
113 |
# lines 1..10 of NEWS for $(news-check-regexp).
|
|
114 |
# If you want to search only line 3 or only lines 20-22, use "3" or "20,22".
|
|
115 |
news-check-lines-spec ?= 1,10
|
|
116 |
news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
|
|
117 |
|
|
118 |
# Prevent programs like 'sort' from considering distinct strings to be equal.
|
|
119 |
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
|
|
120 |
export LC_ALL = C
|
|
121 |
|
|
122 |
## --------------- ##
|
|
123 |
## Sanity checks. ##
|
|
124 |
## --------------- ##
|
|
125 |
|
|
126 |
_cfg_mk := $(shell test -f $(srcdir)/cfg.mk && echo '$(srcdir)/cfg.mk')
|
|
127 |
|
|
128 |
# Collect the names of rules starting with `sc_'.
|
|
129 |
syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
|
|
130 |
$(srcdir)/$(ME) $(_cfg_mk)))
|
|
131 |
.PHONY: $(syntax-check-rules)
|
|
132 |
|
|
133 |
ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0)
|
|
134 |
local-checks-available += $(syntax-check-rules)
|
|
135 |
else
|
|
136 |
local-checks-available += no-vc-detected
|
|
137 |
no-vc-detected:
|
|
138 |
@echo "No version control files detected; skipping syntax check"
|
|
139 |
endif
|
|
140 |
.PHONY: $(local-checks-available)
|
|
141 |
|
|
142 |
# Arrange to print the name of each syntax-checking rule just before running it.
|
|
143 |
$(syntax-check-rules): %: %.m
|
|
144 |
sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
|
|
145 |
.PHONY: $(sc_m_rules_)
|
|
146 |
$(sc_m_rules_):
|
|
147 |
@echo $(patsubst sc_%.m, %, $@)
|
|
148 |
@date +%s.%N > .sc-start-$(basename $@)
|
|
149 |
|
|
150 |
# Compute and print the elapsed time for each syntax-check rule.
|
|
151 |
sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules))
|
|
152 |
.PHONY: $(sc_z_rules_)
|
|
153 |
$(sc_z_rules_): %.z: %
|
|
154 |
@end=$$(date +%s.%N); \
|
|
155 |
start=$$(cat .sc-start-$*); \
|
|
156 |
rm -f .sc-start-$*; \
|
|
157 |
awk -v s=$$start -v e=$$end \
|
|
158 |
'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null
|
|
159 |
|
|
160 |
# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
|
|
161 |
# that computes and prints elapsed time.
|
|
162 |
local-check := \
|
|
163 |
$(patsubst sc_%, sc_%.z, \
|
|
164 |
$(filter-out $(local-checks-to-skip), $(local-checks-available)))
|
|
165 |
|
|
166 |
syntax-check: $(local-check)
|
|
167 |
|
|
168 |
# _sc_search_regexp
|
|
169 |
#
|
|
170 |
# This macro searches for a given construct in the selected files and
|
|
171 |
# then takes some action.
|
|
172 |
#
|
|
173 |
# Parameters (shell variables):
|
|
174 |
#
|
|
175 |
# prohibit | require
|
|
176 |
#
|
|
177 |
# Regular expression (ERE) denoting either a forbidden construct
|
|
178 |
# or a required construct. Those arguments are exclusive.
|
|
179 |
#
|
|
180 |
# in_vc_files | in_files
|
|
181 |
#
|
|
182 |
# grep-E-style regexp denoting the files to check. If no files
|
|
183 |
# are specified the default are all the files that are under
|
|
184 |
# version control.
|
|
185 |
#
|
|
186 |
# containing | non_containing
|
|
187 |
#
|
|
188 |
# Select the files (non) containing strings matching this regexp.
|
|
189 |
# If both arguments are specified then CONTAINING takes
|
|
190 |
# precedence.
|
|
191 |
#
|
|
192 |
# with_grep_options
|
|
193 |
#
|
|
194 |
# Extra options for grep.
|
|
195 |
#
|
|
196 |
# ignore_case
|
|
197 |
#
|
|
198 |
# Ignore case.
|
|
199 |
#
|
|
200 |
# halt
|
|
201 |
#
|
|
202 |
# Message to display before to halting execution.
|
|
203 |
#
|
|
204 |
# Finally, you may exempt files based on an ERE matching file names.
|
|
205 |
# For example, to exempt from the sc_space_tab check all files with the
|
|
206 |
# .diff suffix, set this Make variable:
|
|
207 |
#
|
|
208 |
# exclude_file_name_regexp--sc_space_tab = \.diff$
|
|
209 |
#
|
|
210 |
# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
|
|
211 |
# when filtering by name via in_files, we explicitly filter out matching
|
|
212 |
# names here as well.
|
|
213 |
|
|
214 |
# By default, _sc_search_regexp does not ignore case.
|
|
215 |
export ignore_case =
|
|
216 |
_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :)
|
|
217 |
|
|
218 |
define _sc_say_and_exit
|
|
219 |
dummy=; : so we do not need a semicolon before each use; \
|
|
220 |
{ printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; };
|
|
221 |
endef
|
|
222 |
|
|
223 |
# _sc_search_regexp used to be named _prohibit_regexp. However,
|
|
224 |
# upgrading to the new definition and leaving the old name undefined
|
|
225 |
# would usually convert each custom rule using $(_prohibit_regexp)
|
|
226 |
# (usually defined in cfg.mk) into a no-op. This definition ensures
|
|
227 |
# that people know right away if they're still using the old name.
|
|
228 |
# FIXME: remove in 2012.
|
|
229 |
_prohibit_regexp = \
|
|
230 |
$(error '*** you need to s/_prohibit_regexp/_sc_search_regexp/, and adapt')
|
|
231 |
|
|
232 |
define _sc_search_regexp
|
|
233 |
dummy=; : so we do not need a semicolon before each use; \
|
|
234 |
\
|
|
235 |
: Check arguments; \
|
|
236 |
test -n "$$prohibit" && test -n "$$require" \
|
|
237 |
&& { msg='Cannot specify both prohibit and require' \
|
|
238 |
$(_sc_say_and_exit) } || :; \
|
|
239 |
test -z "$$prohibit" && test -z "$$require" \
|
|
240 |
&& { msg='Should specify either prohibit or require' \
|
|
241 |
$(_sc_say_and_exit) } || :; \
|
|
242 |
test -n "$$in_vc_files" && test -n "$$in_files" \
|
|
243 |
&& { msg='Cannot specify both in_vc_files and in_files' \
|
|
244 |
$(_sc_say_and_exit) } || :; \
|
|
245 |
test "x$$halt" != x \
|
|
246 |
|| { msg='halt not defined' $(_sc_say_and_exit) }; \
|
|
247 |
\
|
|
248 |
: Filter by file name; \
|
|
249 |
if test -n "$$in_files"; then \
|
|
250 |
files=$$(find $(srcdir) | grep -E "$$in_files" \
|
|
251 |
| grep -Ev '$(exclude_file_name_regexp--$@)'); \
|
|
252 |
else \
|
|
253 |
files=$$($(VC_LIST_EXCEPT)); \
|
|
254 |
if test -n "$$in_vc_files"; then \
|
|
255 |
files=$$(echo "$$files" | grep -E "$$in_vc_files"); \
|
|
256 |
fi; \
|
|
257 |
fi; \
|
|
258 |
\
|
|
259 |
: Filter by content; \
|
|
260 |
test -n "$$files" && test -n "$$containing" \
|
|
261 |
&& { files=$$(grep -l "$$containing" $$files); } || :; \
|
|
262 |
test -n "$$files" && test -n "$$non_containing" \
|
|
263 |
&& { files=$$(grep -vl "$$non_containing" $$files); } || :; \
|
|
264 |
\
|
|
265 |
: Check for the construct; \
|
|
266 |
if test -n "$$files"; then \
|
|
267 |
if test -n "$$prohibit"; then \
|
|
268 |
grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
|
|
269 |
&& { msg="$$halt" $(_sc_say_and_exit) } || :; \
|
|
270 |
else \
|
|
271 |
grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
|
|
272 |
| grep . \
|
|
273 |
&& { msg="$$halt" $(_sc_say_and_exit) } || :; \
|
|
274 |
fi \
|
|
275 |
else :; \
|
|
276 |
fi || :;
|
|
277 |
endef
|
|
278 |
|
|
279 |
sc_avoid_if_before_free:
|
|
280 |
@$(srcdir)/$(_build-aux)/useless-if-before-free \
|
|
281 |
$(useless_free_options) \
|
|
282 |
$$($(VC_LIST_EXCEPT) | grep -v useless-if-before-free) && \
|
|
283 |
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
|
|
284 |
exit 1; } || :
|
|
285 |
|
|
286 |
sc_cast_of_argument_to_free:
|
|
287 |
@prohibit='\<free *\( *\(' halt='don'\''t cast free argument' \
|
|
288 |
$(_sc_search_regexp)
|
|
289 |
|
|
290 |
sc_cast_of_x_alloc_return_value:
|
|
291 |
@prohibit='\*\) *x(m|c|re)alloc\>' \
|
|
292 |
halt='don'\''t cast x*alloc return value' \
|
|
293 |
$(_sc_search_regexp)
|
|
294 |
|
|
295 |
sc_cast_of_alloca_return_value:
|
|
296 |
@prohibit='\*\) *alloca\>' \
|
|
297 |
halt='don'\''t cast alloca return value' \
|
|
298 |
$(_sc_search_regexp)
|
|
299 |
|
|
300 |
sc_space_tab:
|
|
301 |
@prohibit='[ ] ' \
|
|
302 |
halt='found SPACE-TAB sequence; remove the SPACE' \
|
|
303 |
$(_sc_search_regexp)
|
|
304 |
|
|
305 |
# Don't use *scanf or the old ato* functions in `real' code.
|
|
306 |
# They provide no error checking mechanism.
|
|
307 |
# Instead, use strto* functions.
|
|
308 |
sc_prohibit_atoi_atof:
|
|
309 |
@prohibit='\<([fs]?scanf|ato([filq]|ll)) *\(' \
|
|
310 |
halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
|
|
311 |
$(_sc_search_regexp)
|
|
312 |
|
|
313 |
# Use STREQ rather than comparing strcmp == 0, or != 0.
|
|
314 |
sc_prohibit_strcmp:
|
|
315 |
@grep -nE '! *str''cmp *\(|\<str''cmp *\(.+\) *[!=]=' \
|
|
316 |
$$($(VC_LIST_EXCEPT)) \
|
|
317 |
| grep -vE ':# *define STRN?EQ\(' && \
|
|
318 |
{ echo '$(ME): replace str''cmp calls above with STREQ/STRNEQ' \
|
|
319 |
1>&2; exit 1; } || :
|
|
320 |
|
|
321 |
# Pass EXIT_*, not number, to usage, exit, and error (when exiting)
|
|
322 |
# Convert all uses automatically, via these two commands:
|
|
323 |
# git grep -l '\<exit *(1)' \
|
|
324 |
# | grep -vEf .x-sc_prohibit_magic_number_exit \
|
|
325 |
# | xargs --no-run-if-empty \
|
|
326 |
# perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
|
|
327 |
# git grep -l '\<exit *(0)' \
|
|
328 |
# | grep -vEf .x-sc_prohibit_magic_number_exit \
|
|
329 |
# | xargs --no-run-if-empty \
|
|
330 |
# perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
|
|
331 |
sc_prohibit_magic_number_exit:
|
|
332 |
@prohibit='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
|
|
333 |
halt='use EXIT_* values rather than magic number' \
|
|
334 |
$(_sc_search_regexp)
|
|
335 |
|
|
336 |
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
|
337 |
# since when that parameter is 0, error does not exit. Use `0' instead.
|
|
338 |
sc_error_exit_success:
|
|
339 |
@prohibit='error *\(EXIT_SUCCESS,' \
|
|
340 |
in_vc_files='\.[chly]$$' \
|
|
341 |
halt='found error (EXIT_SUCCESS' \
|
|
342 |
$(_sc_search_regexp)
|
|
343 |
|
|
344 |
# `FATAL:' should be fully upper-cased in error messages
|
|
345 |
# `WARNING:' should be fully upper-cased, or fully lower-cased
|
|
346 |
sc_error_message_warn_fatal:
|
|
347 |
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
|
|
348 |
| grep -E '"Warning|"Fatal|"fatal' && \
|
|
349 |
{ echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
|
|
350 |
exit 1; } || :
|
|
351 |
|
|
352 |
# Error messages should not start with a capital letter
|
|
353 |
sc_error_message_uppercase:
|
|
354 |
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
|
|
355 |
| grep -E '"[A-Z]' \
|
|
356 |
| grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
|
|
357 |
{ echo '$(ME): found capitalized error message' 1>&2; \
|
|
358 |
exit 1; } || :
|
|
359 |
|
|
360 |
# Error messages should not end with a period
|
|
361 |
sc_error_message_period:
|
|
362 |
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
|
|
363 |
| grep -E '[^."]\."' && \
|
|
364 |
{ echo '$(ME): found error message ending in period' 1>&2; \
|
|
365 |
exit 1; } || :
|
|
366 |
|
|
367 |
sc_file_system:
|
|
368 |
@prohibit=file''system \
|
|
369 |
ignore_case=1 \
|
|
370 |
halt='found use of "file''system"; spell it "file system"' \
|
|
371 |
$(_sc_search_regexp)
|
|
372 |
|
|
373 |
# Don't use cpp tests of this symbol. All code assumes config.h is included.
|
|
374 |
sc_prohibit_have_config_h:
|
|
375 |
@prohibit='^# *if.*HAVE''_CONFIG_H' \
|
|
376 |
halt='found use of HAVE''_CONFIG_H; remove' \
|
|
377 |
$(_sc_search_regexp)
|
|
378 |
|
|
379 |
# Nearly all .c files must include <config.h>. However, we also permit this
|
|
380 |
# via inclusion of a package-specific header, if cfg.mk specified one.
|
|
381 |
# config_h_header must be suitable for grep -E.
|
|
382 |
config_h_header ?= <config\.h>
|
|
383 |
sc_require_config_h:
|
|
384 |
@require='^# *include $(config_h_header)' \
|
|
385 |
in_vc_files='\.c$$' \
|
|
386 |
halt='the above files do not include <config.h>' \
|
|
387 |
$(_sc_search_regexp)
|
|
388 |
|
|
389 |
# You must include <config.h> before including any other header file.
|
|
390 |
# This can possibly be via a package-specific header, if given by cfg.mk.
|
|
391 |
sc_require_config_h_first:
|
|
392 |
@if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
|
|
393 |
fail=0; \
|
|
394 |
for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
|
|
395 |
grep '^# *include\>' $$i | sed 1q \
|
|
396 |
| grep -E '^# *include $(config_h_header)' > /dev/null \
|
|
397 |
|| { echo $$i; fail=1; }; \
|
|
398 |
done; \
|
|
399 |
test $$fail = 1 && \
|
|
400 |
{ echo '$(ME): the above files include some other header' \
|
|
401 |
'before <config.h>' 1>&2; exit 1; } || :; \
|
|
402 |
else :; \
|
|
403 |
fi
|
|
404 |
|
|
405 |
sc_prohibit_HAVE_MBRTOWC:
|
|
406 |
@prohibit='\bHAVE_MBRTOWC\b' \
|
|
407 |
halt="do not use $$prohibit; it is always defined" \
|
|
408 |
$(_sc_search_regexp)
|
|
409 |
|
|
410 |
# To use this "command" macro, you must first define two shell variables:
|
|
411 |
# h: the header name, with no enclosing <> or ""
|
|
412 |
# re: a regular expression that matches IFF something provided by $h is used.
|
|
413 |
define _sc_header_without_use
|
|
414 |
dummy=; : so we do not need a semicolon before each use; \
|
|
415 |
h_esc=`echo '[<"]'"$$h"'[">]'|sed 's/\./\\\\./g'`; \
|
|
416 |
if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
|
|
417 |
files=$$(grep -l '^# *include '"$$h_esc" \
|
|
418 |
$$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
|
|
419 |
grep -LE "$$re" $$files | grep . && \
|
|
420 |
{ echo "$(ME): the above files include $$h but don't use it" \
|
|
421 |
1>&2; exit 1; } || :; \
|
|
422 |
else :; \
|
|
423 |
fi
|
|
424 |
endef
|
|
425 |
|
|
426 |
# Prohibit the inclusion of assert.h without an actual use of assert.
|
|
427 |
sc_prohibit_assert_without_use:
|
|
428 |
@h='assert.h' re='\<assert *\(' $(_sc_header_without_use)
|
|
429 |
|
|
430 |
# Prohibit the inclusion of close-stream.h without an actual use.
|
|
431 |
sc_prohibit_close_stream_without_use:
|
|
432 |
@h='close-stream.h' re='\<close_stream *\(' $(_sc_header_without_use)
|
|
433 |
|
|
434 |
# Prohibit the inclusion of getopt.h without an actual use.
|
|
435 |
sc_prohibit_getopt_without_use:
|
|
436 |
@h='getopt.h' re='\<getopt(_long)? *\(' $(_sc_header_without_use)
|
|
437 |
|
|
438 |
# Don't include quotearg.h unless you use one of its functions.
|
|
439 |
sc_prohibit_quotearg_without_use:
|
|
440 |
@h='quotearg.h' re='\<quotearg(_[^ ]+)? *\(' $(_sc_header_without_use)
|
|
441 |
|
|
442 |
# Don't include quote.h unless you use one of its functions.
|
|
443 |
sc_prohibit_quote_without_use:
|
|
444 |
@h='quote.h' re='\<quote(_n)? *\(' $(_sc_header_without_use)
|
|
445 |
|
|
446 |
# Don't include this header unless you use one of its functions.
|
|
447 |
sc_prohibit_long_options_without_use:
|
|
448 |
@h='long-options.h' re='\<parse_long_options *\(' \
|
|
449 |
$(_sc_header_without_use)
|
|
450 |
|
|
451 |
# Don't include this header unless you use one of its functions.
|
|
452 |
sc_prohibit_inttostr_without_use:
|
|
453 |
@h='inttostr.h' re='\<(off|[iu]max|uint)tostr *\(' \
|
|
454 |
$(_sc_header_without_use)
|
|
455 |
|
|
456 |
# Don't include this header unless you use one of its functions.
|
|
457 |
sc_prohibit_ignore_value_without_use:
|
|
458 |
@h='ignore-value.h' re='\<ignore_(value|ptr) *\(' \
|
|
459 |
$(_sc_header_without_use)
|
|
460 |
|
|
461 |
# Don't include this header unless you use one of its functions.
|
|
462 |
sc_prohibit_error_without_use:
|
|
463 |
@h='error.h' \
|
|
464 |
re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
|
|
465 |
$(_sc_header_without_use)
|
|
466 |
|
|
467 |
# Don't include xalloc.h unless you use one of its functions.
|
|
468 |
# Consider these symbols:
|
|
469 |
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
|
|
470 |
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
|
|
471 |
# Divide into two sets on case, and filter each through this:
|
|
472 |
# | sort | perl -MRegexp::Assemble -le \
|
|
473 |
# 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
|
|
474 |
# Note this was produced by the above:
|
|
475 |
# _xa1 = \
|
|
476 |
#x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
|
|
477 |
# But we can do better, in at least two ways:
|
|
478 |
# 1) take advantage of two "dup"-suffixed strings:
|
|
479 |
# x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
|
|
480 |
# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
|
|
481 |
# "char|[cmz]"
|
|
482 |
# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
|
|
483 |
_xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
|
|
484 |
_xa2 = X([CZ]|N?M)ALLOC
|
|
485 |
sc_prohibit_xalloc_without_use:
|
|
486 |
@h='xalloc.h' \
|
|
487 |
re='\<($(_xa1)|$(_xa2)) *\('\
|
|
488 |
$(_sc_header_without_use)
|
|
489 |
|
|
490 |
# Extract function names:
|
|
491 |
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
|
|
492 |
_hash_re = \
|
|
493 |
clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning
|
|
494 |
_hash_fn = \<($(_hash_re)) *\(
|
|
495 |
_hash_struct = (struct )?\<[Hh]ash_(table|tuning)\>
|
|
496 |
sc_prohibit_hash_without_use:
|
|
497 |
@h='hash.h' \
|
|
498 |
re='$(_hash_fn)|$(_hash_struct)'\
|
|
499 |
$(_sc_header_without_use)
|
|
500 |
|
|
501 |
sc_prohibit_cloexec_without_use:
|
|
502 |
@h='cloexec.h' re='\<(set_cloexec_flag|dup_cloexec) *\(' \
|
|
503 |
$(_sc_header_without_use)
|
|
504 |
|
|
505 |
sc_prohibit_posixver_without_use:
|
|
506 |
@h='posixver.h' re='\<posix2_version *\(' $(_sc_header_without_use)
|
|
507 |
|
|
508 |
sc_prohibit_same_without_use:
|
|
509 |
@h='same.h' re='\<same_name *\(' $(_sc_header_without_use)
|
|
510 |
|
|
511 |
sc_prohibit_hash_pjw_without_use:
|
|
512 |
@h='hash-pjw.h' \
|
|
513 |
re='\<hash_pjw *\(' \
|
|
514 |
$(_sc_header_without_use)
|
|
515 |
|
|
516 |
sc_prohibit_safe_read_without_use:
|
|
517 |
@h='safe-read.h' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
|
|
518 |
$(_sc_header_without_use)
|
|
519 |
|
|
520 |
sc_prohibit_argmatch_without_use:
|
|
521 |
@h='argmatch.h' \
|
|
522 |
re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \
|
|
523 |
$(_sc_header_without_use)
|
|
524 |
|
|
525 |
sc_prohibit_canonicalize_without_use:
|
|
526 |
@h='canonicalize.h' \
|
|
527 |
re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode)' \
|
|
528 |
$(_sc_header_without_use)
|
|
529 |
|
|
530 |
sc_prohibit_root_dev_ino_without_use:
|
|
531 |
@h='root-dev-ino.h' \
|
|
532 |
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
|
|
533 |
$(_sc_header_without_use)
|
|
534 |
|
|
535 |
sc_prohibit_openat_without_use:
|
|
536 |
@h='openat.h' \
|
|
537 |
re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
|
|
538 |
$(_sc_header_without_use)
|
|
539 |
|
|
540 |
# Prohibit the inclusion of c-ctype.h without an actual use.
|
|
541 |
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
|
|
542 |
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
|
|
543 |
sc_prohibit_c_ctype_without_use:
|
|
544 |
@h='c-ctype.h' re='\<c_($(ctype_re)) *\(' \
|
|
545 |
$(_sc_header_without_use)
|
|
546 |
|
|
547 |
_empty =
|
|
548 |
_sp = $(_empty) $(_empty)
|
|
549 |
# The following list was generated by running:
|
|
550 |
# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
|
|
551 |
# | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
|
|
552 |
_sig_functions = \
|
|
553 |
bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
|
|
554 |
sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
|
|
555 |
siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
|
|
556 |
sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
|
|
557 |
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
|
|
558 |
# The following were extracted from "man signal.h" manually.
|
|
559 |
_sig_types_and_consts = \
|
|
560 |
MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
|
|
561 |
SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
|
|
562 |
SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
|
|
563 |
SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
|
|
564 |
sigstack sigval stack_t ucontext_t
|
|
565 |
# generated via this:
|
|
566 |
# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
|
|
567 |
_sig_names = \
|
|
568 |
SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
|
|
569 |
SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
|
|
570 |
SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
|
|
571 |
SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
|
|
572 |
SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
|
|
573 |
SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
|
|
574 |
SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
|
|
575 |
SIGXCPU SIGXFSZ
|
|
576 |
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
|
|
577 |
|
|
578 |
# Prohibit the inclusion of signal.h without an actual use.
|
|
579 |
sc_prohibit_signal_without_use:
|
|
580 |
@h='signal.h' \
|
|
581 |
re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
|
|
582 |
$(_sc_header_without_use)
|
|
583 |
|
|
584 |
# Don't include stdio--.h unless you use one of its functions.
|
|
585 |
sc_prohibit_stdio--_without_use:
|
|
586 |
@h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\(' \
|
|
587 |
$(_sc_header_without_use)
|
|
588 |
|
|
589 |
# Don't include stdio-safer.h unless you use one of its functions.
|
|
590 |
sc_prohibit_stdio-safer_without_use:
|
|
591 |
@h='stdio-safer.h' re='\<((f(re)?|p)open|tmpfile)_safer *\(' \
|
|
592 |
$(_sc_header_without_use)
|
|
593 |
|
|
594 |
# Prohibit the inclusion of strings.h without a sensible use.
|
|
595 |
# Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible.
|
|
596 |
sc_prohibit_strings_without_use:
|
|
597 |
@h='strings.h' \
|
|
598 |
re='\<(strn?casecmp|ffs(ll)?)\>' \
|
|
599 |
$(_sc_header_without_use)
|
|
600 |
|
|
601 |
# Get the list of symbol names with this:
|
|
602 |
# perl -lne '/^# *define ([A-Z]\w+)\(/ and print $1' lib/intprops.h|fmt
|
|
603 |
_intprops_names = \
|
|
604 |
TYPE_IS_INTEGER TYPE_TWOS_COMPLEMENT TYPE_ONES_COMPLEMENT \
|
|
605 |
TYPE_SIGNED_MAGNITUDE TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM \
|
|
606 |
INT_BITS_STRLEN_BOUND INT_STRLEN_BOUND INT_BUFSIZE_BOUND \
|
|
607 |
INT_ADD_RANGE_OVERFLOW INT_SUBTRACT_RANGE_OVERFLOW \
|
|
608 |
INT_NEGATE_RANGE_OVERFLOW INT_MULTIPLY_RANGE_OVERFLOW \
|
|
609 |
INT_DIVIDE_RANGE_OVERFLOW INT_REMAINDER_RANGE_OVERFLOW \
|
|
610 |
INT_LEFT_SHIFT_RANGE_OVERFLOW INT_ADD_OVERFLOW INT_SUBTRACT_OVERFLOW \
|
|
611 |
INT_NEGATE_OVERFLOW INT_MULTIPLY_OVERFLOW INT_DIVIDE_OVERFLOW \
|
|
612 |
INT_REMAINDER_OVERFLOW INT_LEFT_SHIFT_OVERFLOW
|
|
613 |
_intprops_syms_re = $(subst $(_sp),|,$(strip $(_intprops_names)))
|
|
614 |
# Prohibit the inclusion of intprops.h without an actual use.
|
|
615 |
sc_prohibit_intprops_without_use:
|
|
616 |
@h='intprops.h' \
|
|
617 |
re='\<($(_intprops_syms_re)) *\(' \
|
|
618 |
$(_sc_header_without_use)
|
|
619 |
|
|
620 |
_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t
|
|
621 |
# Prohibit the inclusion of stddef.h without an actual use.
|
|
622 |
sc_prohibit_stddef_without_use:
|
|
623 |
@h='stddef.h' \
|
|
624 |
re='\<($(_stddef_syms_re))\>' \
|
|
625 |
$(_sc_header_without_use)
|
|
626 |
|
|
627 |
_de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)?
|
|
628 |
_de2 = (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(64)?
|
|
629 |
_de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
|
|
630 |
_dirent_syms_re = $(_de1)|$(_de2)|$(_de3)
|
|
631 |
# Prohibit the inclusion of dirent.h without an actual use.
|
|
632 |
sc_prohibit_dirent_without_use:
|
|
633 |
@h='dirent.h' \
|
|
634 |
re='\<($(_dirent_syms_re))\>' \
|
|
635 |
$(_sc_header_without_use)
|
|
636 |
|
|
637 |
# Prohibit the inclusion of verify.h without an actual use.
|
|
638 |
sc_prohibit_verify_without_use:
|
|
639 |
@h='verify.h' \
|
|
640 |
re='\<(verify(true|expr)?|static_assert) *\(' \
|
|
641 |
$(_sc_header_without_use)
|
|
642 |
|
|
643 |
# Don't include xfreopen.h unless you use one of its functions.
|
|
644 |
sc_prohibit_xfreopen_without_use:
|
|
645 |
@h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use)
|
|
646 |
|
|
647 |
sc_obsolete_symbols:
|
|
648 |
@prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
|
|
649 |
halt='do not use HAVE''_FCNTL_H or O'_NDELAY \
|
|
650 |
$(_sc_search_regexp)
|
|
651 |
|
|
652 |
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
|
|
653 |
|
|
654 |
# Each nonempty ChangeLog line must start with a year number, or a TAB.
|
|
655 |
sc_changelog:
|
|
656 |
@prohibit='^[^12 ]' \
|
|
657 |
in_vc_files='^ChangeLog$$' \
|
|
658 |
halt='found unexpected prefix in a ChangeLog' \
|
|
659 |
$(_sc_search_regexp)
|
|
660 |
|
|
661 |
# Ensure that each .c file containing a "main" function also
|
|
662 |
# calls set_program_name.
|
|
663 |
sc_program_name:
|
|
664 |
@require='set_program_name *\(m?argv\[0\]\);' \
|
|
665 |
in_vc_files='\.c$$' \
|
|
666 |
containing='\<main *(' \
|
|
667 |
halt='the above files do not call set_program_name' \
|
|
668 |
$(_sc_search_regexp)
|
|
669 |
|
|
670 |
# Ensure that each .c file containing a "main" function also
|
|
671 |
# calls bindtextdomain.
|
|
672 |
sc_bindtextdomain:
|
|
673 |
@require='bindtextdomain *\(' \
|
|
674 |
in_vc_files='\.c$$' \
|
|
675 |
containing='\<main *(' \
|
|
676 |
halt='the above files do not call bindtextdomain' \
|
|
677 |
$(_sc_search_regexp)
|
|
678 |
|
|
679 |
# Require that the final line of each test-lib.sh-using test be this one:
|
|
680 |
# Exit $fail
|
|
681 |
# Note: this test requires GNU grep's --label= option.
|
|
682 |
Exit_witness_file ?= tests/test-lib.sh
|
|
683 |
Exit_base := $(notdir $(Exit_witness_file))
|
|
684 |
sc_require_test_exit_idiom:
|
|
685 |
@if test -f $(srcdir)/$(Exit_witness_file); then \
|
|
686 |
die=0; \
|
|
687 |
for i in $$(grep -l -F 'srcdir/$(Exit_base)' \
|
|
688 |
$$($(VC_LIST) tests)); do \
|
|
689 |
tail -n1 $$i | grep '^Exit .' > /dev/null \
|
|
690 |
&& : || { die=1; echo $$i; } \
|
|
691 |
done; \
|
|
692 |
test $$die = 1 && \
|
|
693 |
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \
|
|
694 |
echo 1>&2 'Exit something'; \
|
|
695 |
exit 1; } || :; \
|
|
696 |
fi
|
|
697 |
|
|
698 |
sc_trailing_blank:
|
|
699 |
@prohibit='[ ]$$' \
|
|
700 |
halt='found trailing blank(s)' \
|
|
701 |
$(_sc_search_regexp)
|
|
702 |
|
|
703 |
# Match lines like the following, but where there is only one space
|
|
704 |
# between the options and the description:
|
|
705 |
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
|
|
706 |
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
|
|
707 |
sc_two_space_separator_in_usage:
|
|
708 |
@prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
|
|
709 |
halt='help2man requires at least two spaces between an option and its description'\
|
|
710 |
$(_sc_search_regexp)
|
|
711 |
|
|
712 |
# A regexp matching function names like "error" that may be used
|
|
713 |
# to emit translatable messages.
|
|
714 |
_gl_translatable_diag_func_re ?= error
|
|
715 |
|
|
716 |
# Look for diagnostics that aren't marked for translation.
|
|
717 |
# This won't find any for which error's format string is on a separate line.
|
|
718 |
sc_unmarked_diagnostics:
|
|
719 |
@grep -nE \
|
|
720 |
'\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
|
|
721 |
$$($(VC_LIST_EXCEPT)) \
|
|
722 |
| grep -Ev '(_|ngettext ?)\(' && \
|
|
723 |
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
|
|
724 |
exit 1; } || :
|
|
725 |
|
|
726 |
# Avoid useless parentheses like those in this example:
|
|
727 |
# #if defined (SYMBOL) || defined (SYM2)
|
|
728 |
sc_useless_cpp_parens:
|
|
729 |
@prohibit='^# *if .*defined *\(' \
|
|
730 |
halt='found useless parentheses in cpp directive' \
|
|
731 |
$(_sc_search_regexp)
|
|
732 |
|
|
733 |
# List headers for which HAVE_HEADER_H is always true, assuming you are
|
|
734 |
# using the appropriate gnulib module. CAUTION: for each "unnecessary"
|
|
735 |
# #if HAVE_HEADER_H that you remove, be sure that your project explicitly
|
|
736 |
# requires the gnulib module that guarantees the usability of that header.
|
|
737 |
gl_assured_headers_ = \
|
|
738 |
cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g'
|
|
739 |
|
|
740 |
# Convert the list of names to upper case, and replace each space with "|".
|
|
741 |
az_ = abcdefghijklmnopqrstuvwxyz
|
|
742 |
AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
743 |
gl_header_upper_case_or_ = \
|
|
744 |
$$($(gl_assured_headers_) \
|
|
745 |
| tr $(az_)/.- $(AZ_)___ \
|
|
746 |
| tr -s ' ' '|' \
|
|
747 |
)
|
|
748 |
sc_prohibit_always_true_header_tests:
|
|
749 |
@or=$(gl_header_upper_case_or_); \
|
|
750 |
re="HAVE_($$or)_H"; \
|
|
751 |
prohibit='\<'"$$re"'\>' \
|
|
752 |
halt=$$(printf '%s\n' \
|
|
753 |
'do not test the above HAVE_<header>_H symbol(s);' \
|
|
754 |
' with the corresponding gnulib module, they are always true') \
|
|
755 |
$(_sc_search_regexp)
|
|
756 |
|
|
757 |
# ==================================================================
|
|
758 |
gl_other_headers_ ?= \
|
|
759 |
intprops.h \
|
|
760 |
openat.h \
|
|
761 |
stat-macros.h
|
|
762 |
|
|
763 |
# Perl -lne code to extract "significant" cpp-defined symbols from a
|
|
764 |
# gnulib header file, eliminating a few common false-positives.
|
|
765 |
# The exempted names below are defined only conditionally in gnulib,
|
|
766 |
# and hence sometimes must/may be defined in application code.
|
|
767 |
gl_extract_significant_defines_ = \
|
|
768 |
/^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
|
|
769 |
&& $$2 !~ /(?:rpl_|_used_without_)/\
|
|
770 |
&& $$1 !~ /^(?:NSIG|ENODATA)$$/\
|
|
771 |
&& $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\
|
|
772 |
and print $$1
|
|
773 |
|
|
774 |
# Create a list of regular expressions matching the names
|
|
775 |
# of macros that are guaranteed to be defined by parts of gnulib.
|
|
776 |
define def_sym_regex
|
|
777 |
gen_h=$(gl_generated_headers_); \
|
|
778 |
(cd $(gnulib_dir)/lib; \
|
|
779 |
for f in *.in.h $(gl_other_headers_); do \
|
|
780 |
test -f $$f \
|
|
781 |
&& perl -lne '$(gl_extract_significant_defines_)' $$f; \
|
|
782 |
done; \
|
|
783 |
) | sort -u \
|
|
784 |
| sed 's/^/^ *# *(define|undef) */;s/$$/\\>/'
|
|
785 |
endef
|
|
786 |
|
|
787 |
# Don't define macros that we already get from gnulib header files.
|
|
788 |
sc_prohibit_always-defined_macros:
|
|
789 |
@if test -d $(gnulib_dir); then \
|
|
790 |
case $$(echo all: | grep -l -f - Makefile) in Makefile);; *) \
|
|
791 |
echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \
|
|
792 |
esac; \
|
|
793 |
$(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT)) \
|
|
794 |
&& { echo '$(ME): define the above via some gnulib .h file' \
|
|
795 |
1>&2; exit 1; } || :; \
|
|
796 |
fi
|
|
797 |
# ==================================================================
|
|
798 |
|
|
799 |
# Prohibit checked in backup files.
|
|
800 |
sc_prohibit_backup_files:
|
|
801 |
@$(VC_LIST) | grep '~$$' && \
|
|
802 |
{ echo '$(ME): found version controlled backup file' 1>&2; \
|
|
803 |
exit 1; } || :
|
|
804 |
|
|
805 |
# Require the latest GPL.
|
|
806 |
sc_GPL_version:
|
|
807 |
@prohibit='either ''version [^3]' \
|
|
808 |
halt='GPL vN, N!=3' \
|
|
809 |
$(_sc_search_regexp)
|
|
810 |
|
|
811 |
# Require the latest GFDL. Two regexp, since some .texi files end up
|
|
812 |
# line wrapping between 'Free Documentation License,' and 'Version'.
|
|
813 |
_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
|
|
814 |
sc_GFDL_version:
|
|
815 |
@prohibit='$(_GFDL_regexp)' \
|
|
816 |
halt='GFDL vN, N!=3' \
|
|
817 |
$(_sc_search_regexp)
|
|
818 |
|
|
819 |
# Don't use Texinfo's @acronym{}.
|
|
820 |
# http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00321.html
|
|
821 |
texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$
|
|
822 |
sc_texinfo_acronym:
|
|
823 |
@prohibit='@acronym\{' \
|
|
824 |
in_vc_files='$(texinfo_suffix_re_)' \
|
|
825 |
halt='found use of Texinfo @acronym{}' \
|
|
826 |
$(_sc_search_regexp)
|
|
827 |
|
|
828 |
cvs_keywords = \
|
|
829 |
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
|
|
830 |
|
|
831 |
sc_prohibit_cvs_keyword:
|
|
832 |
@prohibit='\$$($(cvs_keywords))\$$' \
|
|
833 |
halt='do not use CVS keyword expansion' \
|
|
834 |
$(_sc_search_regexp)
|
|
835 |
|
|
836 |
# This Perl code is slightly obfuscated. Not only is each "$" doubled
|
|
837 |
# because it's in a Makefile, but the $$c's are comments; we cannot
|
|
838 |
# use "#" due to the way the script ends up concatenated onto one line.
|
|
839 |
# It would be much more concise, and would produce better output (including
|
|
840 |
# counts) if written as:
|
|
841 |
# perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
|
|
842 |
# but that would be far less efficient, reading the entire contents
|
|
843 |
# of each file, rather than just the last two bytes of each.
|
|
844 |
# In addition, while the code below detects both blank lines and a missing
|
|
845 |
# newline at EOF, the above detects only the former.
|
|
846 |
#
|
|
847 |
# This is a perl script that is expected to be the single-quoted argument
|
|
848 |
# to a command-line "-le". The remaining arguments are file names.
|
|
849 |
# Print the name of each file that ends in exactly one newline byte.
|
|
850 |
# I.e., warn if there are blank lines (2 or more newlines), or if the
|
|
851 |
# last byte is not a newline. However, currently we don't complain
|
|
852 |
# about any file that contains exactly one byte.
|
|
853 |
# Exit nonzero if at least one such file is found, otherwise, exit 0.
|
|
854 |
# Warn about, but otherwise ignore open failure. Ignore seek/read failure.
|
|
855 |
#
|
|
856 |
# Use this if you want to remove trailing empty lines from selected files:
|
|
857 |
# perl -pi -0777 -e 's/\n\n+$/\n/' files...
|
|
858 |
#
|
|
859 |
require_exactly_one_NL_at_EOF_ = \
|
|
860 |
foreach my $$f (@ARGV) \
|
|
861 |
{ \
|
|
862 |
open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \
|
|
863 |
my $$p = sysseek (F, -2, 2); \
|
|
864 |
my $$c = "seek failure probably means file has < 2 bytes; ignore"; \
|
|
865 |
my $$last_two_bytes; \
|
|
866 |
defined $$p and $$p = sysread F, $$last_two_bytes, 2; \
|
|
867 |
close F; \
|
|
868 |
$$c = "ignore read failure"; \
|
|
869 |
$$p && ($$last_two_bytes eq "\n\n" \
|
|
870 |
|| substr ($$last_two_bytes,1) ne "\n") \
|
|
871 |
and (print $$f), $$fail=1; \
|
|
872 |
} \
|
|
873 |
END { exit defined $$fail }
|
|
874 |
sc_prohibit_empty_lines_at_EOF:
|
|
875 |
@perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
|
|
876 |
|| { echo '$(ME): empty line(s) or no newline at EOF' \
|
|
877 |
1>&2; exit 1; } || :
|
|
878 |
|
|
879 |
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
|
|
880 |
# This is a bit of a kludge, since it prevents use of the string
|
|
881 |
# even in comments, but for now it does the job with no false positives.
|
|
882 |
sc_prohibit_stat_st_blocks:
|
|
883 |
@prohibit='[.>]st_blocks' \
|
|
884 |
halt='do not use st_blocks; use ST_NBLOCKS' \
|
|
885 |
$(_sc_search_regexp)
|
|
886 |
|
|
887 |
# Make sure we don't define any S_IS* macros in src/*.c files.
|
|
888 |
# They're already defined via gnulib's sys/stat.h replacement.
|
|
889 |
sc_prohibit_S_IS_definition:
|
|
890 |
@prohibit='^ *# *define *S_IS' \
|
|
891 |
halt='do not define S_IS* macros; include <sys/stat.h>' \
|
|
892 |
$(_sc_search_regexp)
|
|
893 |
|
|
894 |
# Perl block to convert a match to FILE_NAME:LINENO:TEST,
|
|
895 |
# that is shared by two definitions below.
|
|
896 |
perl_filename_lineno_text_ = \
|
|
897 |
-e ' {' \
|
|
898 |
-e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \
|
|
899 |
-e ' ($$v = $$&) =~ s/\n/\\n/g;' \
|
|
900 |
-e ' print "$$ARGV:$$n:$$v\n";' \
|
|
901 |
-e ' }'
|
|
902 |
|
|
903 |
prohibit_doubled_word_RE_ ?= \
|
|
904 |
/\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims
|
|
905 |
prohibit_doubled_word_ = \
|
|
906 |
-e 'while ($(prohibit_doubled_word_RE_))' \
|
|
907 |
$(perl_filename_lineno_text_)
|
|
908 |
|
|
909 |
# Define this to a regular expression that matches
|
|
910 |
# any filename:dd:match lines you want to ignore.
|
|
911 |
# The default is to ignore no matches.
|
|
912 |
ignore_doubled_word_match_RE_ ?= ^$$
|
|
913 |
|
|
914 |
sc_prohibit_doubled_word:
|
|
915 |
@perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT)) \
|
|
916 |
| grep -vE '$(ignore_doubled_word_match_RE_)' \
|
|
917 |
| grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || :
|
|
918 |
|
|
919 |
# A regular expression matching undesirable combinations of words like
|
|
920 |
# "can not"; this matches them even when the two words appear on different
|
|
921 |
# lines, but not when there is an intervening delimiter like "#" or "*".
|
|
922 |
prohibit_undesirable_word_seq_RE_ ?= \
|
|
923 |
/\bcan\s+not\b/gims
|
|
924 |
prohibit_undesirable_word_seq_ = \
|
|
925 |
-e 'while ($(prohibit_undesirable_word_seq_RE_))' \
|
|
926 |
$(perl_filename_lineno_text_)
|
|
927 |
# Define this to a regular expression that matches
|
|
928 |
# any filename:dd:match lines you want to ignore.
|
|
929 |
# The default is to ignore no matches.
|
|
930 |
ignore_undesirable_word_sequence_RE_ ?= ^$$
|
|
931 |
|
|
932 |
sc_prohibit_undesirable_word_seq:
|
|
933 |
@perl -n -0777 $(prohibit_undesirable_word_seq_) \
|
|
934 |
$$($(VC_LIST_EXCEPT)) \
|
|
935 |
| grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep . \
|
|
936 |
&& { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
|
|
937 |
|
|
938 |
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
|
|
939 |
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
|
|
940 |
# Using test's -a and -o operators is not portable.
|
|
941 |
# We prefer test over [, since the latter is spelled [[ in configure.ac.
|
|
942 |
sc_prohibit_test_minus_ao:
|
|
943 |
@prohibit='(\<test| \[+) .+ -[ao] ' \
|
|
944 |
halt='$(_ptm1); $(_ptm2)' \
|
|
945 |
$(_sc_search_regexp)
|
|
946 |
|
|
947 |
# Avoid a test bashism.
|
|
948 |
sc_prohibit_test_double_equal:
|
|
949 |
@prohibit='(\<test| \[+) .+ == ' \
|
|
950 |
containing='#! */bin/[a-z]*sh' \
|
|
951 |
halt='use "test x = x", not "test x =''= x"' \
|
|
952 |
$(_sc_search_regexp)
|
|
953 |
|
|
954 |
# Each program that uses proper_name_utf8 must link with one of the
|
|
955 |
# ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
|
|
956 |
# The perl -0777 invocation below extracts the possibly-multi-line
|
|
957 |
# definition of LDADD from the appropriate Makefile.am and exits 0
|
|
958 |
# when it contains "ICONV".
|
|
959 |
sc_proper_name_utf8_requires_ICONV:
|
|
960 |
@progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
|
|
961 |
if test "x$$progs" != x; then \
|
|
962 |
fail=0; \
|
|
963 |
for p in $$progs; do \
|
|
964 |
dir=$$(dirname "$$p"); \
|
|
965 |
perl -0777 \
|
|
966 |
-ne 'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \
|
|
967 |
$$dir/Makefile.am && continue; \
|
|
968 |
base=$$(basename "$$p" .c); \
|
|
969 |
grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
|
|
970 |
|| { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
|
|
971 |
done; \
|
|
972 |
test $$fail = 1 && \
|
|
973 |
{ echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
|
|
974 |
exit 1; } || :; \
|
|
975 |
fi
|
|
976 |
|
|
977 |
# Warn about "c0nst struct Foo const foo[]",
|
|
978 |
# but not about "char const *const foo" or "#define const const".
|
|
979 |
sc_redundant_const:
|
|
980 |
@prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
|
|
981 |
halt='redundant "const" in declarations' \
|
|
982 |
$(_sc_search_regexp)
|
|
983 |
|
|
984 |
sc_const_long_option:
|
|
985 |
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
|
|
986 |
| grep -Ev 'const struct option|struct option const' && { \
|
|
987 |
echo 1>&2 '$(ME): add "const" to the above declarations'; \
|
|
988 |
exit 1; } || :
|
|
989 |
|
|
990 |
NEWS_hash = \
|
|
991 |
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
|
|
992 |
$(srcdir)/NEWS \
|
|
993 |
| perl -0777 -pe \
|
|
994 |
's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \
|
|
995 |
| md5sum - \
|
|
996 |
| sed 's/ .*//')
|
|
997 |
|
|
998 |
# Ensure that we don't accidentally insert an entry into an old NEWS block.
|
|
999 |
sc_immutable_NEWS:
|
|
1000 |
@if test -f $(srcdir)/NEWS; then \
|
|
1001 |
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
|
|
1002 |
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
|
|
1003 |
fi
|
|
1004 |
|
|
1005 |
# Update the hash stored above. Do this after each release and
|
|
1006 |
# for any corrections to old entries.
|
|
1007 |
update-NEWS-hash: NEWS
|
|
1008 |
perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \
|
|
1009 |
$(srcdir)/cfg.mk
|
|
1010 |
|
|
1011 |
# Ensure that we use only the standard $(VAR) notation,
|
|
1012 |
# not @...@ in Makefile.am, now that we can rely on automake
|
|
1013 |
# to emit a definition for each substituted variable.
|
|
1014 |
# However, there is still one case in which @VAR@ use is not just
|
|
1015 |
# legitimate, but actually required: when augmenting an automake-defined
|
|
1016 |
# variable with a prefix. For example, gettext uses this:
|
|
1017 |
# MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
|
|
1018 |
# otherwise, makeinfo would put German or French (current locale)
|
|
1019 |
# navigation hints in the otherwise-English documentation.
|
|
1020 |
#
|
|
1021 |
# Allow the package to add exceptions via a hook in cfg.mk;
|
|
1022 |
# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
|
|
1023 |
# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
|
|
1024 |
_makefile_at_at_check_exceptions ?=
|
|
1025 |
sc_makefile_at_at_check:
|
|
1026 |
@perl -ne '/\@[A-Z_0-9]+\@/' \
|
|
1027 |
-e ' && !/([A-Z_0-9]+)\s+=.*\@\1\@$$/' \
|
|
1028 |
-e ''$(_makefile_at_at_check_exceptions) \
|
|
1029 |
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
|
|
1030 |
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \
|
|
1031 |
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
|
|
1032 |
|
|
1033 |
news-check: NEWS
|
|
1034 |
if sed -n $(news-check-lines-spec)p $(srcdir)/NEWS \
|
|
1035 |
| grep -E $(news-check-regexp) >/dev/null; then \
|
|
1036 |
:; \
|
|
1037 |
else \
|
|
1038 |
echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
|
|
1039 |
exit 1; \
|
|
1040 |
fi
|
|
1041 |
|
|
1042 |
sc_makefile_TAB_only_indentation:
|
|
1043 |
@prohibit='^ [ ]{8}' \
|
|
1044 |
in_vc_files='akefile|\.mk$$' \
|
|
1045 |
halt='found TAB-8-space indentation' \
|
|
1046 |
$(_sc_search_regexp)
|
|
1047 |
|
|
1048 |
sc_m4_quote_check:
|
|
1049 |
@prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
|
|
1050 |
in_vc_files='(^configure\.ac|\.m4)$$' \
|
|
1051 |
halt='quote the first arg to AC_DEF*' \
|
|
1052 |
$(_sc_search_regexp)
|
|
1053 |
|
|
1054 |
fix_po_file_diag = \
|
|
1055 |
'you have changed the set of files with translatable diagnostics;\n\
|
|
1056 |
apply the above patch\n'
|
|
1057 |
|
|
1058 |
# Verify that all source files using _() are listed in po/POTFILES.in.
|
|
1059 |
po_file ?= $(srcdir)/po/POTFILES.in
|
|
1060 |
generated_files ?= $(srcdir)/lib/*.[ch]
|
|
1061 |
sc_po_check:
|
|
1062 |
@if test -f $(po_file); then \
|
|
1063 |
grep -E -v '^(#|$$)' $(po_file) \
|
|
1064 |
| grep -v '^src/false\.c$$' | sort > $@-1; \
|
|
1065 |
files=; \
|
|
1066 |
for file in $$($(VC_LIST_EXCEPT)) $(generated_files); do \
|
|
1067 |
test -r $$file || continue; \
|
|
1068 |
case $$file in \
|
|
1069 |
*.m4|*.mk) continue ;; \
|
|
1070 |
*.?|*.??) ;; \
|
|
1071 |
*) continue;; \
|
|
1072 |
esac; \
|
|
1073 |
case $$file in \
|
|
1074 |
*.[ch]) \
|
|
1075 |
base=`expr " $$file" : ' \(.*\)\..'`; \
|
|
1076 |
{ test -f $$base.l || test -f $$base.y; } && continue;; \
|
|
1077 |
esac; \
|
|
1078 |
files="$$files $$file"; \
|
|
1079 |
done; \
|
|
1080 |
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
|
|
1081 |
| sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2; \
|
|
1082 |
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|
|
1083 |
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
|
|
1084 |
rm -f $@-1 $@-2; \
|
|
1085 |
fi
|
|
1086 |
|
|
1087 |
# Sometimes it is useful to change the PATH environment variable
|
|
1088 |
# in Makefiles. When doing so, it's better not to use the Unix-centric
|
|
1089 |
# path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
|
|
1090 |
msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
|
|
1091 |
sc_makefile_path_separator_check:
|
|
1092 |
@prohibit='PATH[=].*:' \
|
|
1093 |
in_vc_files='akefile|\.mk$$' \
|
|
1094 |
halt=$(msg) \
|
|
1095 |
$(_sc_search_regexp)
|
|
1096 |
|
|
1097 |
# Check that `make alpha' will not fail at the end of the process,
|
|
1098 |
# i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release)
|
|
1099 |
# and is read-only.
|
|
1100 |
writable-files:
|
|
1101 |
if test -d $(release_archive_dir); then \
|
|
1102 |
for file in $(DIST_ARCHIVES); do \
|
|
1103 |
for p in ./ $(release_archive_dir)/; do \
|
|
1104 |
test -e $$p$$file || continue; \
|
|
1105 |
test -w $$p$$file \
|
|
1106 |
|| { echo ERROR: $$p$$file is not writable; fail=1; }; \
|
|
1107 |
done; \
|
|
1108 |
done; \
|
|
1109 |
test "$$fail" && exit 1 || : ; \
|
|
1110 |
else :; \
|
|
1111 |
fi
|
|
1112 |
|
|
1113 |
v_etc_file = $(gnulib_dir)/lib/version-etc.c
|
|
1114 |
sample-test = tests/sample-test
|
|
1115 |
texi = doc/$(PACKAGE).texi
|
|
1116 |
# Make sure that the copyright date in $(v_etc_file) is up to date.
|
|
1117 |
# Do the same for the $(sample-test) and the main doc/.texi file.
|
|
1118 |
sc_copyright_check:
|
|
1119 |
@require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \
|
|
1120 |
in_files=$(v_etc_file) \
|
|
1121 |
halt='out of date copyright in $(v_etc_file); update it' \
|
|
1122 |
$(_sc_search_regexp)
|
|
1123 |
@require='# Copyright \(C\) '$$(date +%Y)' Free' \
|
|
1124 |
in_vc_files=$(sample-test) \
|
|
1125 |
halt='out of date copyright in $(sample-test); update it' \
|
|
1126 |
$(_sc_search_regexp)
|
|
1127 |
@require='Copyright @copyright\{\} .*'$$(date +%Y)' Free' \
|
|
1128 |
in_vc_files=$(texi) \
|
|
1129 |
halt='out of date copyright in $(texi); update it' \
|
|
1130 |
$(_sc_search_regexp)
|
|
1131 |
|
|
1132 |
# If tests/help-version exists and seems to be new enough, assume that its
|
|
1133 |
# use of init.sh and path_prepend_ is correct, and ensure that every other
|
|
1134 |
# use of init.sh is identical.
|
|
1135 |
# This is useful because help-version cross-checks prog --version
|
|
1136 |
# with $(VERSION), which verifies that its path_prepend_ invocation
|
|
1137 |
# sets PATH correctly. This is an inexpensive way to ensure that
|
|
1138 |
# the other init.sh-using tests also get it right.
|
|
1139 |
_hv_file ?= $(srcdir)/tests/help-version
|
|
1140 |
_hv_regex_weak ?= ^ *\. .*/init\.sh"
|
|
1141 |
# Fix syntax-highlighters "
|
|
1142 |
_hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh"
|
|
1143 |
sc_cross_check_PATH_usage_in_tests:
|
|
1144 |
@if test -f $(_hv_file); then \
|
|
1145 |
grep -l 'VERSION mismatch' $(_hv_file) >/dev/null \
|
|
1146 |
|| { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \
|
|
1147 |
exit 0; }; \
|
|
1148 |
grep -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \
|
|
1149 |
|| { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
|
|
1150 |
exit 1; }; \
|
|
1151 |
good=$$(grep -E '$(_hv_regex_strong)' $(_hv_file)); \
|
|
1152 |
grep -LFx "$$good" \
|
|
1153 |
$$(grep -lE '$(_hv_regex_weak)' $$($(VC_LIST_EXCEPT))) \
|
|
1154 |
| grep . && \
|
|
1155 |
{ echo "$(ME): the above files use path_prepend_ inconsistently" \
|
|
1156 |
1>&2; exit 1; } || :; \
|
|
1157 |
fi
|
|
1158 |
|
|
1159 |
# #if HAVE_... will evaluate to false for any non numeric string.
|
|
1160 |
# That would be flagged by using -Wundef, however gnulib currently
|
|
1161 |
# tests many undefined macros, and so we can't enable that option.
|
|
1162 |
# So at least preclude common boolean strings as macro values.
|
|
1163 |
sc_Wundef_boolean:
|
|
1164 |
@prohibit='^#define.*(yes|no|true|false)$$' \
|
|
1165 |
in_files='$(CONFIG_INCLUDE)' \
|
|
1166 |
halt='Use 0 or 1 for macro values' \
|
|
1167 |
$(_sc_search_regexp)
|
|
1168 |
|
|
1169 |
# Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
|
|
1170 |
# not be constant, or might overflow a stack. In general, use PATH_MAX as
|
|
1171 |
# a limit, not an array or alloca size.
|
|
1172 |
sc_prohibit_path_max_allocation:
|
|
1173 |
@prohibit='(\balloca *\([^)]*|\[[^]]*)PATH_MAX' \
|
|
1174 |
halt='Avoid stack allocations of size PATH_MAX' \
|
|
1175 |
$(_sc_search_regexp)
|
|
1176 |
|
|
1177 |
sc_vulnerable_makefile_CVE-2009-4029:
|
|
1178 |
@prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
|
|
1179 |
in_files=$$(find $(srcdir) -name Makefile.in) \
|
|
1180 |
halt=$$(printf '%s\n' \
|
|
1181 |
'the above files are vulnerable; beware of running' \
|
|
1182 |
' "make dist*" rules, and upgrade to fixed automake' \
|
|
1183 |
' see http://bugzilla.redhat.com/542609 for details') \
|
|
1184 |
$(_sc_search_regexp)
|
|
1185 |
|
|
1186 |
vc-diff-check:
|
|
1187 |
(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
|
|
1188 |
if test -s vc-diffs; then \
|
|
1189 |
cat vc-diffs; \
|
|
1190 |
echo "Some files are locally modified:" 1>&2; \
|
|
1191 |
exit 1; \
|
|
1192 |
else \
|
|
1193 |
rm vc-diffs; \
|
|
1194 |
fi
|
|
1195 |
|
|
1196 |
rel-files = $(DIST_ARCHIVES)
|
|
1197 |
|
|
1198 |
gnulib_dir ?= $(srcdir)/gnulib
|
|
1199 |
gnulib-version = $$(cd $(gnulib_dir) && git describe)
|
|
1200 |
bootstrap-tools ?= autoconf,automake,gnulib
|
|
1201 |
|
|
1202 |
# If it's not already specified, derive the GPG key ID from
|
|
1203 |
# the signed tag we've just applied to mark this release.
|
|
1204 |
gpg_key_ID ?= \
|
|
1205 |
$$(git cat-file tag v$(VERSION) > .ann-sig \
|
|
1206 |
&& gpgv .ann-sig - < /dev/null 2>&1 \
|
|
1207 |
| sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig)
|
|
1208 |
|
|
1209 |
translation_project_ ?= coordinator@translationproject.org
|
|
1210 |
|
|
1211 |
# Make info-gnu the default only for a stable release.
|
|
1212 |
ifeq ($(RELEASE_TYPE),stable)
|
|
1213 |
announcement_Cc_ ?= $(translation_project_), $(PACKAGE_BUGREPORT)
|
|
1214 |
announcement_mail_headers_ ?= \
|
|
1215 |
To: info-gnu@gnu.org \
|
|
1216 |
Cc: $(announcement_Cc_) \
|
|
1217 |
Mail-Followup-To: $(PACKAGE_BUGREPORT)
|
|
1218 |
else
|
|
1219 |
announcement_Cc_ ?= $(translation_project_)
|
|
1220 |
announcement_mail_headers_ ?= \
|
|
1221 |
To: $(PACKAGE_BUGREPORT) \
|
|
1222 |
Cc: $(announcement_Cc_)
|
|
1223 |
endif
|
|
1224 |
|
|
1225 |
announcement: NEWS ChangeLog $(rel-files)
|
|
1226 |
@$(srcdir)/$(_build-aux)/announce-gen \
|
|
1227 |
--mail-headers='$(announcement_mail_headers_)' \
|
|
1228 |
--release-type=$(RELEASE_TYPE) \
|
|
1229 |
--package=$(PACKAGE) \
|
|
1230 |
--prev=$(PREV_VERSION) \
|
|
1231 |
--curr=$(VERSION) \
|
|
1232 |
--gpg-key-id=$(gpg_key_ID) \
|
|
1233 |
--news=$(srcdir)/NEWS \
|
|
1234 |
--bootstrap-tools=$(bootstrap-tools) \
|
|
1235 |
--gnulib-version=$(gnulib-version) \
|
|
1236 |
--no-print-checksums \
|
|
1237 |
$(addprefix --url-dir=, $(url_dir_list))
|
|
1238 |
|
|
1239 |
## ---------------- ##
|
|
1240 |
## Updating files. ##
|
|
1241 |
## ---------------- ##
|
|
1242 |
|
|
1243 |
ftp-gnu = ftp://ftp.gnu.org/gnu
|
|
1244 |
www-gnu = http://www.gnu.org
|
|
1245 |
|
|
1246 |
upload_dest_dir_ ?= $(PACKAGE)
|
|
1247 |
emit_upload_commands:
|
|
1248 |
@echo =====================================
|
|
1249 |
@echo =====================================
|
|
1250 |
@echo "$(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \\"
|
|
1251 |
@echo " --to $(gnu_rel_host):$(upload_dest_dir_) \\"
|
|
1252 |
@echo " $(rel-files)"
|
|
1253 |
@echo '# send the ~/announce-$(my_distdir) e-mail'
|
|
1254 |
@echo =====================================
|
|
1255 |
@echo =====================================
|
|
1256 |
|
|
1257 |
define emit-commit-log
|
|
1258 |
printf '%s\n' 'maint: post-release administrivia' '' \
|
|
1259 |
'* NEWS: Add header line for next release.' \
|
|
1260 |
'* .prev-version: Record previous version.' \
|
|
1261 |
'* cfg.mk (old_NEWS_hash): Auto-update.'
|
|
1262 |
endef
|
|
1263 |
|
|
1264 |
.PHONY: no-submodule-changes
|
|
1265 |
no-submodule-changes:
|
|
1266 |
if test -d $(srcdir)/.git; then \
|
|
1267 |
diff=$$(cd $(srcdir) && git submodule -q foreach \
|
|
1268 |
git diff-index --name-only HEAD) \
|
|
1269 |
|| exit 1; \
|
|
1270 |
case $$diff in '') ;; \
|
|
1271 |
*) echo '$(ME): submodule files are locally modified:'; \
|
|
1272 |
echo "$$diff"; exit 1;; esac; \
|
|
1273 |
else \
|
|
1274 |
: ; \
|
|
1275 |
fi
|
|
1276 |
|
|
1277 |
submodule-checks ?= no-submodule-changes public-submodule-commit
|
|
1278 |
|
|
1279 |
# Ensure that each sub-module commit we're using is public.
|
|
1280 |
# Without this, it is too easy to tag and release code that
|
|
1281 |
# cannot be built from a fresh clone.
|
|
1282 |
.PHONY: public-submodule-commit
|
|
1283 |
public-submodule-commit:
|
|
1284 |
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
|
|
1285 |
cd $(srcdir) && \
|
|
1286 |
git submodule --quiet foreach test '$$(git rev-parse $$sha1)' \
|
|
1287 |
= '$$(git merge-base origin $$sha1)' \
|
|
1288 |
|| { echo '$(ME): found non-public submodule commit' >&2; \
|
|
1289 |
exit 1; }; \
|
|
1290 |
else \
|
|
1291 |
: ; \
|
|
1292 |
fi
|
|
1293 |
# This rule has a high enough utility/cost ratio that it should be a
|
|
1294 |
# dependent of "check" by default. However, some of us do occasionally
|
|
1295 |
# commit a temporary change that deliberately points to a non-public
|
|
1296 |
# submodule commit, and want to be able to use rules like "make check".
|
|
1297 |
# In that case, run e.g., "make check gl_public_submodule_commit="
|
|
1298 |
# to disable this test.
|
|
1299 |
gl_public_submodule_commit ?= public-submodule-commit
|
|
1300 |
check: $(gl_public_submodule_commit)
|
|
1301 |
|
|
1302 |
.PHONY: alpha beta stable
|
|
1303 |
ALL_RECURSIVE_TARGETS += alpha beta stable
|
|
1304 |
alpha beta stable: $(local-check) writable-files $(submodule-checks)
|
|
1305 |
test $@ = stable \
|
|
1306 |
&& { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
|
|
1307 |
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|
|
1308 |
|| :
|
|
1309 |
$(MAKE) vc-diff-check
|
|
1310 |
$(MAKE) news-check
|
|
1311 |
$(MAKE) distcheck
|
|
1312 |
$(MAKE) dist XZ_OPT=-9ev
|
|
1313 |
$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
|
|
1314 |
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
|
1315 |
|
|
1316 |
# Override this in cfg.mk if you follow different procedures.
|
|
1317 |
release-prep-hook ?= release-prep
|
|
1318 |
|
|
1319 |
gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?]
|
|
1320 |
.PHONY: release-prep
|
|
1321 |
release-prep:
|
|
1322 |
case $$RELEASE_TYPE in alpha|beta|stable) ;; \
|
|
1323 |
*) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
|
|
1324 |
$(MAKE) --no-print-directory -s announcement > ~/announce-$(my_distdir)
|
|
1325 |
if test -d $(release_archive_dir); then \
|
|
1326 |
ln $(rel-files) $(release_archive_dir); \
|
|
1327 |
chmod a-w $(rel-files); \
|
|
1328 |
fi
|
|
1329 |
echo $(VERSION) > $(prev_version_file)
|
|
1330 |
$(MAKE) update-NEWS-hash
|
|
1331 |
perl -pi -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' NEWS
|
|
1332 |
$(emit-commit-log) > .ci-msg
|
|
1333 |
$(VC) commit -F .ci-msg -a
|
|
1334 |
rm .ci-msg
|
|
1335 |
|
|
1336 |
# Override this with e.g., -s $(srcdir)/some_other_name.texi
|
|
1337 |
# if the default $(PACKAGE)-derived name doesn't apply.
|
|
1338 |
gendocs_options_ ?=
|
|
1339 |
|
|
1340 |
.PHONY: web-manual
|
|
1341 |
web-manual:
|
|
1342 |
@test -z "$(manual_title)" \
|
|
1343 |
&& { echo define manual_title in cfg.mk 1>&2; exit 1; } || :
|
|
1344 |
@cd '$(srcdir)/doc'; \
|
|
1345 |
$(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \
|
|
1346 |
-o '$(abs_builddir)/doc/manual' \
|
|
1347 |
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \
|
|
1348 |
"$(PACKAGE_NAME) - $(manual_title)"
|
|
1349 |
@echo " *** Upload the doc/manual directory to web-cvs."
|
|
1350 |
|
|
1351 |
# Code Coverage
|
|
1352 |
|
|
1353 |
init-coverage:
|
|
1354 |
$(MAKE) $(AM_MAKEFLAGS) clean
|
|
1355 |
lcov --directory . --zerocounters
|
|
1356 |
|
|
1357 |
COVERAGE_CCOPTS ?= "-g --coverage"
|
|
1358 |
COVERAGE_OUT ?= doc/coverage
|
|
1359 |
|
|
1360 |
build-coverage:
|
|
1361 |
$(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS)
|
|
1362 |
$(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check
|
|
1363 |
mkdir -p $(COVERAGE_OUT)
|
|
1364 |
lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \
|
|
1365 |
--capture
|
|
1366 |
|
|
1367 |
gen-coverage:
|
|
1368 |
genhtml --output-directory $(COVERAGE_OUT) \
|
|
1369 |
$(COVERAGE_OUT)/$(PACKAGE).info \
|
|
1370 |
--highlight --frames --legend \
|
|
1371 |
--title "$(PACKAGE_NAME)"
|
|
1372 |
|
|
1373 |
coverage: init-coverage build-coverage gen-coverage
|
|
1374 |
|
|
1375 |
# Update gettext files.
|
|
1376 |
PACKAGE ?= $(shell basename $(PWD))
|
|
1377 |
PO_DOMAIN ?= $(PACKAGE)
|
|
1378 |
POURL = http://translationproject.org/latest/$(PO_DOMAIN)/
|
|
1379 |
PODIR ?= po
|
|
1380 |
refresh-po:
|
|
1381 |
rm -f $(PODIR)/*.po && \
|
|
1382 |
echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
|
|
1383 |
wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
|
|
1384 |
echo 'en@boldquot' > $(PODIR)/LINGUAS && \
|
|
1385 |
echo 'en@quot' >> $(PODIR)/LINGUAS && \
|
|
1386 |
ls $(PODIR)/*.po | sed 's/\.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
|
|
1387 |
|
|
1388 |
# Running indent once is not idempotent, but running it twice is.
|
|
1389 |
INDENT_SOURCES ?= $(C_SOURCES)
|
|
1390 |
.PHONY: indent
|
|
1391 |
indent:
|
|
1392 |
indent $(INDENT_SOURCES)
|
|
1393 |
indent $(INDENT_SOURCES)
|
|
1394 |
|
|
1395 |
# If you want to set UPDATE_COPYRIGHT_* environment variables,
|
|
1396 |
# put the assignments in this variable.
|
|
1397 |
update-copyright-env ?=
|
|
1398 |
|
|
1399 |
# Run this rule once per year (usually early in January)
|
|
1400 |
# to update all FSF copyright year lists in your project.
|
|
1401 |
# If you have an additional project-specific rule,
|
|
1402 |
# add it in cfg.mk along with a line 'update-copyright: prereq'.
|
|
1403 |
# By default, exclude all variants of COPYING; you can also
|
|
1404 |
# add exemptions (such as ChangeLog..* for rotated change logs)
|
|
1405 |
# in the file .x-update-copyright.
|
|
1406 |
.PHONY: update-copyright
|
|
1407 |
update-copyright:
|
|
1408 |
grep -l -w Copyright \
|
|
1409 |
$$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \
|
|
1410 |
| $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@
|
|
1411 |
|
|
1412 |
# This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
|
|
1413 |
# overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
|
|
1414 |
|
|
1415 |
# NOTE: to override any _gl_TS_* default value, you must
|
|
1416 |
# define the variable(s) using "export" in cfg.mk.
|
|
1417 |
_gl_TS_dir ?= src
|
|
1418 |
|
|
1419 |
ALL_RECURSIVE_TARGETS += sc_tight_scope
|
|
1420 |
sc_tight_scope: tight-scope.mk
|
|
1421 |
@fail=0; \
|
|
1422 |
if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \
|
|
1423 |
> /dev/null \
|
|
1424 |
&& ! grep -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
|
|
1425 |
> /dev/null 2>&1; then \
|
|
1426 |
echo '$(ME): skipping $@'; \
|
|
1427 |
else \
|
|
1428 |
$(MAKE) -s -C $(_gl_TS_dir) \
|
|
1429 |
-f Makefile \
|
|
1430 |
-f $(abs_top_srcdir)/cfg.mk \
|
|
1431 |
-f $(abs_top_builddir)/$< \
|
|
1432 |
_gl_tight_scope \
|
|
1433 |
|| fail=1; \
|
|
1434 |
fi; \
|
|
1435 |
rm -f $<; \
|
|
1436 |
exit $$fail
|
|
1437 |
|
|
1438 |
tight-scope.mk: $(ME)
|
|
1439 |
@rm -f $@ $@-t
|
|
1440 |
@perl -ne '/^# TS-start/.../^# TS-end/ and print' $(ME) > $@-t
|
|
1441 |
@chmod a=r $@-t && mv $@-t $@
|
|
1442 |
|
|
1443 |
ifeq (a,b)
|
|
1444 |
# TS-start
|
|
1445 |
|
|
1446 |
# Most functions should have static scope.
|
|
1447 |
# Any that don't must be marked with `extern', but `main'
|
|
1448 |
# and `usage' are exceptions: they're always extern, but
|
|
1449 |
# do not need to be marked. Symbols matching `__.*' are
|
|
1450 |
# reserved by the compiler, so are automatically excluded below.
|
|
1451 |
_gl_TS_unmarked_extern_functions ?= main usage
|
|
1452 |
_gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\S+) *\(/
|
|
1453 |
|
|
1454 |
# If your project uses a macro like "XTERN", then put
|
|
1455 |
# the following in cfg.mk to override this default:
|
|
1456 |
# export _gl_TS_extern = extern|XTERN
|
|
1457 |
_gl_TS_extern ?= extern
|
|
1458 |
|
|
1459 |
# The second nm|grep checks for file-scope variables with `extern' scope.
|
|
1460 |
# Without gnulib's progname module, you might put program_name here.
|
|
1461 |
# Symbols matching `__.*' are reserved by the compiler,
|
|
1462 |
# so are automatically excluded below.
|
|
1463 |
_gl_TS_unmarked_extern_vars ?=
|
|
1464 |
|
|
1465 |
# NOTE: the _match variables are perl expressions -- not mere regular
|
|
1466 |
# expressions -- so that you can extend them to match other patterns
|
|
1467 |
# and easily extract matched variable names.
|
|
1468 |
# For example, if your project declares some global variables via
|
|
1469 |
# a macro like this: GLOBAL(type, var_name, initializer), then you
|
|
1470 |
# can override this definition to automatically extract those names:
|
|
1471 |
# export _gl_TS_var_match = \
|
|
1472 |
# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
|
|
1473 |
_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/
|
|
1474 |
|
|
1475 |
# The names of object files in (or relative to) $(_gl_TS_dir).
|
|
1476 |
_gl_TS_obj_files ?= *.$(OBJEXT)
|
|
1477 |
|
|
1478 |
# Files in which to search for the one-line style extern declarations.
|
|
1479 |
# $(_gl_TS_dir)-relative.
|
|
1480 |
_gl_TS_headers ?= $(noinst_HEADERS)
|
|
1481 |
|
|
1482 |
.PHONY: _gl_tight_scope
|
|
1483 |
_gl_tight_scope: $(bin_PROGRAMS)
|
|
1484 |
t=exceptions-$$$$; \
|
|
1485 |
trap 's=$$?; rm -f $$t; exit $$s' 0; \
|
|
1486 |
for sig in 1 2 3 13 15; do \
|
|
1487 |
eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
|
|
1488 |
done; \
|
|
1489 |
src=`for f in $(SOURCES); do \
|
|
1490 |
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
|
1491 |
hdr=`for f in $(_gl_TS_headers); do \
|
|
1492 |
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
|
1493 |
( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_functions); \
|
|
1494 |
grep -h -A1 '^extern .*[^;]$$' $$src \
|
|
1495 |
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
|
|
1496 |
perl -lne \
|
|
1497 |
'$(_gl_TS_function_match) and print "^$$1\$$"' $$hdr; \
|
|
1498 |
) | sort -u > $$t; \
|
|
1499 |
nm -e $(_gl_TS_obj_files) | sed -n 's/.* T //p'|grep -Ev -f $$t \
|
|
1500 |
&& { echo the above functions should have static scope >&2; \
|
|
1501 |
exit 1; } || : ; \
|
|
1502 |
( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars); \
|
|
1503 |
perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' $$hdr *.h \
|
|
1504 |
) | sort -u > $$t; \
|
|
1505 |
nm -e $(_gl_TS_obj_files) | sed -n 's/.* [BCDGRS] //p' \
|
|
1506 |
| sort -u | grep -Ev -f $$t \
|
|
1507 |
&& { echo the above variables should have static scope >&2; \
|
|
1508 |
exit 1; } || :
|
|
1509 |
# TS-end
|
|
1510 |
endif
|