2 # This Makefile fragment tries to be general-purpose enough to be
3 # used by many projects via the gnulib maintainer-makefile module.
5 ## Copyright (C) 2001-2019 Free Software Foundation, Inc.
7 ## This program is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program. If not, see <https://www.gnu.org/licenses/>.
20 # This is reported not to work with make-3.79.1
21 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
24 # These variables ought to be defined through the configure.ac section
25 # of the module description. But some packages import this file directly,
26 # ignoring the module description.
32 _sp
= $(_empty
) $(_empty
)
36 # If S1 == S2, return S1, otherwise the empty string.
37 _equal
= $(and
$(findstring $(1),$(2)),$(findstring $(2),$(1)))
39 # member-check,VARIABLE,VALID-VALUES
40 # ----------------------------------
41 # Check that $(VARIABLE) is in the space-separated list of VALID-VALUES, and
42 # return it. Die otherwise.
46 $(if
$(findstring $(_sp
),$($(1))), \
47 $(error invalid
$(1): '$($(1))', expected
$(2)), \
48 $(or
$(findstring $(_sp
)$($(1))$(_sp
),$(_sp
)$(2)$(_sp
)), \
49 $(error invalid
$(1): '$($(1))', expected
$(2)))), \
50 $(error
$(1) undefined
)))
52 # Do not save the original name or timestamp in the .tar.gz file.
53 # Use --rsyncable if available.
55 $(shell gzip
--help
2>/dev
/null|
$(GREP
) rsyncable
>/dev
/null \
56 && printf
%s
--rsyncable
)
57 GZIP_ENV
= '--no-name --best $(gzip_rsyncable)'
62 VC_LIST
= $(srcdir)/$(_build-aux
)/vc-list-files
-C
$(srcdir)
64 # You can override this variable in cfg.mk if your gnulib submodule lives
65 # in a different location.
66 gnulib_dir ?
= $(srcdir)/gnulib
68 # You can override this variable in cfg.mk to set your own regexp
69 # matching files to ignore.
70 VC_LIST_ALWAYS_EXCLUDE_REGEX ?
= ^
$$
72 # This is to preprocess robustly the output of $(VC_LIST), so that even
73 # when $(srcdir) is a pathological name like "....", the leading sed command
74 # removes only the intended prefix.
75 _dot_escaped_srcdir
= $(subst .
,\.
,$(srcdir))
77 # Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
78 # when $(srcdir) is not ".".
80 _prepend_srcdir_prefix
=
82 _prepend_srcdir_prefix
= |
$(SED
) 's|^|$(srcdir)/|'
85 # In order to be able to consistently filter "."-relative names,
86 # (i.e., with no $(srcdir) prefix), this definition is careful to
87 # remove any $(srcdir) prefix, and to restore what it removes.
89 $(or
$(exclude_file_name_regexp--
$@
),^
$$)
91 $(VC_LIST
) |
$(SED
) 's|^$(_dot_escaped_srcdir)/||' \
92 | if
test -f
$(srcdir)/.x-
$@
; then
$(GREP
) -vEf
$(srcdir)/.x-
$@
; \
93 else $(GREP
) -Ev
-e
"$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
94 |
$(GREP
) -Ev
-e
'($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
95 $(_prepend_srcdir_prefix
)
97 ifeq ($(origin prev_version_file
), undefined
)
98 prev_version_file
= $(srcdir)/.prev-version
101 PREV_VERSION
:= $(shell cat
$(prev_version_file
) 2>/dev
/null
)
102 VERSION_REGEXP
= $(subst .
,\.
,$(VERSION
))
103 PREV_VERSION_REGEXP
= $(subst .
,\.
,$(PREV_VERSION
))
106 this-vc-tag
= v
$(VERSION
)
107 this-vc-tag-regexp
= v
$(VERSION_REGEXP
)
109 tag-package
= $(shell echo
"$(PACKAGE)" | tr
'[:lower:]' '[:upper:]')
110 tag-this-version
= $(subst .
,_
,$(VERSION
))
111 this-vc-tag
= $(tag-package
)-$(tag-this-version
)
112 this-vc-tag-regexp
= $(this-vc-tag
)
114 my_distdir
= $(PACKAGE
)-$(VERSION
)
116 # Old releases are stored here.
117 release_archive_dir ?
= ..
/release
119 # If RELEASE_TYPE is undefined, but RELEASE is, use its second word.
120 # But overwrite VERSION.
122 VERSION
:= $(word 1, $(RELEASE
))
123 RELEASE_TYPE ?
= $(word 2, $(RELEASE
))
126 # Validate and return $(RELEASE_TYPE), or die.
127 RELEASE_TYPES
= alpha beta stable
128 release-type
= $(call member-check
,RELEASE_TYPE
,$(RELEASE_TYPES
))
130 # Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
131 # Use alpha.gnu.org for alpha and beta releases.
132 # Use ftp.gnu.org for stable releases.
133 gnu_ftp_host-alpha
= alpha.gnu.org
134 gnu_ftp_host-beta
= alpha.gnu.org
135 gnu_ftp_host-stable
= ftp.gnu.org
136 gnu_rel_host ?
= $(gnu_ftp_host-
$(release-type
))
138 url_dir_list ?
= $(if
$(call _equal
,$(gnu_rel_host
),ftp.gnu.org
), \
139 https
://ftpmirror.gnu.org
/$(PACKAGE
), \
140 https
://$(gnu_rel_host
)/gnu
/$(PACKAGE
))
142 # Override this in cfg.mk if you are using a different format in your
144 today
= $(shell date
+%Y-
%m-
%d
)
146 # Select which lines of NEWS are searched for $(news-check-regexp).
147 # This is a sed line number spec. The default says that we search
148 # lines 1..10 of NEWS for $(news-check-regexp).
149 # If you want to search only line 3 or only lines 20-22, use "3" or "20,22".
150 news-check-lines-spec ?
= 1,10
151 news-check-regexp ?
= '^\*.* $(VERSION_REGEXP) \($(today)\)'
153 # Prevent programs like 'sort' from considering distinct strings to be equal.
154 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
157 ## --------------- ##
159 ## --------------- ##
161 ifneq ($(_gl-Makefile
),)
162 _cfg_mk
:= $(wildcard $(srcdir)/cfg.mk
)
164 # Collect the names of rules starting with 'sc_'.
165 syntax-check-rules
:= $(sort $(shell $(SED
) -n \
166 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(srcdir)/$(ME
) $(_cfg_mk
)))
167 .PHONY
: $(syntax-check-rules
)
169 ifeq ($(shell $(VC_LIST
) >/dev
/null
2>&1; echo
$$?
),0)
170 local-checks-available
+= $(syntax-check-rules
)
172 local-checks-available
+= no-vc-detected
174 @echo
"No version control files detected; skipping syntax check"
176 .PHONY
: $(local-checks-available
)
178 # Arrange to print the name of each syntax-checking rule just before running it.
179 $(syntax-check-rules
): %: %.m
180 sc_m_rules_
= $(patsubst %, %.m
, $(syntax-check-rules
))
181 .PHONY
: $(sc_m_rules_
)
183 @echo
$(patsubst sc_
%.m
, %, $@
)
184 @date
+%s.
%N
> .sc-start-
$(basename $@
)
186 # Compute and print the elapsed time for each syntax-check rule.
187 sc_z_rules_
= $(patsubst %, %.z
, $(syntax-check-rules
))
188 .PHONY
: $(sc_z_rules_
)
189 $(sc_z_rules_
): %.z
: %
190 @end
=$$(date
+%s.
%N
); \
191 start
=$$(cat .sc-start-
$*); \
192 rm -f .sc-start-
$*; \
193 awk
-v s
=$$start -v e
=$$end \
194 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev
/null
196 # The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
197 # that computes and prints elapsed time.
199 $(patsubst sc_
%, sc_
%.z
, \
200 $(filter-out $(local-checks-to-skip
), $(local-checks-available
)))
202 syntax-check
: $(local-check
)
207 # This macro searches for a given construct in the selected files and
208 # then takes some action.
210 # Parameters (shell variables):
214 # Regular expression (ERE) denoting either a forbidden construct
215 # or a required construct. Those arguments are exclusive.
219 # Regular expression (ERE) denoting lines to ignore that matched
220 # a prohibit construct. For example, this can be used to exclude
221 # comments that mention why the nearby code uses an alternative
222 # construct instead of the simpler prohibited construct.
224 # in_vc_files | in_files
226 # grep-E-style regexp selecting the files to check. For in_vc_files,
227 # the regexp is used to select matching files from the list of all
228 # version-controlled files; for in_files, it's from the names printed
229 # by "find $(srcdir)". When neither is specified, use all files that
230 # are under version control.
232 # containing | non_containing
234 # Select the files (non) containing strings matching this regexp.
235 # If both arguments are specified then CONTAINING takes
240 # Extra options for grep.
248 # Message to display before to halting execution.
250 # Finally, you may exempt files based on an ERE matching file names.
251 # For example, to exempt from the sc_space_tab check all files with the
252 # .diff suffix, set this Make variable:
254 # exclude_file_name_regexp--sc_space_tab = \.diff$
256 # Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
257 # when filtering by name via in_files, we explicitly filter out matching
258 # names here as well.
260 # Initialize each, so that envvar settings cannot interfere.
267 export non_containing
=
269 export with_grep_options
=
271 # By default, _sc_search_regexp does not ignore case.
273 _ignore_case
= $$(test -n
"$$ignore_case" && printf
%s
-i ||
:)
275 define _sc_say_and_exit
276 dummy
=; : so we do not need a semicolon before each use
; \
277 { printf
'%s\n' "$(ME): $$msg" 1>&2; exit
1; };
280 define _sc_search_regexp
281 dummy
=; : so we do not need a semicolon before each use
; \
284 test -n
"$$prohibit" && test -n
"$$require" \
285 && { msg
='Cannot specify both prohibit and require' \
286 $(_sc_say_and_exit
) } ||
:; \
287 test -z
"$$prohibit" && test -z
"$$require" \
288 && { msg
='Should specify either prohibit or require' \
289 $(_sc_say_and_exit
) } ||
:; \
290 test -z
"$$prohibit" && test -n
"$$exclude" \
291 && { msg
='Use of exclude requires a prohibit pattern' \
292 $(_sc_say_and_exit
) } ||
:; \
293 test -n
"$$in_vc_files" && test -n
"$$in_files" \
294 && { msg
='Cannot specify both in_vc_files and in_files' \
295 $(_sc_say_and_exit
) } ||
:; \
296 test "x$$halt" != x \
297 ||
{ msg
='halt not defined' $(_sc_say_and_exit
) }; \
299 : Filter by file name
; \
300 if
test -n
"$$in_files"; then \
301 files
=$$(find
$(srcdir) |
$(GREP
) -E
"$$in_files" \
302 |
$(GREP
) -Ev
'$(_sc_excl)'); \
304 files
=$$($(VC_LIST_EXCEPT
)); \
305 if
test -n
"$$in_vc_files"; then \
306 files
=$$(echo
"$$files" |
$(GREP
) -E
"$$in_vc_files"); \
310 : Filter by content
; \
312 && test -n
"$$containing" \
313 && { files
=$$(echo
"$$files" | xargs
$(GREP
) -l
"$$containing"); } \
316 && test -n
"$$non_containing" \
317 && { files
=$$(echo
"$$files" | xargs
$(GREP
) -vl
"$$non_containing"); } \
320 : Check for the construct
; \
321 if
test -n
"$$files"; then \
322 if
test -n
"$$prohibit"; then \
324 | xargs
$(GREP
) $$with_grep_options $(_ignore_case
) -nE \
325 "$$prohibit" /dev
/null \
326 |
$(GREP
) -vE
"$${exclude:-^$$}" \
327 && { msg
="$$halt" $(_sc_say_and_exit
) } \
332 $(GREP
) $$with_grep_options $(_ignore_case
) -LE
"$$require" \
334 && { msg
="$$halt" $(_sc_say_and_exit
) } \
341 sc_avoid_if_before_free
:
343 |
$(GREP
) -v useless-if-before-free \
345 $(srcdir)/$(_build-aux
)/useless-if-before-free \
346 $(useless_free_options
) \
347 && { printf
'$(ME): found useless "if"' \
348 ' before "free" above\n' 1>&2; \
352 sc_cast_of_argument_to_free
:
353 @prohibit
='\<free *\( *\(' halt
="don't cast free argument" \
356 sc_cast_of_x_alloc_return_value
:
357 @prohibit
='\*\) *x(m|c|re)alloc\>' \
358 halt
="don't cast x*alloc return value" \
361 sc_cast_of_alloca_return_value
:
362 @prohibit
='\*\) *alloca\>' \
363 halt
="don't cast alloca return value" \
368 halt
='found SPACE-TAB sequence; remove the SPACE' \
371 # Don't use *scanf or the old ato* functions in "real" code.
372 # They provide no error checking mechanism.
373 # Instead, use strto* functions.
374 sc_prohibit_atoi_atof
:
375 @prohibit
='\<([fs]?scanf|ato([filq]|ll)) *\(' \
376 halt
='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
379 # Use STREQ rather than comparing strcmp == 0, or != 0.
382 @prohibit
='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \
383 exclude
='# *define STRN?EQ\(' \
384 halt
='replace strcmp calls above with STREQ/STRNEQ' \
387 # Really. You don't want to use this function.
388 # It may fail to NUL-terminate the destination,
389 # and always NUL-pads out to the specified length.
391 @prohibit
='\<strncpy *\(' \
392 halt
='do not use strncpy, period' \
395 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
396 # Convert all uses automatically, via these two commands:
397 # git grep -l '\<exit *(1)' \
398 # | grep -vEf .x-sc_prohibit_magic_number_exit \
399 # | xargs --no-run-if-empty \
400 # perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
401 # git grep -l '\<exit *(0)' \
402 # | grep -vEf .x-sc_prohibit_magic_number_exit \
403 # | xargs --no-run-if-empty \
404 # perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
405 sc_prohibit_magic_number_exit
:
406 @prohibit
='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]' \
407 exclude
='exit \(77\)|error ?\(((0|77),|[^,]*)' \
408 halt
='use EXIT_* values rather than magic number' \
411 # Using EXIT_SUCCESS as the first argument to error is misleading,
412 # since when that parameter is 0, error does not exit. Use '0' instead.
413 sc_error_exit_success
:
414 @prohibit
='error *\(EXIT_SUCCESS,' \
415 in_vc_files
='\.[chly]$$' \
416 halt
='found error (EXIT_SUCCESS' \
419 # "FATAL:" should be fully upper-cased in error messages
420 # "WARNING:" should be fully upper-cased, or fully lower-cased
421 sc_error_message_warn_fatal
:
423 | xargs
$(GREP
) -nEA2
'[^rp]error *\(' /dev
/null \
424 |
$(GREP
) -E
'"Warning|"Fatal|"fatal' \
425 && { echo
'$(ME): use FATAL, WARNING or warning' 1>&2; \
429 # Error messages should not start with a capital letter
430 sc_error_message_uppercase
:
432 | xargs
$(GREP
) -nEA2
'[^rp]error *\(' /dev
/null \
433 |
$(GREP
) -E
'"[A-Z]' \
434 |
$(GREP
) -vE
'"FATAL|"WARNING|"Java|"C#|PRIuMAX' \
435 && { echo
'$(ME): found capitalized error message' 1>&2; \
439 # Error messages should not end with a period
440 sc_error_message_period
:
442 | xargs
$(GREP
) -nEA2
'[^rp]error *\(' /dev
/null \
443 |
$(GREP
) -E
'[^."]\."' \
444 && { echo
'$(ME): found error message ending in period' 1>&2; \
449 @prohibit
=file
''system \
450 exclude
='/proc/filesystems' \
452 halt
='found use of "file''system"; spell it "file system"' \
455 # Don't use cpp tests of this symbol. All code assumes config.h is included.
456 sc_prohibit_have_config_h
:
457 @prohibit
='^# *if.*HAVE''_CONFIG_H' \
458 halt
='found use of HAVE''_CONFIG_H; remove' \
461 # Nearly all .c files must include <config.h>. However, we also permit this
462 # via inclusion of a package-specific header, if cfg.mk specified one.
463 # config_h_header must be suitable for grep -E.
464 config_h_header ?
= <config\.h
>
466 @require
='^# *include $(config_h_header)' \
467 in_vc_files
='\.c$$' \
468 halt
='the above files do not include <config.h>' \
471 # Print each file name for which the first #include does not match
472 # $(config_h_header). Like grep -m 1, this only looks at the first match.
473 perl_config_h_first_
= \
474 -e
'BEGIN {$$ret = 0}' \
475 -e
'if (/^\# *include\b/) {' \
476 -e
' if (not m{^\# *include $(config_h_header)}) {' \
477 -e
' print "$$ARGV\n";' \
480 -e
' \# Move on to next file after first include' \
483 -e
'END {exit $$ret}'
485 # You must include <config.h> before including any other header file.
486 # This can possibly be via a package-specific header, if given by cfg.mk.
487 sc_require_config_h_first
:
488 @if
$(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$' > /dev
/null
; then \
489 files
=$$($(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$') && \
490 perl
-n
$(perl_config_h_first_
) $$files || \
491 { echo
'$(ME): the above files include some other header' \
492 'before <config.h>' 1>&2; exit
1; } ||
:; \
496 sc_prohibit_HAVE_MBRTOWC
:
497 @prohibit
='\bHAVE_MBRTOWC\b' \
498 halt
="do not use $$prohibit; it is always defined" \
501 # To use this "command" macro, you must first define two shell variables:
502 # h: the header name, with no enclosing <> or ""
503 # re: a regular expression that matches IFF something provided by $h is used.
504 define _sc_header_without_use
505 dummy
=; : so we do not need a semicolon before each use
; \
506 h_esc
=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \
507 if
$(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$' > /dev
/null
; then \
508 files
=$$($(GREP
) -l
'^# *include '"$$h_esc" \
509 $$($(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$')) && \
510 $(GREP
) -LE
"$$re" $$files |
$(GREP
) .
&& \
511 { echo
"$(ME): the above files include $$h but don't use it" \
512 1>&2; exit
1; } ||
:; \
517 # Prohibit the inclusion of assert.h without an actual use of assert.
518 sc_prohibit_assert_without_use
:
519 @h
='assert.h' re
='\<assert *\(' $(_sc_header_without_use
)
521 # Prohibit the inclusion of close-stream.h without an actual use.
522 sc_prohibit_close_stream_without_use
:
523 @h
='close-stream.h' re
='\<close_stream *\(' $(_sc_header_without_use
)
525 # Prohibit the inclusion of getopt.h without an actual use.
526 sc_prohibit_getopt_without_use
:
527 @h
='getopt.h' re
='\<getopt(_long)? *\(' $(_sc_header_without_use
)
529 # Don't include quotearg.h unless you use one of its functions.
530 sc_prohibit_quotearg_without_use
:
531 @h
='quotearg.h' re
='\<quotearg(_[^ ]+)? *\(' $(_sc_header_without_use
)
533 # Don't include quote.h unless you use one of its functions.
534 sc_prohibit_quote_without_use
:
535 @h
='quote.h' re
='\<quote((_n)? *\(|_quoting_options\>)' \
536 $(_sc_header_without_use
)
538 # Don't include this header unless you use one of its functions.
539 sc_prohibit_long_options_without_use
:
540 @h
='long-options.h' re
='\<parse_long_options *\(' \
541 $(_sc_header_without_use
)
543 # Don't include this header unless you use one of its functions.
544 sc_prohibit_inttostr_without_use
:
545 @h
='inttostr.h' re
='\<(off|[iu]max|uint)tostr *\(' \
546 $(_sc_header_without_use
)
548 # Don't include this header unless you use one of its functions.
549 sc_prohibit_ignore_value_without_use
:
550 @h
='ignore-value.h' re
='\<ignore_(value|ptr) *\(' \
551 $(_sc_header_without_use
)
553 # Don't include this header unless you use one of its functions.
554 sc_prohibit_error_without_use
:
556 re
='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
557 $(_sc_header_without_use
)
559 # Don't include xalloc.h unless you use one of its functions.
560 # Consider these symbols:
561 # perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
562 # perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
563 # Divide into two sets on case, and filter each through this:
564 # | sort | perl -MRegexp::Assemble -le \
565 # 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
566 # Note this was produced by the above:
568 #x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
569 # But we can do better, in at least two ways:
570 # 1) take advantage of two "dup"-suffixed strings:
571 # x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
572 # 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
574 # x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
575 _xa1
= x
(((2n?
)?re|char|n
(re|m
)|
[cmz
])alloc|alloc_
(oversized|die
)|
(mem|str
)dup
)
576 _xa2
= X
([CZ
]|N?M
)ALLOC
577 sc_prohibit_xalloc_without_use
:
579 re
='\<($(_xa1)|$(_xa2)) *\('\
580 $(_sc_header_without_use
)
582 # Extract function names:
583 # perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
585 clear|delete|free|get_
(first|next
)|insert|lookup|print_statistics|reset_tuning
586 _hash_fn
= \
<($(_hash_re
)) *\
(
587 _hash_struct
= (struct
)?\
<[Hh
]ash_
(table|tuning
)\
>
588 sc_prohibit_hash_without_use
:
590 re
='$(_hash_fn)|$(_hash_struct)'\
591 $(_sc_header_without_use
)
593 sc_prohibit_cloexec_without_use
:
594 @h
='cloexec.h' re
='\<(set_cloexec_flag|dup_cloexec) *\(' \
595 $(_sc_header_without_use
)
597 sc_prohibit_posixver_without_use
:
598 @h
='posixver.h' re
='\<posix2_version *\(' $(_sc_header_without_use
)
600 sc_prohibit_same_without_use
:
601 @h
='same.h' re
='\<same_name(at)? *\(' $(_sc_header_without_use
)
603 sc_prohibit_hash_pjw_without_use
:
606 $(_sc_header_without_use
)
608 sc_prohibit_safe_read_without_use
:
609 @h
='safe-read.h' re
='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
610 $(_sc_header_without_use
)
612 sc_prohibit_argmatch_without_use
:
614 re
='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \
615 $(_sc_header_without_use
)
617 sc_prohibit_canonicalize_without_use
:
618 @h
='canonicalize.h' \
619 re
='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode|file_name)' \
620 $(_sc_header_without_use
)
622 sc_prohibit_root_dev_ino_without_use
:
623 @h
='root-dev-ino.h' \
624 re
='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
625 $(_sc_header_without_use
)
627 sc_prohibit_openat_without_use
:
629 re
='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat|(FCHMOD|FCHOWN|STAT)AT_INLINE)\>' \
630 $(_sc_header_without_use
)
632 # Prohibit the inclusion of c-ctype.h without an actual use.
633 ctype_re
= isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
634 |isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
635 sc_prohibit_c_ctype_without_use
:
636 @h
='c-ctype.h' re
='\<c_($(ctype_re)) *\(' \
637 $(_sc_header_without_use
)
639 # The following list was generated by running:
640 # man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
641 # | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
643 bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
644 sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
645 siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
646 sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
647 _sig_function_re
= $(subst $(_sp
),|
,$(strip $(_sig_functions
)))
648 # The following were extracted from "man signal.h" manually.
649 _sig_types_and_consts
= \
650 MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
651 SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
652 SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
653 SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
654 sigstack sigval stack_t ucontext_t
655 # generated via this:
656 # perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
658 SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
659 SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
660 SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
661 SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
662 SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
663 SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
664 SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
666 _sig_syms_re
= $(subst $(_sp
),|
,$(strip $(_sig_names
) $(_sig_types_and_consts
)))
668 # Prohibit the inclusion of signal.h without an actual use.
669 sc_prohibit_signal_without_use
:
671 re
='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
672 $(_sc_header_without_use
)
674 # Don't include stdio--.h unless you use one of its functions.
675 sc_prohibit_stdio--_without_use
:
676 @h
='stdio--.h' re
='\<((f(re)?|p)open|tmpfile) *\(' \
677 $(_sc_header_without_use
)
679 # Don't include stdio-safer.h unless you use one of its functions.
680 sc_prohibit_stdio-safer_without_use
:
681 @h
='stdio-safer.h' re
='\<((f(re)?|p)open|tmpfile)_safer *\(' \
682 $(_sc_header_without_use
)
684 # Prohibit the inclusion of strings.h without a sensible use.
685 # Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible.
686 sc_prohibit_strings_without_use
:
688 re
='\<(strn?casecmp|ffs(ll)?)\>' \
689 $(_sc_header_without_use
)
691 # Extract the raw list of symbol names with this:
692 gl_extract_define_simple
= \
693 /^\
# *define ([A-Z]\w+)\(/ and print $$1
694 # Filter out duplicates and convert to a space-separated list:
696 $(shell f
=$(gnulib_dir
)/lib
/intprops.h
; \
697 perl
-lne
'$(gl_extract_define_simple)' $$f |
sort -u | tr
'\n' ' ')
698 # Remove trailing space and convert to a regular expression:
699 _intprops_syms_re
= $(subst $(_sp
),|
,$(strip $(_intprops_names
)))
700 # Prohibit the inclusion of intprops.h without an actual use.
701 sc_prohibit_intprops_without_use
:
703 re
='\<($(_intprops_syms_re)) *\(' \
704 $(_sc_header_without_use
)
706 _stddef_syms_re
= NULL|offsetof|ptrdiff_t|size_t|wchar_t
707 # Prohibit the inclusion of stddef.h without an actual use.
708 sc_prohibit_stddef_without_use
:
710 re
='\<($(_stddef_syms_re))\>' \
711 $(_sc_header_without_use
)
713 _de1
= dirfd|
(close|
(fd
)?open|read|rewind|seek|tell
)dir(64)?
(_r
)?
714 _de2
= (versionsort|struct dirent|getdirentries|alphasort|scandir
(at
)?
)(64)?
715 _de3
= MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
716 _dirent_syms_re
= $(_de1
)|
$(_de2
)|
$(_de3
)
717 # Prohibit the inclusion of dirent.h without an actual use.
718 sc_prohibit_dirent_without_use
:
720 re
='\<($(_dirent_syms_re))\>' \
721 $(_sc_header_without_use
)
723 # Prohibit the inclusion of verify.h without an actual use.
724 sc_prohibit_verify_without_use
:
726 re
='\<(verify(true|expr)?|assume|static_assert) *\(' \
727 $(_sc_header_without_use
)
729 # Don't include xfreopen.h unless you use one of its functions.
730 sc_prohibit_xfreopen_without_use
:
731 @h
='xfreopen.h' re
='\<xfreopen *\(' $(_sc_header_without_use
)
734 @prohibit
='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
735 halt
='do not use HAVE''_FCNTL_H or O'_NDELAY \
738 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
740 # Each nonempty ChangeLog line must start with a year number, or a TAB.
742 @prohibit
='^[^12 ]' \
743 in_vc_files
='^ChangeLog$$' \
744 halt
='found unexpected prefix in a ChangeLog' \
747 # Ensure that each .c file containing a "main" function also
748 # calls bindtextdomain.
750 @require
='bindtextdomain *\(' \
751 in_vc_files
='\.c$$' \
752 containing
='\<main *(' \
753 halt
='the above files do not call bindtextdomain' \
756 # Require that the final line of each test-lib.sh-using test be this one:
758 # Note: this test requires GNU grep's --label= option.
759 Exit_witness_file ?
= tests
/test-lib.sh
760 Exit_base
:= $(notdir $(Exit_witness_file
))
761 sc_require_test_exit_idiom
:
762 @if
test -f
$(srcdir)/$(Exit_witness_file
); then \
764 for i in
$$($(GREP
) -l
-F
'srcdir/$(Exit_base)' \
765 $$($(VC_LIST
) tests
)); do \
766 tail
-n1
$$i |
$(GREP
) '^Exit .' > /dev
/null \
767 && : ||
{ die
=1; echo
$$i; } \
770 { echo
1>&2 '$(ME): the final line in each of the above is not:'; \
771 echo
1>&2 'Exit something'; \
777 halt
='found trailing blank(s)' \
778 exclude
='^Binary file .* matches$$' \
781 # Match lines like the following, but where there is only one space
782 # between the options and the description:
783 # -D, --all-repeated[=delimit-method] print all duplicate lines\n
784 longopt_re
= --[a-z
][0-9A-Za-z-
]*(\
[?
=[0-9A-Za-z-
]*\
]?
)?
785 sc_two_space_separator_in_usage
:
786 @prohibit
='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
787 halt
='help2man requires at least two spaces between an option and its description'\
790 # A regexp matching function names like "error" that may be used
791 # to emit translatable messages.
792 _gl_translatable_diag_func_re ?
= error
794 # Look for diagnostics that aren't marked for translation.
795 # This won't find any for which error's format string is on a separate line.
796 sc_unmarked_diagnostics
:
797 @prohibit
='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
798 exclude
='(_|ngettext ?)\(' \
799 halt
='found unmarked diagnostic(s)' \
802 # Avoid useless parentheses like those in this example:
803 # #if defined (SYMBOL) || defined (SYM2)
804 sc_useless_cpp_parens
:
805 @prohibit
='^# *if .*defined *\(' \
806 halt
='found useless parentheses in cpp directive' \
809 # List headers for which HAVE_HEADER_H is always true, assuming you are
810 # using the appropriate gnulib module. CAUTION: for each "unnecessary"
811 # #if HAVE_HEADER_H that you remove, be sure that your project explicitly
812 # requires the gnulib module that guarantees the usability of that header.
813 gl_assured_headers_
= \
814 cd
$(gnulib_dir
)/lib
&& echo
*.in.h|
$(SED
) 's/\.in\.h//g'
816 # Convert the list of names to upper case, and replace each space with "|".
817 az_
= abcdefghijklmnopqrstuvwxyz
818 AZ_
= ABCDEFGHIJKLMNOPQRSTUVWXYZ
819 gl_header_upper_case_or_
= \
820 $$($(gl_assured_headers_
) \
821 | tr
$(az_
)/.
- $(AZ_
)___ \
824 sc_prohibit_always_true_header_tests
:
825 @or
=$(gl_header_upper_case_or_
); \
826 re
="HAVE_($$or)_H"; \
827 prohibit
='\<'"$$re"'\>' \
828 halt
=$$(printf
'%s\n' \
829 'do not test the above HAVE_<header>_H symbol(s);' \
830 ' with the corresponding gnulib module, they are always true') \
833 sc_prohibit_defined_have_decl_tests
:
834 @prohibit
='(#[ ]*ifn?def|\<defined)\>[ (]+HAVE_DECL_' \
835 halt
='HAVE_DECL macros are always defined' \
838 # ==================================================================
839 gl_other_headers_ ?
= \
844 # Perl -lne code to extract "significant" cpp-defined symbols from a
845 # gnulib header file, eliminating a few common false-positives.
846 # The exempted names below are defined only conditionally in gnulib,
847 # and hence sometimes must/may be defined in application code.
848 gl_extract_significant_defines_
= \
849 /^\
# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
850 && $$2 !~
/(?
:rpl_|_used_without_
)/\
851 && $$1 !~
/^
(?
:NSIG|ENODATA
)$$/\
852 && $$1 !~
/^
(?
:SA_RESETHAND|SA_RESTART
)$$/\
855 # Create a list of regular expressions matching the names
856 # of macros that are guaranteed to be defined by parts of gnulib.
858 gen_h
=$(gl_generated_headers_
); \
859 (cd
$(gnulib_dir
)/lib
; \
860 for f in
*.in.h
$(gl_other_headers_
); do \
862 && perl
-lne
'$(gl_extract_significant_defines_)' $$f; \
865 |
$(SED
) 's/^/^ *# *(define|undef) */;s/$$/\\>/'
868 # Don't define macros that we already get from gnulib header files.
869 sc_prohibit_always-defined_macros
:
870 @if
test -d
$(gnulib_dir
); then \
871 case
$$(echo
all: |
$(GREP
) -l
-f
- Makefile
) in Makefile
);; *) \
872 echo
'$(ME): skipping $@: you lack GNU grep' 1>&2; exit
0;; \
874 regex
=$$($(def_sym_regex
)); export regex
; \
876 | xargs sh
-c
'echo $$regex | $(GREP) -E -f - "$$@"' \
878 && { printf
'$(ME): define the above' \
879 ' via some gnulib .h file\n' 1>&2; \
883 # ==================================================================
885 # Prohibit checked in backup files.
886 sc_prohibit_backup_files
:
887 @
$(VC_LIST
) |
$(GREP
) '~$$' && \
888 { echo
'$(ME): found version controlled backup file' 1>&2; \
891 # Require the latest GPL.
893 @prohibit
='either ''version [^3]' \
894 halt
='GPL vN, N!=3' \
897 # Require the latest GFDL. Two regexp, since some .texi files end up
898 # line wrapping between 'Free Documentation License,' and 'Version'.
899 _GFDL_regexp
= (Free
''Documentation.
*Version
1\.
[^
3]|Version
1\.
[^
3] or any
)
901 @prohibit
='$(_GFDL_regexp)' \
902 halt
='GFDL vN, N!=3' \
905 # Don't use Texinfo's @acronym{}.
906 # https://lists.gnu.org/r/bug-gnulib/2010-03/msg00321.html
907 texinfo_suffix_re_ ?
= \.
(txi|texi
(nfo
)?
)$$
909 @prohibit
='@acronym\{' \
910 in_vc_files
='$(texinfo_suffix_re_)' \
911 halt
='found use of Texinfo @acronym{}' \
915 Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
917 sc_prohibit_cvs_keyword
:
918 @prohibit
='\$$($(cvs_keywords))\$$' \
919 halt
='do not use CVS keyword expansion' \
922 # This Perl code is slightly obfuscated. Not only is each "$" doubled
923 # because it's in a Makefile, but the $$c's are comments; we cannot
924 # use "#" due to the way the script ends up concatenated onto one line.
925 # It would be much more concise, and would produce better output (including
926 # counts) if written as:
927 # perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
928 # but that would be far less efficient, reading the entire contents
929 # of each file, rather than just the last two bytes of each.
930 # In addition, while the code below detects both blank lines and a missing
931 # newline at EOF, the above detects only the former.
933 # This is a perl script that is expected to be the single-quoted argument
934 # to a command-line "-le". The remaining arguments are file names.
935 # Print the name of each file that does not end in exactly one newline byte.
936 # I.e., warn if there are blank lines (2 or more newlines), or if the
937 # last byte is not a newline. However, currently we don't complain
938 # about any file that contains exactly one byte.
939 # Exit nonzero if at least one such file is found, otherwise, exit 0.
940 # Warn about, but otherwise ignore open failure. Ignore seek/read failure.
942 # Use this if you want to remove trailing empty lines from selected files:
943 # perl -pi -0777 -e 's/\n\n+$/\n/' files...
945 require_exactly_one_NL_at_EOF_
= \
946 foreach my
$$f (@ARGV
) \
948 open F
, "<", $$f or
(warn
"failed to open $$f: $$!\n"), next
; \
949 my
$$p = sysseek
(F
, -2, 2); \
950 my
$$c = "seek failure probably means file has < 2 bytes; ignore"; \
951 my
$$last_two_bytes; \
952 defined
$$p and
$$p = sysread F
, $$last_two_bytes, 2; \
954 $$c = "ignore read failure"; \
955 $$p && ($$last_two_bytes eq
"\n\n" \
956 || substr
($$last_two_bytes,1) ne
"\n") \
957 and
(print $$f), $$fail=1; \
959 END
{ exit defined
$$fail }
960 sc_prohibit_empty_lines_at_EOF
:
962 | xargs perl
-le
'$(require_exactly_one_NL_at_EOF_)' \
963 ||
{ echo
'$(ME): empty line(s) or no newline at EOF' 1>&2; \
967 # Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
968 # This is a bit of a kludge, since it prevents use of the string
969 # even in comments, but for now it does the job with no false positives.
970 sc_prohibit_stat_st_blocks
:
971 @prohibit
='[.>]st_blocks' \
972 halt
='do not use st_blocks; use ST_NBLOCKS' \
975 # Make sure we don't define any S_IS* macros in src/*.c files.
976 # They're already defined via gnulib's sys/stat.h replacement.
977 sc_prohibit_S_IS_definition
:
978 @prohibit
='^ *# *define *S_IS' \
979 halt
='do not define S_IS* macros; include <sys/stat.h>' \
982 # Perl block to convert a match to FILE_NAME:LINENO:TEST,
983 # that is shared by two definitions below.
984 perl_filename_lineno_text_
= \
986 -e
' $$n = ($$` =~ tr/\n/\n/ + 1);' \
987 -e
' ($$v = $$&) =~ s/\n/\\n/g;' \
988 -e
' print "$$ARGV:$$n:$$v\n";' \
991 prohibit_doubled_words_
= \
992 the then in an on if is it but for or at and do to
993 # expand the regex before running the check to avoid using expensive captures
994 prohibit_doubled_word_expanded_
= \
995 $(join $(prohibit_doubled_words_
),$(addprefix \s
+,$(prohibit_doubled_words_
)))
996 prohibit_doubled_word_RE_ ?
= \
997 /\b(?
:$(subst $(_sp
),|
,$(prohibit_doubled_word_expanded_
)))\b/gims
998 prohibit_doubled_word_
= \
999 -e
'while ($(prohibit_doubled_word_RE_))' \
1000 $(perl_filename_lineno_text_
)
1002 # Define this to a regular expression that matches
1003 # any filename:dd:match lines you want to ignore.
1004 # The default is to ignore no matches.
1005 ignore_doubled_word_match_RE_ ?
= ^
$$
1007 sc_prohibit_doubled_word
:
1008 @
$(VC_LIST_EXCEPT
) \
1009 | xargs perl
-n
-0777 $(prohibit_doubled_word_
) \
1010 |
$(GREP
) -vE
'$(ignore_doubled_word_match_RE_)' \
1012 && { echo
'$(ME): doubled words' 1>&2; exit
1; } \
1015 # A regular expression matching undesirable combinations of words like
1016 # "can not"; this matches them even when the two words appear on different
1017 # lines, but not when there is an intervening delimiter like "#" or "*".
1018 # Similarly undesirable, "See @xref{...}", since an @xref should start
1019 # a sentence. Explicitly prohibit any prefix of "see" or "also".
1020 # Also prohibit a prefix matching "\w+ +".
1021 # @pxref gets the same see/also treatment and should be parenthesized;
1022 # presume it must *not* start a sentence.
1023 # POSIX spells it "timestamp" rather than "time\s+stamp", so we do, too.
1024 bad_xref_re_ ?
= (?
:[\w
,:;] +|
(?
:see|also
)\s
+)\@xref\
{
1025 bad_pxref_re_ ?
= (?
:[.
!?
]|
(?
:see|also
))\s
+\@pxref\
{
1026 prohibit_undesirable_word_seq_RE_ ?
= \
1027 /(?
:\bcan\s
+not
\b|
\btime\s
+stamps?
\b|
$(bad_xref_re_
)|
$(bad_pxref_re_
))/gims
1028 prohibit_undesirable_word_seq_
= \
1029 -e
'while ($(prohibit_undesirable_word_seq_RE_))' \
1030 $(perl_filename_lineno_text_
)
1031 # Define this to a regular expression that matches
1032 # any filename:dd:match lines you want to ignore.
1033 # The default is to ignore no matches.
1034 ignore_undesirable_word_sequence_RE_ ?
= ^
$$
1036 sc_prohibit_undesirable_word_seq
:
1037 @
$(VC_LIST_EXCEPT
) \
1038 | xargs perl
-n
-0777 $(prohibit_undesirable_word_seq_
) \
1039 |
$(GREP
) -vE
'$(ignore_undesirable_word_sequence_RE_)' \
1041 && { echo
'$(ME): undesirable word sequence' >&2; exit
1; } \
1044 # Except for shell files and for loops, double semicolon is probably a mistake
1045 sc_prohibit_double_semicolon
:
1046 @prohibit
='; *;[ {} \]*(/[/*]|$$)' \
1047 in_vc_files
='\.[chly]$$' \
1048 exclude
='\bfor *\(.*\)' \
1049 halt
="Double semicolon detected" \
1050 $(_sc_search_regexp
)
1052 _ptm1
= use
"test C1 && test C2", not
"test C1 -''a C2"
1053 _ptm2
= use
"test C1 || test C2", not
"test C1 -''o C2"
1054 # Using test's -a and -o operators is not portable.
1055 # We prefer test over [, since the latter is spelled [[ in configure.ac.
1056 sc_prohibit_test_minus_ao
:
1057 @prohibit
='(\<test| \[+) .+ -[ao] ' \
1058 halt
='$(_ptm1); $(_ptm2)' \
1059 $(_sc_search_regexp
)
1061 # Avoid a test bashism.
1062 sc_prohibit_test_double_equal
:
1063 @prohibit
='(\<test| \[+) .+ == ' \
1064 containing
='#! */bin/[a-z]*sh' \
1065 halt
='use "test x = x", not "test x =''= x"' \
1066 $(_sc_search_regexp
)
1068 # Each program that uses proper_name_utf8 must link with one of the
1069 # ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
1070 # The perl -0777 invocation below extracts the possibly-multi-line
1071 # definition of LDADD from the appropriate Makefile.am and exits 0
1072 # when it contains "ICONV".
1073 sc_proper_name_utf8_requires_ICONV
:
1074 @progs
=$$($(VC_LIST_EXCEPT
) \
1075 | xargs
$(GREP
) -l
'proper_name_utf8 ''("'); \
1076 if
test "x$$progs" != x
; then \
1078 for p in
$$progs; do \
1079 dir=$$(dirname
"$$p"); \
1081 -ne
'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \
1082 $$dir/Makefile.am
&& continue
; \
1083 base
=$$(basename "$$p" .c
); \
1084 $(GREP
) "$${base}_LDADD.*ICONV)" $$dir/Makefile.am
> /dev
/null \
1085 ||
{ fail
=1; echo
1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
1087 test $$fail = 1 && \
1088 { echo
1>&2 '$(ME): the above do not link with any ICONV library'; \
1092 # Warn about "c0nst struct Foo const foo[]",
1093 # but not about "char const *const foo" or "#define const const".
1095 @prohibit
='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
1096 halt
='redundant "const" in declarations' \
1097 $(_sc_search_regexp
)
1099 sc_const_long_option
:
1100 @prohibit
='^ *static.*struct option ' \
1101 exclude
='const struct option|struct option const' \
1102 halt
='add "const" to the above declarations' \
1103 $(_sc_search_regexp
)
1106 $$($(SED
) -n
'/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
1109 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \
1113 # Ensure that we don't accidentally insert an entry into an old NEWS block.
1115 @if
test -f
$(srcdir)/NEWS
; then \
1116 test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
1117 { echo
'$(ME): you have modified old NEWS' 1>&2; exit
1; }; \
1120 # Update the hash stored above. Do this after each release and
1121 # for any corrections to old entries.
1122 update-NEWS-hash
: NEWS
1123 perl
-pi
-e
's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \
1126 # Ensure that we use only the standard $(VAR) notation,
1127 # not @...@ in Makefile.am, now that we can rely on automake
1128 # to emit a definition for each substituted variable.
1129 # However, there is still one case in which @VAR@ use is not just
1130 # legitimate, but actually required: when augmenting an automake-defined
1131 # variable with a prefix. For example, gettext uses this:
1132 # MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
1133 # otherwise, makeinfo would put German or French (current locale)
1134 # navigation hints in the otherwise-English documentation.
1136 # Allow the package to add exceptions via a hook in cfg.mk;
1137 # for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
1138 # setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
1139 _makefile_at_at_check_exceptions ?
=
1140 sc_makefile_at_at_check
:
1141 @perl
-ne
'/\@\w+\@/' \
1142 -e
' && !/(\w+)\s+=.*\@\1\@$$/' \
1143 -e
''$(_makefile_at_at_check_exceptions
) \
1144 -e
'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
1145 $$($(VC_LIST_EXCEPT
) |
$(GREP
) -E
'(^|/)(Makefile\.am|[^/]+\.mk)$$') \
1146 && { echo
'$(ME): use $$(...), not @...@' 1>&2; exit
1; } ||
:
1149 $(AM_V_GEN
)if
$(SED
) -n
$(news-check-lines-spec
)p
$< \
1150 |
$(GREP
) -E
$(news-check-regexp
) >/dev
/null
; then \
1153 echo
'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
1157 sc_makefile_TAB_only_indentation
:
1158 @prohibit
='^ [ ]{8}' \
1159 in_vc_files
='akefile|\.mk$$' \
1160 halt
='found TAB-8-space indentation' \
1161 $(_sc_search_regexp
)
1164 @prohibit
='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
1165 in_vc_files
='(^configure\.ac|\.m4)$$' \
1166 halt
='quote the first arg to AC_DEF*' \
1167 $(_sc_search_regexp
)
1169 fix_po_file_diag
= \
1170 'you have changed the set of files with translatable diagnostics;\n\
1171 apply the above patch\n'
1173 # Generate a list of files in which to search for translatable strings.
1174 perl_translatable_files_list_
= \
1175 -e
'foreach $$file (@ARGV) {' \
1176 -e
' \# Consider only file extensions with one or two letters' \
1177 -e
' $$file =~ /\...?$$/ or next;' \
1178 -e
' \# Ignore m4 and mk files' \
1179 -e
' $$file =~ /\.m[4k]$$/ and next;' \
1180 -e
' \# Ignore a .c or .h file with a corresponding .l or .y file' \
1181 -e
' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \
1183 -e
' \# Skip unreadable files' \
1184 -e
' -r $$file or next;' \
1185 -e
' print "$$file ";' \
1188 # Verify that all source files using _() (more specifically, files that
1189 # match $(_gl_translatable_string_re)) are listed in po/POTFILES.in.
1190 po_file ?
= $(srcdir)/po
/POTFILES.in
1191 generated_files ?
= $(srcdir)/lib
/*.
[ch
]
1192 _gl_translatable_string_re ?
= \b(N?_|gettext
*)\
([^
)"]*("|
$$)
1194 @if
test -f
$(po_file
); then \
1195 $(GREP
) -E
-v
'^(#|$$)' $(po_file
) \
1196 |
$(GREP
) -v
'^src/false\.c$$' |
sort > $@
-1; \
1197 { $(VC_LIST_EXCEPT
); echo
$(generated_files
); } \
1198 | xargs perl
$(perl_translatable_files_list_
) \
1199 | xargs
$(GREP
) -E
-l
'$(_gl_translatable_string_re)' \
1200 |
$(SED
) 's|^$(_dot_escaped_srcdir)/||' \
1202 diff
-u
-L
$(po_file
) -L
$(po_file
) $@
-1 $@
-2 \
1203 ||
{ printf
'$(ME): '$(fix_po_file_diag
) 1>&2; exit
1; }; \
1207 # Sometimes it is useful to change the PATH environment variable
1208 # in Makefiles. When doing so, it's better not to use the Unix-centric
1209 # path separator of ':', but rather the automake-provided '$(PATH_SEPARATOR)'.
1210 msg
= 'Do not use ":" above; use $$(PATH_SEPARATOR) instead'
1211 sc_makefile_path_separator_check
:
1212 @prohibit
='PATH[=].*:' \
1213 in_vc_files
='akefile|\.mk$$' \
1215 $(_sc_search_regexp
)
1217 # Check that 'make alpha' will not fail at the end of the process,
1218 # i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release)
1221 $(AM_V_GEN
)if
test -d
$(release_archive_dir
); then \
1222 for file in
$(DIST_ARCHIVES
); do \
1223 for p in .
/ $(release_archive_dir
)/; do \
1224 test -e
$$p$$file || continue
; \
1226 ||
{ echo ERROR
: $$p$$file is not writable
; fail
=1; }; \
1229 test "$$fail" && exit
1 ||
: ; \
1233 v_etc_file
= $(gnulib_dir
)/lib
/version-etc.c
1234 sample-test
= tests
/sample-test
1235 texi
= doc
/$(PACKAGE
).texi
1236 # Make sure that the copyright date in $(v_etc_file) is up to date.
1237 # Do the same for the $(sample-test) and the main doc/.texi file.
1239 @require
='enum { COPYRIGHT_YEAR = '$$(date
+%Y
)' };' \
1240 in_files
=$(v_etc_file
) \
1241 halt
='out of date copyright in $(v_etc_file); update it' \
1242 $(_sc_search_regexp
)
1243 @require
='# Copyright \(C\) '$$(date
+%Y
)' Free' \
1244 in_vc_files
=$(sample-test
) \
1245 halt
='out of date copyright in $(sample-test); update it' \
1246 $(_sc_search_regexp
)
1247 @require
='Copyright @copyright\{\} .*'$$(date
+%Y
) \
1248 in_vc_files
=$(texi
) \
1249 halt
='out of date copyright in $(texi); update it' \
1250 $(_sc_search_regexp
)
1252 # If tests/help-version exists and seems to be new enough, assume that its
1253 # use of init.sh and path_prepend_ is correct, and ensure that every other
1254 # use of init.sh is identical.
1255 # This is useful because help-version cross-checks prog --version
1256 # with $(VERSION), which verifies that its path_prepend_ invocation
1257 # sets PATH correctly. This is an inexpensive way to ensure that
1258 # the other init.sh-using tests also get it right.
1259 _hv_file ?
= $(srcdir)/tests
/help-version
1260 _hv_regex_weak ?
= ^
*\. .
*/init\.sh
"
1261 # Fix syntax-highlighters "
1262 _hv_regex_strong ?
= ^
*\.
"\$${srcdir=\.}/init\.sh"
1263 sc_cross_check_PATH_usage_in_tests
:
1264 @if
test -f
$(_hv_file
); then \
1265 $(GREP
) -l
'VERSION mismatch' $(_hv_file
) >/dev
/null \
1266 ||
{ echo
"$@: skipped: no such file: $(_hv_file)" 1>&2; \
1268 $(GREP
) -lE
'$(_hv_regex_strong)' $(_hv_file
) >/dev
/null \
1269 ||
{ echo
"$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
1271 good
=$$($(GREP
) -E
'$(_hv_regex_strong)' $(_hv_file
)); \
1273 | xargs
$(GREP
) -lE
'$(_hv_regex_weak)' \
1274 | xargs
$(GREP
) -LFx
"$$good" \
1276 && { printf
"$(ME): the above files use" \
1277 " path_prepend_ inconsistently\n" 1>&2; \
1282 # BRE regex of file contents to identify a test script.
1283 _test_script_regex ?
= \
<init\.sh\
>
1285 # In tests, use "compare expected actual", not the reverse.
1286 sc_prohibit_reversed_compare_failure
:
1287 @prohibit
='\<compare [^ ]+ ([^ ]*exp|/dev/null)' \
1288 containing
='$(_test_script_regex)' \
1289 halt
='reversed compare arguments' \
1290 $(_sc_search_regexp
)
1292 # #if HAVE_... will evaluate to false for any non numeric string.
1293 # That would be flagged by using -Wundef, however gnulib currently
1294 # tests many undefined macros, and so we can't enable that option.
1295 # So at least preclude common boolean strings as macro values.
1297 @prohibit
='^#define.*(yes|no|true|false)$$' \
1298 in_files
='$(CONFIG_INCLUDE)' \
1299 halt
='Use 0 or 1 for macro values' \
1300 $(_sc_search_regexp
)
1302 # Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
1303 # not be constant, or might overflow a stack. In general, use PATH_MAX as
1304 # a limit, not an array or alloca size.
1305 sc_prohibit_path_max_allocation
:
1306 @prohibit
='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \
1307 halt
='Avoid stack allocations of size PATH_MAX' \
1308 $(_sc_search_regexp
)
1310 sc_vulnerable_makefile_CVE-2009-4029
:
1311 @prohibit
='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
1312 in_files
='(^|/)Makefile\.in$$' \
1313 halt
=$$(printf
'%s\n' \
1314 'the above files are vulnerable; beware of running' \
1315 ' "make dist*" rules, and upgrade to fixed automake' \
1316 ' see https://bugzilla.redhat.com/show_bug.cgi?id=542609 for details') \
1317 $(_sc_search_regexp
)
1319 sc_vulnerable_makefile_CVE-2012-3386
:
1320 @prohibit
='chmod a\+w \$$\(distdir\)' \
1321 in_files
='(^|/)Makefile\.in$$' \
1322 halt
=$$(printf
'%s\n' \
1323 'the above files are vulnerable; beware of running' \
1324 ' "make distcheck", and upgrade to fixed automake' \
1325 ' see https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-3386 for details') \
1326 $(_sc_search_regexp
)
1329 $(AM_V_GEN
)(unset CDPATH
; cd
$(srcdir) && $(VC
) diff
) > vc-diffs ||
:
1330 $(AM_V_at
)if
test -s vc-diffs
; then \
1332 echo
"Some files are locally modified:" 1>&2; \
1338 rel-files
= $(DIST_ARCHIVES
)
1340 gnulib-version
= $$(cd
$(gnulib_dir
) \
1341 && { git describe || git rev-parse
--short
=10 HEAD
; } )
1342 bootstrap-tools ?
= autoconf
,automake
,gnulib
1344 gpgv
= $$(gpgv2
--version
>/dev
/null
&& echo gpgv2 || echo gpgv
)
1345 # If it's not already specified, derive the GPG key ID from
1346 # the signed tag we've just applied to mark this release.
1349 && git cat-file tag v
$(VERSION
) \
1350 |
$(gpgv
) --status-fd
1 --keyring
/dev
/null
- - 2>/dev
/null \
1351 | awk
'/^\[GNUPG:\] ERRSIG / {print $$3; exit}')
1353 translation_project_ ?
= coordinator@translationproject.org
1355 # Make info-gnu the default only for a stable release.
1356 announcement_Cc_stable
= $(translation_project_
), $(PACKAGE_BUGREPORT
)
1357 announcement_mail_headers_stable
= \
1358 To
: info-gnu@gnu.org \
1359 Cc
: $(announcement_Cc_
) \
1360 Mail-Followup-To
: $(PACKAGE_BUGREPORT
)
1362 announcement_Cc_alpha
= $(translation_project_
)
1363 announcement_mail_headers_alpha
= \
1364 To
: $(PACKAGE_BUGREPORT
) \
1365 Cc
: $(announcement_Cc_
)
1367 announcement_mail_Cc_beta
= $(announcement_mail_Cc_alpha
)
1368 announcement_mail_headers_beta
= $(announcement_mail_headers_alpha
)
1370 announcement_mail_Cc_ ?
= $(announcement_mail_Cc_
$(release-type
))
1371 announcement_mail_headers_ ?
= $(announcement_mail_headers_
$(release-type
))
1372 announcement
: NEWS ChangeLog
$(rel-files
)
1373 # Not $(AM_V_GEN) since the output of this command serves as
1374 # announcement message: it would start with " GEN announcement".
1375 $(AM_V_at
)$(srcdir)/$(_build-aux
)/announce-gen \
1376 --mail-headers
='$(announcement_mail_headers_)' \
1377 --release-type
=$(release-type
) \
1378 --package
=$(PACKAGE
) \
1379 --prev
=$(PREV_VERSION
) \
1381 --gpg-key-id
=$(gpg_key_ID
) \
1382 --srcdir=$(srcdir) \
1383 --news
=$(srcdir)/NEWS \
1384 --bootstrap-tools
=$(bootstrap-tools
) \
1385 $$(case
,$(bootstrap-tools
), in
(*,gnulib
,*) \
1386 echo
--gnulib-version
=$(gnulib-version
);; esac
) \
1387 --no-print-checksums \
1388 $(addprefix --url-dir
=, $(url_dir_list
))
1390 .PHONY
: release-commit
1392 $(AM_V_GEN
)cd
$(srcdir) \
1393 && $(_build-aux
)/do-release-commit-and-tag \
1394 -C
$(abs_builddir
) $(RELEASE
)
1396 ## ---------------- ##
1397 ## Updating files. ##
1398 ## ---------------- ##
1400 ftp-gnu
= https
://ftp.gnu.org
/gnu
1401 www-gnu
= https
://www.gnu.org
1403 upload_dest_dir_ ?
= $(PACKAGE
)
1405 $(srcdir)/$(_build-aux
)/gnupload
$(GNUPLOADFLAGS
) \
1406 --to
$(gnu_rel_host
):$(upload_dest_dir_
) \
1408 emit_upload_commands
:
1409 @echo
=====================================
1410 @echo
=====================================
1411 @echo
'$(upload_command)'
1412 @echo
'# send the ~/announce-$(my_distdir) e-mail'
1413 @echo
=====================================
1414 @echo
=====================================
1418 $(AM_V_GEN
)$(upload_command
)
1420 define emit-commit-log
1421 printf
'%s\n' 'maint: post-release administrivia' '' \
1422 '* NEWS: Add header line for next release.' \
1423 '* .prev-version: Record previous version.' \
1424 '* cfg.mk (old_NEWS_hash): Auto-update.'
1427 .PHONY
: no-submodule-changes
1428 no-submodule-changes
:
1429 $(AM_V_GEN
)if
test -d
$(srcdir)/.git \
1430 && git
--version
>/dev
/null
2>&1; then \
1431 diff
=$$(cd
$(srcdir) && git submodule
-q
foreach \
1432 git diff-index
--name-only HEAD
) \
1434 case
$$diff in
'') ;; \
1435 *) echo
'$(ME): submodule files are locally modified:'; \
1436 echo
"$$diff"; exit
1;; esac
; \
1441 submodule-checks ?
= no-submodule-changes public-submodule-commit
1443 # Ensure that each sub-module commit we're using is public.
1444 # Without this, it is too easy to tag and release code that
1445 # cannot be built from a fresh clone.
1446 .PHONY
: public-submodule-commit
1447 public-submodule-commit
:
1448 $(AM_V_GEN
)if
test -d
$(srcdir)/.git \
1449 && git
--version
>/dev
/null
2>&1; then \
1451 git submodule
--quiet
foreach \
1452 'test "$$(git rev-parse "$$sha1")" \
1453 = "$$(git merge-base origin "$$sha1")"' \
1454 ||
{ echo
'$(ME): found non-public submodule commit' >&2; \
1459 # This rule has a high enough utility/cost ratio that it should be a
1460 # dependent of "check" by default. However, some of us do occasionally
1461 # commit a temporary change that deliberately points to a non-public
1462 # submodule commit, and want to be able to use rules like "make check".
1463 # In that case, run e.g., "make check gl_public_submodule_commit="
1464 # to disable this test.
1465 gl_public_submodule_commit ?
= public-submodule-commit
1466 check: $(gl_public_submodule_commit
)
1468 .PHONY
: alpha beta stable release
1469 ALL_RECURSIVE_TARGETS
+= alpha beta stable
1470 alpha beta stable
: $(local-check
) writable-files
$(submodule-checks
)
1471 $(AM_V_GEN
)test $@
= stable \
1472 && { echo
$(VERSION
) |
$(GREP
) -E
'^[0-9]+(\.[0-9]+)+$$' \
1473 ||
{ echo
"invalid version string: $(VERSION)" 1>&2; exit
1;};}\
1475 $(AM_V_at
)$(MAKE
) vc-diff-check
1476 $(AM_V_at
)$(MAKE
) news-check
1477 $(AM_V_at
)$(MAKE
) distcheck
1478 $(AM_V_at
)$(MAKE
) dist
1479 $(AM_V_at
)$(MAKE
) $(release-prep-hook
) RELEASE_TYPE
=$@
1480 $(AM_V_at
)$(MAKE
) -s emit_upload_commands RELEASE_TYPE
=$@
1483 $(AM_V_GEN
)$(MAKE
) _version
1484 $(AM_V_GEN
)$(MAKE
) $(release-type
)
1486 # Override this in cfg.mk if you follow different procedures.
1487 release-prep-hook ?
= release-prep
1489 gl_noteworthy_news_
= * Noteworthy changes in release ?.?
(????
-??
-??
) [?
]
1490 .PHONY
: release-prep
1492 $(AM_V_GEN
)$(MAKE
) --no-print-directory
-s announcement \
1493 > ~
/announce-
$(my_distdir
)
1494 $(AM_V_at
)if
test -d
$(release_archive_dir
); then \
1495 ln
$(rel-files
) $(release_archive_dir
); \
1496 chmod a-w
$(rel-files
); \
1498 $(AM_V_at
)echo
$(VERSION
) > $(prev_version_file
)
1499 $(AM_V_at
)$(MAKE
) update-NEWS-hash
1500 $(AM_V_at
)perl
-pi \
1501 -e
'$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' \
1503 $(AM_V_at
)msg
=$$($(emit-commit-log
)) || exit
1; \
1504 cd
$(srcdir) && $(VC
) commit
-m
"$$msg" -a
1506 # Override this with e.g., -s $(srcdir)/some_other_name.texi
1507 # if the default $(PACKAGE)-derived name doesn't apply.
1512 $(AM_V_GEN
)test -z
"$(manual_title)" \
1513 && { echo
define manual_title in cfg.mk
1>&2; exit
1; } ||
:
1514 $(AM_V_at
)cd
'$(srcdir)/doc'; \
1515 $(SHELL
) ..
/$(_build-aux
)/gendocs.sh
$(gendocs_options_
) \
1516 -o
'$(abs_builddir)/doc/manual' \
1517 --email
$(PACKAGE_BUGREPORT
) $(PACKAGE
) \
1518 "$(PACKAGE_NAME) - $(manual_title)"
1519 $(AM_V_at
)echo
" *** Upload the doc/manual directory to web-cvs."
1521 .PHONY
: web-manual-update
1523 $(AM_V_GEN
)cd
$(srcdir) \
1524 && $(_build-aux
)/gnu-web-doc-update
-C
$(abs_builddir
)
1530 $(MAKE
) $(AM_MAKEFLAGS
) clean
1531 lcov
--directory .
--zerocounters
1533 COVERAGE_CCOPTS ?
= "-g --coverage"
1534 COVERAGE_OUT ?
= doc
/coverage
1537 $(MAKE
) $(AM_MAKEFLAGS
) CFLAGS
=$(COVERAGE_CCOPTS
) CXXFLAGS
=$(COVERAGE_CCOPTS
)
1538 $(MAKE
) $(AM_MAKEFLAGS
) CFLAGS
=$(COVERAGE_CCOPTS
) CXXFLAGS
=$(COVERAGE_CCOPTS
) check
1539 mkdir
-p
$(COVERAGE_OUT
)
1540 lcov
--directory .
--output-file
$(COVERAGE_OUT
)/$(PACKAGE
).
info \
1544 genhtml
--output-directory
$(COVERAGE_OUT
) \
1545 $(COVERAGE_OUT
)/$(PACKAGE
).
info \
1546 --highlight
--frames
--legend \
1547 --title
"$(PACKAGE_NAME)"
1550 $(MAKE
) init-coverage
1551 $(MAKE
) build-coverage
1552 $(MAKE
) gen-coverage
1554 # Some projects carry local adjustments for gnulib modules via patches in
1555 # a gnulib patch directory whose default name is gl/ (defined in bootstrap
1556 # via local_gl_dir=gl). Those patches become stale as the originals evolve
1557 # in gnulib. Use this rule to refresh any stale patches. It applies each
1558 # patch to the original in $(gnulib_dir) and uses the temporary result to
1559 # generate a fuzz-free .diff file. If you customize the name of your local
1560 # gnulib patch directory via bootstrap.conf, this rule detects that name.
1561 # Run this from a non-VPATH (i.e., srcdir) build directory.
1562 .PHONY
: refresh-gnulib-patches
1563 refresh-gnulib-patches
:
1565 if
test -f bootstrap.conf
; then \
1566 t
=$$(perl
-lne
'/^\s*local_gl_dir=(\S+)/ and $$d=$$1;' \
1567 -e
'END{defined $$d and print $$d}' bootstrap.conf
); \
1568 test -n
"$$t" && gl
=$$t; \
1570 for diff in
$$(cd
$$gl; git ls-files |
$(GREP
) '\.diff$$'); do \
1571 b
=$$(printf
%s
"$$diff"|
$(SED
) 's/\.diff$$//'); \
1572 VERSION_CONTROL
=none \
1573 patch
"$(gnulib_dir)/$$b" "$$gl/$$diff" || exit
1; \
1574 ( cd
$(gnulib_dir
) || exit
1; \
1575 git diff
"$$b" > "../$$gl/$$diff"; \
1576 git checkout
$$b ) || exit
1; \
1579 # Update gettext files.
1580 PACKAGE ?
= $(shell basename $(PWD
))
1581 PO_DOMAIN ?
= $(PACKAGE
)
1582 POURL
= https
://translationproject.org
/latest
/$(PO_DOMAIN
)/
1585 rm -f
$(PODIR
)/*.po
&& \
1586 echo
"$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
1587 wget
--no-verbose
--directory-prefix
$(PODIR
) --no-directories
--recursive
--level
1 --accept .po
--accept .po
.1 $(POURL
) && \
1588 echo
'en@boldquot' > $(PODIR
)/LINGUAS
&& \
1589 echo
'en@quot' >> $(PODIR
)/LINGUAS
&& \
1590 ls
$(PODIR
)/*.po |
$(SED
) 's/\.po//;s,$(PODIR)/,,' | \
1591 sort >> $(PODIR
)/LINGUAS
1593 # Running indent once is not idempotent, but running it twice is.
1594 INDENT_SOURCES ?
= $(C_SOURCES
)
1597 indent
$(INDENT_SOURCES
)
1598 indent
$(INDENT_SOURCES
)
1600 # If you want to set UPDATE_COPYRIGHT_* environment variables,
1601 # put the assignments in this variable.
1602 update-copyright-env ?
=
1604 # Run this rule once per year (usually early in January)
1605 # to update all FSF copyright year lists in your project.
1606 # If you have an additional project-specific rule,
1607 # add it in cfg.mk along with a line 'update-copyright: prereq'.
1608 # By default, exclude all variants of COPYING; you can also
1609 # add exemptions (such as ChangeLog..* for rotated change logs)
1610 # in the file .x-update-copyright.
1611 .PHONY
: update-copyright
1613 $(AM_V_GEN
)$(GREP
) -l
-w Copyright \
1614 $$(export VC_LIST_EXCEPT_DEFAULT
=COPYING
&& $(VC_LIST_EXCEPT
)) \
1615 |
$(update-copyright-env
) xargs
$(srcdir)/$(_build-aux
)/$@
1617 # This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
1618 # overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
1620 # NOTE: to override any _gl_TS_* default value, you must
1621 # define the variable(s) using "export" in cfg.mk.
1624 ALL_RECURSIVE_TARGETS
+= sc_tight_scope
1625 sc_tight_scope
: tight-scope.mk
1627 if
! $(GREP
) '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \
1629 && ! $(GREP
) -w noinst_HEADERS
$(srcdir)/$(_gl_TS_dir
)/Makefile.am \
1630 > /dev
/null
2>&1; then \
1631 echo
'$(ME): skipping $@'; \
1633 $(MAKE
) -s
-C
$(_gl_TS_dir
) \
1635 -f
$(abs_top_srcdir
)/cfg.mk \
1636 -f
$(abs_top_builddir
)/$< \
1643 tight-scope.mk
: $(ME
)
1645 @perl
-ne
'/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME
) > $@
-t
1646 @chmod a
=r
$@
-t
&& mv
$@
-t
$@
1651 # Most functions should have static scope.
1652 # Any that don't must be marked with 'extern', but 'main'
1653 # and 'usage' are exceptions: they're always extern, but
1654 # do not need to be marked. Symbols matching '__.*' are
1655 # reserved by the compiler, so are automatically excluded below.
1656 _gl_TS_unmarked_extern_functions ?
= main usage
1657 _gl_TS_function_match ?
= /^
(?
:$(_gl_TS_extern
)) +.
*?
(\w
+) *\
(/
1659 # If your project uses a macro like "XTERN", then put
1660 # the following in cfg.mk to override this default:
1661 # export _gl_TS_extern = extern|XTERN
1662 _gl_TS_extern ?
= extern
1664 # The second nm|grep checks for file-scope variables with 'extern' scope.
1665 # Without gnulib's progname module, you might put program_name here.
1666 # Symbols matching '__.*' are reserved by the compiler,
1667 # so are automatically excluded below.
1668 _gl_TS_unmarked_extern_vars ?
=
1670 # NOTE: the _match variables are perl expressions -- not mere regular
1671 # expressions -- so that you can extend them to match other patterns
1672 # and easily extract matched variable names.
1673 # For example, if your project declares some global variables via
1674 # a macro like this: GLOBAL(type, var_name, initializer), then you
1675 # can override this definition to automatically extract those names:
1676 # export _gl_TS_var_match = \
1677 # /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
1678 _gl_TS_var_match ?
= /^
(?
:$(_gl_TS_extern
)) .
*?
(\w
+)(\
[.
*?\
])?
;/
1680 # The names of object files in (or relative to) $(_gl_TS_dir).
1681 _gl_TS_obj_files ?
= *.
$(OBJEXT
)
1683 # Files in which to search for the one-line style extern declarations.
1684 # $(_gl_TS_dir)-relative.
1685 _gl_TS_headers ?
= $(noinst_HEADERS
)
1686 _gl_TS_other_headers ?
= *.h
1688 .PHONY
: _gl_tight_scope
1689 _gl_tight_scope
: $(bin_PROGRAMS
)
1690 sed_wrap
='s/^/^_?/;s/$$/$$/'; \
1691 t
=exceptions-
$$$$; \
1692 trap
's=$$?; rm -f $$t; exit $$s' 0; \
1693 for sig in
1 2 3 13 15; do \
1694 eval
"trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
1696 src
=`for f in $(SOURCES); do \
1697 test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
1698 hdr
=`for f in $(_gl_TS_headers); do \
1699 test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
1700 ( printf
'%s\n' '__.*' $(_gl_TS_unmarked_extern_functions
); \
1701 $(GREP
) -h
-A1
'^extern .*[^;]$$' $$src \
1702 |
$(GREP
) -vE
'^(extern |--|#)' |
$(SED
) 's/ .*//; /^$$/d'; \
1704 '$(_gl_TS_function_match) and print $$1' $$hdr; \
1705 ) |
sort -u |
$(SED
) "$$sed_wrap" > $$t; \
1706 nm
-g
$(_gl_TS_obj_files
)|
$(SED
) -n
's/.* T //p'|
$(GREP
) -Ev
-f
$$t \
1707 && { echo the above functions should have static scope
>&2; \
1709 ( printf
'%s\n' '__.*' main
$(_gl_TS_unmarked_extern_vars
); \
1710 perl
-lne
'$(_gl_TS_var_match) and print $$1' \
1711 $$hdr $(_gl_TS_other_headers
) \
1712 ) |
sort -u |
$(SED
) "$$sed_wrap" > $$t; \
1713 nm
-g
$(_gl_TS_obj_files
) |
$(SED
) -n
's/.* [BCDGRS] //p' \
1714 |
sort -u |
$(GREP
) -Ev
-f
$$t \
1715 && { echo the above variables should have static scope
>&2; \