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-2024 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.
33 _sp
= $(_empty
) $(_empty
)
37 # If S1 == S2, return S1, otherwise the empty string.
38 _equal
= $(and
$(findstring $(1),$(2)),$(findstring $(2),$(1)))
40 # member-check,VARIABLE,VALID-VALUES
41 # ----------------------------------
42 # Check that $(VARIABLE) is in the space-separated list of VALID-VALUES, and
43 # return it. Die otherwise.
47 $(if
$(findstring $(_sp
),$($(1))), \
48 $(error invalid
$(1): '$($(1))', expected
$(2)), \
49 $(or
$(findstring $(_sp
)$($(1))$(_sp
),$(_sp
)$(2)$(_sp
)), \
50 $(error invalid
$(1): '$($(1))', expected
$(2)))), \
51 $(error
$(1) undefined
)))
53 # Do not save the original name or timestamp in the .tar.gz file.
54 # Use --rsyncable if available.
56 $(shell gzip
--help
2>/dev
/null|
$(GREP
) rsyncable
>/dev
/null \
57 && printf
%s
--rsyncable
)
58 GZIP_ENV
= '--no-name --best $(gzip_rsyncable)'
63 VC_LIST
= $(srcdir)/$(_build-aux
)/vc-list-files
-C
$(srcdir)
65 # You can override this variable in cfg.mk if your gnulib submodule lives
66 # in a different location.
67 gnulib_dir ?
= $(shell if
test -n
"$(GNULIB_SRCDIR)" && test -f
"$(GNULIB_SRCDIR)/gnulib-tool"; then \
68 echo
"$(GNULIB_SRCDIR)"; \
70 echo
$(srcdir)/gnulib
; \
73 # You can override this variable in cfg.mk to set your own regexp
74 # matching files to ignore.
75 VC_LIST_ALWAYS_EXCLUDE_REGEX ?
= ^
$$
77 # This is to preprocess robustly the output of $(VC_LIST), so that even
78 # when $(srcdir) is a pathological name like "....", the leading sed command
79 # removes only the intended prefix.
80 _dot_escaped_srcdir
= $(subst .
,\.
,$(srcdir))
82 # Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
83 # when $(srcdir) is not ".".
85 _prepend_srcdir_prefix
=
87 _prepend_srcdir_prefix
= |
$(SED
) 's|^|$(srcdir)/|'
90 # In order to be able to consistently filter "."-relative names,
91 # (i.e., with no $(srcdir) prefix), this definition is careful to
92 # remove any $(srcdir) prefix, and to restore what it removes.
94 $(or
$(exclude_file_name_regexp--
$@
),^
$$)
96 $(VC_LIST
) |
$(SED
) 's|^$(_dot_escaped_srcdir)/||' \
97 | if
test -f
$(srcdir)/.x-
$@
; then
$(GREP
) -vEf
$(srcdir)/.x-
$@
; \
98 else $(GREP
) -Ev
-e
"$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
99 |
$(GREP
) -Ev
-e
'($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
100 $(_prepend_srcdir_prefix
)
102 ifeq ($(origin prev_version_file
), undefined
)
103 prev_version_file
= $(srcdir)/.prev-version
106 PREV_VERSION
:= $(shell cat
$(prev_version_file
) 2>/dev
/null
)
107 VERSION_REGEXP
= $(subst .
,\.
,$(VERSION
))
108 PREV_VERSION_REGEXP
= $(subst .
,\.
,$(PREV_VERSION
))
111 this-vc-tag
= v
$(VERSION
)
112 this-vc-tag-regexp
= v
$(VERSION_REGEXP
)
114 tag-package
= $(shell echo
"$(PACKAGE)" | tr
'[:lower:]' '[:upper:]')
115 tag-this-version
= $(subst .
,_
,$(VERSION
))
116 this-vc-tag
= $(tag-package
)-$(tag-this-version
)
117 this-vc-tag-regexp
= $(this-vc-tag
)
119 my_distdir
= $(PACKAGE
)-$(VERSION
)
121 # Old releases are stored here.
122 release_archive_dir ?
= ..
/release
124 # If RELEASE_TYPE is undefined, but RELEASE is, use its second word.
125 # But overwrite VERSION.
127 ifeq ($(origin RELEASE
),command line
)
128 VERSION
:= $(word 1,$(RELEASE
))
129 RELEASE_TYPE ?
= $(word 2,$(RELEASE
))
133 # Validate and return $(RELEASE_TYPE), or die.
134 RELEASE_TYPES
= alpha beta stable
135 release-type
= $(call member-check
,RELEASE_TYPE
,$(RELEASE_TYPES
))
137 # Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
138 # Use alpha.gnu.org for alpha and beta releases.
139 # Use ftp.gnu.org for stable releases.
140 gnu_ftp_host-alpha
= alpha.gnu.org
141 gnu_ftp_host-beta
= alpha.gnu.org
142 gnu_ftp_host-stable
= ftp.gnu.org
143 gnu_rel_host ?
= $(gnu_ftp_host-
$(release-type
))
145 url_dir_list ?
= $(if
$(call _equal
,$(gnu_rel_host
),ftp.gnu.org
), \
146 https
://ftpmirror.gnu.org
/$(PACKAGE
), \
147 https
://$(gnu_rel_host
)/gnu
/$(PACKAGE
))
149 # Override this in cfg.mk if you are using a different format in your
151 today
= $(shell date
+%Y-
%m-
%d
)
153 # Select which lines of NEWS are searched for $(news-check-regexp).
154 # This is a sed line number spec. The default says that we search
155 # lines 1..10 of NEWS for $(news-check-regexp).
156 # If you want to search only line 3 or only lines 20-22, use "3" or "20,22".
157 news-check-lines-spec ?
= 1,10
158 news-check-regexp ?
= '^\*.* $(VERSION_REGEXP) \($(today)\)'
160 # Prevent programs like 'sort' from considering distinct strings to be equal.
161 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
164 ## --------------- ##
166 ## --------------- ##
168 ifneq ($(_gl-Makefile
),)
169 _cfg_mk
:= $(wildcard $(srcdir)/cfg.mk
)
171 # Collect the names of rules starting with 'sc_'.
172 syntax-check-rules
:= $(sort $(shell env LC_ALL
=C
$(SED
) -n \
173 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(srcdir)/$(ME
) $(_cfg_mk
)))
174 .PHONY
: $(syntax-check-rules
)
176 ifeq ($(shell $(VC_LIST
) >/dev
/null
2>&1; echo
$$?
),0)
177 local-checks-available
+= $(syntax-check-rules
)
179 local-checks-available
+= no-vc-detected
181 @echo
"No version control files detected; skipping syntax check"
183 .PHONY
: $(local-checks-available
)
185 # Arrange to prine the name of each syntax-checking rule just before running it.
186 $(syntax-check-rules
): %: %.m
187 sc_m_rules_
= $(patsubst %, %.m
, $(syntax-check-rules
))
188 .PHONY
: $(sc_m_rules_
)
190 @echo
$(patsubst sc_
%.m
, %, $@
)
191 @date
+%s.
%N
> .sc-start-
$(basename $@
)
193 # Compute and print the elapsed time for each syntax-check rule.
194 sc_z_rules_
= $(patsubst %, %.z
, $(syntax-check-rules
))
195 .PHONY
: $(sc_z_rules_
)
196 $(sc_z_rules_
): %.z
: %
197 @end
=$$(date
+%s.
%N
); \
198 start
=$$(cat .sc-start-
$*); \
199 rm -f .sc-start-
$*; \
200 $(AWK
) -v s
=$$start -v e
=$$end \
201 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev
/null
203 # The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
204 # that computes and prints elapsed time.
206 $(patsubst sc_
%, sc_
%.z
, \
207 $(filter-out $(local-checks-to-skip
), $(local-checks-available
)))
209 syntax-check
: $(local-check
)
214 # This macro searches for a given construct in the selected files and
215 # then takes some action.
217 # Parameters (shell variables):
221 # Regular expression (ERE) denoting either a forbidden construct
222 # or a required construct. Those arguments are exclusive.
226 # Regular expression (ERE) denoting lines to ignore that matched
227 # a prohibit construct. For example, this can be used to exclude
228 # comments that mention why the nearby code uses an alternative
229 # construct instead of the simpler prohibited construct.
231 # in_vc_files | in_files
233 # grep-E-style regexp selecting the files to check. For in_vc_files,
234 # the regexp is used to select matching files from the list of all
235 # version-controlled files; for in_files, it's from the names printed
236 # by "find $(srcdir)". When neither is specified, use all files that
237 # are under version control.
239 # containing | non_containing
241 # Select the files (non) containing strings matching this regexp.
242 # If both arguments are specified then CONTAINING takes
247 # Extra options for grep.
255 # Message to display before to halting execution.
257 # Finally, you may exempt files based on an ERE matching file names.
258 # For example, to exempt from the sc_space_tab check all files with the
259 # .diff suffix, set this Make variable:
261 # exclude_file_name_regexp--sc_space_tab = \.diff$
263 # Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
264 # when filtering by name via in_files, we explicitly filter out matching
265 # names here as well.
267 # Initialize each, so that envvar settings cannot interfere.
274 export non_containing
=
276 export with_grep_options
=
278 # By default, _sc_search_regexp does not ignore case.
280 _ignore_case
= $$(test -n
"$$ignore_case" && printf
%s
-i ||
:)
282 define _sc_say_and_exit
283 dummy
=; : so we do not need a semicolon before each use
; \
284 { printf
'%s\n' "$(ME): $$msg" 1>&2; exit
1; };
287 define _sc_search_regexp
288 dummy
=; : so we do not need a semicolon before each use
; \
291 test -n
"$$prohibit" && test -n
"$$require" \
292 && { msg
='Cannot specify both prohibit and require' \
293 $(_sc_say_and_exit
) } ||
:; \
294 test -z
"$$prohibit" && test -z
"$$require" \
295 && { msg
='Should specify either prohibit or require' \
296 $(_sc_say_and_exit
) } ||
:; \
297 test -z
"$$prohibit" && test -n
"$$exclude" \
298 && { msg
='Use of exclude requires a prohibit pattern' \
299 $(_sc_say_and_exit
) } ||
:; \
300 test -n
"$$in_vc_files" && test -n
"$$in_files" \
301 && { msg
='Cannot specify both in_vc_files and in_files' \
302 $(_sc_say_and_exit
) } ||
:; \
303 test "x$$halt" != x \
304 ||
{ msg
='halt not defined' $(_sc_say_and_exit
) }; \
306 : Filter by file name
; \
307 if
test -n
"$$in_files"; then \
308 files
=$$(find
$(srcdir) |
$(GREP
) -E
"$$in_files" \
309 |
$(GREP
) -Ev
'$(_sc_excl)'); \
311 files
=$$($(VC_LIST_EXCEPT
)); \
312 if
test -n
"$$in_vc_files"; then \
313 files
=$$(echo
"$$files" |
$(GREP
) -E
"$$in_vc_files"); \
317 : Filter by content
; \
319 && test -n
"$$containing" \
320 && { files
=$$(echo
"$$files" | xargs
$(GREP
) -l
"$$containing"); } \
323 && test -n
"$$non_containing" \
324 && { files
=$$(echo
"$$files" | xargs
$(GREP
) -vl
"$$non_containing"); } \
327 : Check for the construct
; \
328 if
test -n
"$$files"; then \
329 if
test -n
"$$prohibit"; then \
331 | xargs
$(GREP
) $$with_grep_options $(_ignore_case
) -nE \
332 "$$prohibit" /dev
/null \
333 |
$(GREP
) -vE
"$${exclude:-^$$}" \
334 && { msg
="$$halt" $(_sc_say_and_exit
) } \
339 $(GREP
) $$with_grep_options $(_ignore_case
) -LE
"$$require" \
341 && { msg
="$$halt" $(_sc_say_and_exit
) } \
348 sc_avoid_if_before_free
:
350 |
$(GREP
) -v useless-if-before-free \
352 $(srcdir)/$(_build-aux
)/useless-if-before-free \
353 $(useless_free_options
) \
354 && { printf
'$(ME): found useless "if"' \
355 ' before "free" above\n' 1>&2; \
359 sc_cast_of_argument_to_free
:
360 @prohibit
='\<free *\( *\(' halt
="don't cast free argument" \
363 sc_cast_of_x_alloc_return_value
:
364 @prohibit
='\*\) *x(m|c|re)alloc\>' \
365 halt
="don't cast x*alloc return value" \
368 sc_cast_of_alloca_return_value
:
369 @prohibit
='\*\) *alloca\>' \
370 halt
="don't cast alloca return value" \
375 halt
='found SPACE-TAB sequence; remove the SPACE' \
378 # Don't use *scanf or the old ato* functions in "real" code.
379 # They provide no error checking mechanism.
380 # Instead, use strto* functions.
381 sc_prohibit_atoi_atof
:
382 @prohibit
='\<([fs]?scanf|ato([filq]|ll)) *\(' \
383 halt
='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
386 # Use STREQ rather than comparing strcmp == 0, or != 0.
389 @prohibit
='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \
390 exclude
='# *define STRN?EQ\(' \
391 halt
='replace strcmp calls above with STREQ/STRNEQ' \
394 # Really. You don't want to use this function.
395 # It may fail to NUL-terminate the destination,
396 # and always NUL-pads out to the specified length.
398 @prohibit
='\<strncpy *\(' \
399 halt
='do not use strncpy, period' \
402 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
403 # Convert all uses automatically, via these two commands:
404 # git grep -l '\<exit *(1)' \
405 # | grep -vEf .x-sc_prohibit_magic_number_exit \
406 # | xargs --no-run-if-empty \
407 # perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
408 # git grep -l '\<exit *(0)' \
409 # | grep -vEf .x-sc_prohibit_magic_number_exit \
410 # | xargs --no-run-if-empty \
411 # perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
412 sc_prohibit_magic_number_exit
:
413 @prohibit
='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]' \
414 exclude
='exit \(77\)|error ?\(((0|77),|[^,]*)' \
415 halt
='use EXIT_* values rather than magic number' \
418 # Check that we don't use $< in non-implicit Makefile rules.
420 # To find the Makefiles, trace AC_CONFIG_FILES. Using VC_LIST would
421 # miss the Makefiles that are not under VC control (e.g., symlinks
422 # installed for gettext). "Parsing" (recursive) uses of SUBDIRS seems
425 # Use GNU Make's --print-data-base to normalize the rules into some
426 # easy to parse format: they are separated by two \n. Look for the
427 # "section" about non-pattern rules (marked with "# Files") inside
428 # which there are still the POSIX Make like implicit rules (".c.o").
429 sc_prohibit_gnu_make_extensions_awk_
= \
437 /\
$$</ && in_rules
&& $$0 !~
/^
(.
*\n)*\.\w
+(\.\w
+)?
:/ { \
438 print "Error: " file
": $$< in a non implicit rule\n" $$0; \
444 sc_prohibit_gnu_make_extensions
:
445 @if
$(AWK
) --version | grep GNU
>/dev
/null
2>&1; then \
446 (cd
$(srcdir) && autoconf
--trace AC_CONFIG_FILES
:'$$1') | \
448 $(SED
) -ne
'/Makefile/{s/\.in$$//;p;}' | \
450 $(MAKE
) -qp
-f
$$m .DUMMY-TARGET
2>/dev
/null | \
451 $(AWK
) -v file
=$$m -e
'$($@_awk_)' || exit
1; \
455 # Using EXIT_SUCCESS as the first argument to error is misleading,
456 # since when that parameter is 0, error does not exit. Use '0' instead.
457 sc_error_exit_success
:
458 @prohibit
='error *\(EXIT_SUCCESS,' \
459 in_vc_files
='\.[chly]$$' \
460 halt
='found error (EXIT_SUCCESS' \
463 # "FATAL:" should be fully upper-cased in error messages
464 # "WARNING:" should be fully upper-cased, or fully lower-cased
465 sc_error_message_warn_fatal
:
467 | xargs
$(GREP
) -nEA2
'[^rp]error *\(' /dev
/null \
468 |
$(GREP
) -E
'"Warning|"Fatal|"fatal' \
469 && { echo
'$(ME): use FATAL, WARNING or warning' 1>&2; \
473 # Error messages should not start with a capital letter
474 sc_error_message_uppercase
:
476 | xargs
$(GREP
) -nEA2
'[^rp]error *\(' /dev
/null \
477 |
$(GREP
) -E
'"[A-Z]' \
478 |
$(GREP
) -vE
'"FATAL|"WARNING|"Java|"C#|"PRI' \
479 && { echo
'$(ME): found capitalized error message' 1>&2; \
483 # Error messages should not end with a period
484 sc_error_message_period
:
486 | xargs
$(GREP
) -nEA2
'[^rp]error *\(' /dev
/null \
487 |
$(GREP
) -E
'[^."]\."' \
488 && { echo
'$(ME): found error message ending in period' 1>&2; \
493 @prohibit
=file
''system \
494 exclude
='/proc/filesystems' \
496 halt
='found use of "file''system"; spell it "file system"' \
499 # Don't use cpp tests of this symbol. All code assumes config.h is included.
500 sc_prohibit_have_config_h
:
501 @prohibit
='^# *if.*HAVE''_CONFIG_H' \
502 halt
='found use of HAVE''_CONFIG_H; remove' \
505 # Nearly all .c files must include <config.h>. However, we also permit this
506 # via inclusion of a package-specific header, if cfg.mk specified one.
507 # config_h_header must be suitable for grep -E.
508 # Rationale: The Gnulib documentation, node 'Include <config.h>'.
509 config_h_header ?
= <config\.h
>
511 @require
='^# *include $(config_h_header)' \
512 in_vc_files
='\.c$$' \
513 halt
='the above files do not include <config.h>' \
516 # Print each file name for which the first #include does not match
517 # $(config_h_header). Like grep -m 1, this only looks at the first match.
518 perl_config_h_first_
= \
519 -e
'BEGIN {$$ret = 0}' \
520 -e
'if (/^\# *include\b/) {' \
521 -e
' if (not m{^\# *include $(config_h_header)}) {' \
522 -e
' print "$$ARGV\n";' \
525 -e
' \# Move on to next file after first include' \
528 -e
'END {exit $$ret}'
530 # You must include <config.h> before including any other header file.
531 # This can possibly be via a package-specific header, if given by cfg.mk.
532 # Rationale: The Gnulib documentation, node 'Include <config.h>'.
533 sc_require_config_h_first
:
534 @if
$(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$' > /dev
/null
; then \
535 files
=$$($(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$') && \
536 perl
-n
$(perl_config_h_first_
) $$files || \
537 { echo
'$(ME): the above files include some other header' \
538 'before <config.h>' 1>&2; exit
1; } ||
:; \
542 # Generated headers that override system headers.
543 # These are documented in gnulib-tool.texi. Keep sorted.
544 # sed -n -e 's/^@item[[:space:]]\{1,\}@code{\([^}]\{1,\}\)}$/\1/p' $GNULIB_SRCDIR/doc/gnulib-tool.texi | sort -u
545 gl_prefer_angle_bracket_headers_ ?
= \
617 # Remove each .h suffix and change each space to "|".
618 angle_bracket_header_re
= \
619 $(subst $(_sp
),|
,$(patsubst %.h
,%,$(gl_prefer_angle_bracket_headers_
)))
621 # Suggest using '#include <header.h>' instead of '#include "header.h"' for
622 # headers that override system headers.
623 # Rationale: The Gnulib documentation, node 'Style of #include statements'.
624 sc_prefer_angle_bracket_headers
:
625 @prohibit
='^ *# *include "($(angle_bracket_header_re))\.h"' \
626 halt
='Use #include <hdr.h>, not #include "hdr.h" for the above' \
629 sc_prohibit_HAVE_MBRTOWC
:
630 @prohibit
='\bHAVE_MBRTOWC\b' \
631 halt
="do not use $$prohibit; it is always defined" \
634 # To use this "command" macro, you must first define two shell variables:
635 # h: the header name, with no enclosing <> or ""
636 # re: a regular expression that matches IFF something provided by $h is used.
637 define _sc_header_without_use
638 dummy
=; : so we do not need a semicolon before each use
; \
639 h_esc
=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \
640 if
$(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$' > /dev
/null
; then \
641 files
=$$($(GREP
) -l
'^# *include '"$$h_esc" \
642 $$($(VC_LIST_EXCEPT
) |
$(GREP
) '\.c$$')) && \
643 $(GREP
) -LE
"$$re" $$files |
$(GREP
) .
&& \
644 { echo
"$(ME): the above files include $$h but don't use it" \
645 1>&2; exit
1; } ||
:; \
650 # Prohibit the inclusion of assert.h without an actual use of assert.
651 sc_prohibit_assert_without_use
:
652 @h
='assert.h' re
='\<assert *\(' $(_sc_header_without_use
)
654 # Prohibit the inclusion of close-stream.h without an actual use.
655 sc_prohibit_close_stream_without_use
:
656 @h
='close-stream.h' re
='\<close_stream *\(' $(_sc_header_without_use
)
658 # Prohibit the inclusion of getopt.h without an actual use.
659 sc_prohibit_getopt_without_use
:
660 @h
='getopt.h' re
='\<getopt(_long)? *\(' $(_sc_header_without_use
)
662 # Don't include quotearg.h unless you use one of its functions.
663 sc_prohibit_quotearg_without_use
:
664 @h
='quotearg.h' re
='\<quotearg(_[^ ]+)? *\(' $(_sc_header_without_use
)
666 # Don't include quote.h unless you use one of its functions.
667 sc_prohibit_quote_without_use
:
668 @h
='quote.h' re
='\<quote((_n)? *\(|_quoting_options\>)' \
669 $(_sc_header_without_use
)
671 # Don't include this header unless you use one of its functions.
672 sc_prohibit_long_options_without_use
:
673 @h
='long-options.h' re
='\<parse_(long_options|gnu_standard_options_only) *\(' \
674 $(_sc_header_without_use
)
676 # Don't include this header unless you use one of its functions.
677 sc_prohibit_inttostr_without_use
:
678 @h
='inttostr.h' re
='\<(off|[iu]max|uint)tostr *\(' \
679 $(_sc_header_without_use
)
681 # Don't include this header unless you use one of its functions.
682 sc_prohibit_ignore_value_without_use
:
683 @h
='ignore-value.h' re
='\<ignore_(value|ptr) *\(' \
684 $(_sc_header_without_use
)
686 # Don't include this header unless you use one of its functions.
687 sc_prohibit_error_without_use
:
689 re
='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
690 $(_sc_header_without_use
)
692 # Don't include xalloc.h unless you use one of its symbols.
693 # Consider these symbols:
694 # perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
695 # perl -lne 'm{^(?:_Noreturn )?(?:void|char) \*?(\w+) *\(} and print $1' lib/xalloc.h
696 # Divide into two sets on case, and filter each through this:
697 # | sort | perl -MRegexp::Assemble -le \
698 # 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
699 _xa1
= x
(i
(m
(emdup0?|alloc
)|realloc
(array
)?|
([cz
]|nm
)alloc
)|
([pz
]|c
(har
)?|
2n?re|nm
)alloc|realloc
(array
)?|m
(alloc|emdup
)|alloc_die|strdup
)
700 _xa2
= X
([CZ
]|N?M
)ALLOC
701 sc_prohibit_xalloc_without_use
:
703 re
='\<($(_xa1)|$(_xa2)) *\('\
704 $(_sc_header_without_use
)
706 # Extract function names:
707 # perl -lne '/^(?:extern )?(?:void|char|Hash_table) \*?(\w+) *\(/ and print $1' lib/hash.h
709 hash_
(re
(set_tuning|move
)|xin
(itialize|sert
)|in
(itialize|sert
)|get_
(firs|nex
)t|print_statistics|
(delet|fre
)e|lookup|clear
)
710 _hash_fn
= \
<($(_hash_re
)) *\
(
711 _hash_struct
= (struct
)?\
<[Hh
]ash_
(table|tuning
)\
>
712 sc_prohibit_hash_without_use
:
714 re
='$(_hash_fn)|$(_hash_struct)'\
715 $(_sc_header_without_use
)
717 sc_prohibit_cloexec_without_use
:
718 @h
='cloexec.h' re
='\<(set_cloexec_flag|dup_cloexec) *\(' \
719 $(_sc_header_without_use
)
721 sc_prohibit_posixver_without_use
:
722 @h
='posixver.h' re
='\<posix2_version *\(' $(_sc_header_without_use
)
724 sc_prohibit_same_without_use
:
725 @h
='same.h' re
='\<same_name(at)? *\(' $(_sc_header_without_use
)
727 sc_prohibit_hash_pjw_without_use
:
730 $(_sc_header_without_use
)
732 sc_prohibit_safe_read_without_use
:
733 @h
='safe-read.h' re
='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
734 $(_sc_header_without_use
)
736 sc_prohibit_argmatch_without_use
:
738 re
='(\<(ARGMATCH_DEFINE_GROUP|ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \
739 $(_sc_header_without_use
)
741 sc_prohibit_canonicalize_without_use
:
742 @h
='canonicalize.h' \
743 re
='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode|file_name)' \
744 $(_sc_header_without_use
)
746 sc_prohibit_root_dev_ino_without_use
:
747 @h
='root-dev-ino.h' \
748 re
='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
749 $(_sc_header_without_use
)
751 sc_prohibit_openat_without_use
:
753 re
='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat|(FCHMOD|FCHOWN|STAT)AT_INLINE)\>' \
754 $(_sc_header_without_use
)
756 # Prohibit the inclusion of c-ctype.h without an actual use.
757 ctype_re
= isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
758 |isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
759 sc_prohibit_c_ctype_without_use
:
760 @h
='c-ctype.h' re
='\<c_($(ctype_re)) *\(' \
761 $(_sc_header_without_use
)
763 # The following list was generated by running:
764 # man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
765 # | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
767 bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
768 sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
769 siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
770 sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
771 _sig_function_re
= $(subst $(_sp
),|
,$(strip $(_sig_functions
)))
772 # The following were extracted from "man signal.h" manually.
773 _sig_types_and_consts
= \
774 MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
775 SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
776 SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
777 SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
778 sigstack sigval stack_t ucontext_t
779 # generated via this:
780 # perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
782 SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
783 SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
784 SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
785 SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
786 SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
787 SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
788 SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
790 _sig_syms_re
= $(subst $(_sp
),|
,$(strip $(_sig_names
) $(_sig_types_and_consts
)))
792 # Prohibit the inclusion of signal.h without an actual use.
793 sc_prohibit_signal_without_use
:
795 re
='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
796 $(_sc_header_without_use
)
798 # Don't include stdio--.h unless you use one of its functions.
799 sc_prohibit_stdio--_without_use
:
800 @h
='stdio--.h' re
='\<((f(re)?|p)open|tmpfile) *\(' \
801 $(_sc_header_without_use
)
803 # Don't include stdio-safer.h unless you use one of its functions.
804 sc_prohibit_stdio-safer_without_use
:
805 @h
='stdio-safer.h' re
='\<((f(re)?|p)open|tmpfile)_safer *\(' \
806 $(_sc_header_without_use
)
808 # Prohibit the inclusion of strings.h without a sensible use.
809 # Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible.
810 sc_prohibit_strings_without_use
:
812 re
='\<(strn?casecmp|ffs(ll)?)\>' \
813 $(_sc_header_without_use
)
815 # Extract the raw list of symbol names with this:
816 gl_extract_define_simple
= \
817 /^\
# *define ([A-Z]\w+)\(/ and print $$1
818 # Filter out duplicates and convert to a space-separated list:
820 $(shell f
=$(gnulib_dir
)/lib
/intprops.h
; \
821 perl
-lne
'$(gl_extract_define_simple)' $$f |
sort -u | tr
'\n' ' ')
822 # Remove trailing space and convert to a regular expression:
823 _intprops_syms_re
= $(subst $(_sp
),|
,$(strip $(_intprops_names
)))
824 # Prohibit the inclusion of intprops.h without an actual use.
825 sc_prohibit_intprops_without_use
:
827 re
='\<($(_intprops_syms_re)) *\(' \
828 $(_sc_header_without_use
)
831 NULL|max_align_t|nullptr_t|offsetof|ptrdiff_t|size_t|unreachable|wchar_t
832 # Prohibit the inclusion of stddef.h without an actual use.
833 sc_prohibit_stddef_without_use
:
835 re
='\<($(_stddef_syms_re))\>' \
836 $(_sc_header_without_use
)
838 _de1
= dirfd|
(close|
(fd
)?open|read|rewind|seek|tell
)dir(64)?
(_r
)?
839 _de2
= (versionsort|struct dirent|getdirentries|alphasort|scandir
(at
)?
)(64)?
840 _de3
= MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
841 _dirent_syms_re
= $(_de1
)|
$(_de2
)|
$(_de3
)
842 # Prohibit the inclusion of dirent.h without an actual use.
843 sc_prohibit_dirent_without_use
:
845 re
='\<($(_dirent_syms_re))\>' \
846 $(_sc_header_without_use
)
848 # Prohibit the inclusion of verify.h without an actual use.
849 sc_prohibit_verify_without_use
:
851 re
='\<(verify(_expr)?|assume) *\(' \
852 $(_sc_header_without_use
)
854 # Don't include xfreopen.h unless you use one of its functions.
855 sc_prohibit_xfreopen_without_use
:
856 @h
='xfreopen.h' re
='\<xfreopen *\(' $(_sc_header_without_use
)
859 @prohibit
='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
860 halt
='do not use HAVE''_FCNTL_H or O'_NDELAY \
863 # Prohibit BSD4.3/SysV u_char, u_short, u_int and u_long usage.
866 halt
='don'\''t use u''_char; instead use unsigned char' \
869 @prohibit
=u
''_short \
870 halt
='don'\''t use u''_short; instead use unsigned short' \
874 halt
='don'\''t use u''_int; instead use unsigned int' \
878 halt
='don'\''t use u''_long; instead use unsigned long' \
881 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
883 # Each nonempty ChangeLog line must start with a year number, or a TAB.
885 @prohibit
='^[^12 ]' \
886 in_vc_files
='^ChangeLog$$' \
887 halt
='found unexpected prefix in a ChangeLog' \
890 # Ensure that each .c file containing a "main" function also
891 # calls bindtextdomain.
893 @require
='bindtextdomain *\(' \
894 in_vc_files
='\.c$$' \
895 containing
='\<main *(' \
896 halt
='the above files do not call bindtextdomain' \
899 # Require that the final line of each test-lib.sh-using test be this one:
901 # Note: this test requires GNU grep's --label= option.
902 Exit_witness_file ?
= tests
/test-lib.sh
903 Exit_base
:= $(notdir $(Exit_witness_file
))
904 sc_require_test_exit_idiom
:
905 @if
test -f
$(srcdir)/$(Exit_witness_file
); then \
907 for i in
$$($(GREP
) -l
-F
'srcdir/$(Exit_base)' \
908 $$($(VC_LIST
) tests
)); do \
909 tail
-n1
$$i |
$(GREP
) '^Exit .' > /dev
/null \
910 && : ||
{ die
=1; echo
$$i; } \
913 { echo
1>&2 '$(ME): the final line in each of the above is not:'; \
914 echo
1>&2 'Exit something'; \
920 halt
='found trailing blank(s)' \
921 exclude
='^Binary file .* matches$$' \
924 # Match lines like the following, but where there is only one space
925 # between the options and the description:
926 # -D, --all-repeated[=delimit-method] print all duplicate lines\n
927 longopt_re
= --[a-z
][0-9A-Za-z-
]*(\
[?
=[0-9A-Za-z-
]*]?
)?
928 sc_two_space_separator_in_usage
:
929 @prohibit
='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
930 halt
='help2man requires at least two spaces between an option and its description'\
933 # A regexp matching function names like "error" that may be used
934 # to emit translatable messages.
935 _gl_translatable_diag_func_re ?
= error
937 # Look for diagnostics that aren't marked for translation.
938 # This won't find any for which error's format string is on a separate line.
939 sc_unmarked_diagnostics
:
940 @prohibit
='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
941 exclude
='(_|ngettext ?)\(' \
942 halt
='found unmarked diagnostic(s)' \
945 # Avoid useless parentheses like those in this example:
946 # #if defined (SYMBOL) || defined (SYM2)
947 sc_useless_cpp_parens
:
948 @prohibit
='^# *if .*defined *\(' \
949 halt
='found useless parentheses in cpp directive' \
952 # List headers for which HAVE_HEADER_H is always true, assuming you are
953 # using the appropriate gnulib module. CAUTION: for each "unnecessary"
954 # #if HAVE_HEADER_H that you remove, be sure that your project explicitly
955 # requires the gnulib module that guarantees the usability of that header.
956 gl_assured_headers_
= \
957 cd
$(gnulib_dir
)/lib
&& echo
*.in.h|
$(SED
) 's/\.in\.h//g'
959 # Convert the list of names to upper case, and replace each space with "|".
960 az_
= abcdefghijklmnopqrstuvwxyz
961 AZ_
= ABCDEFGHIJKLMNOPQRSTUVWXYZ
962 gl_header_upper_case_or_
= \
963 $$($(gl_assured_headers_
) \
964 | tr
$(az_
)/.
- $(AZ_
)___ \
967 sc_prohibit_always_true_header_tests
:
968 @or
=$(gl_header_upper_case_or_
); \
969 re
="HAVE_($$or)_H"; \
970 prohibit
='\<'"$$re"'\>' \
971 halt
=$$(printf
'%s\n' \
972 'do not test the above HAVE_<header>_H symbol(s);' \
973 ' with the corresponding gnulib module, they are always true') \
976 sc_prohibit_defined_have_decl_tests
:
977 @prohibit
='(#[ ]*ifn?def|\<defined)\>[ (]+HAVE_DECL_' \
978 halt
='HAVE_DECL macros are always defined' \
981 # ==================================================================
982 gl_other_headers_ ?
= \
987 # Perl -lne code to extract "significant" cpp-defined symbols from a
988 # gnulib header file, eliminating a few common false-positives.
989 # The exempted names below are defined only conditionally in gnulib,
990 # and hence sometimes must/may be defined in application code.
991 gl_extract_significant_defines_
= \
992 /^\
# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
993 && $$2 !~
/(?
:rpl_|_used_without_
)/\
994 && $$1 !~
/^
(?
:NSIG|ENODATA
)$$/\
995 && $$1 !~
/^
(?
:SA_RESETHAND|SA_RESTART
)$$/\
998 # Create a list of regular expressions matching the names
999 # of macros that are guaranteed to be defined by parts of gnulib.
1000 define def_sym_regex
1001 gen_h
=$(gl_generated_headers_
); \
1002 (cd
$(gnulib_dir
)/lib
; \
1003 for f in
*.in.h
$(gl_other_headers_
); do \
1005 && perl
-lne
'$(gl_extract_significant_defines_)' $$f; \
1008 |
$(SED
) 's/^/^ *# *(define|undef) */;s/$$/\\>/'
1011 # Don't define macros that we already get from gnulib header files.
1012 sc_prohibit_always-defined_macros
:
1013 @if
test -d
$(gnulib_dir
); then \
1014 case
$$(echo
all: |
$(GREP
) -l
-f
- Makefile
) in Makefile
);; *) \
1015 echo
'$(ME): skipping $@: you lack GNU grep' 1>&2; exit
0;; \
1017 regex
=$$($(def_sym_regex
)); export regex
; \
1019 | xargs sh
-c
'echo $$regex | $(GREP) -E -f - "$$@"' \
1021 && { printf
'$(ME): define the above' \
1022 ' via some gnulib .h file\n' 1>&2; \
1027 # ==================================================================
1029 # Prohibit checked in backup files.
1030 sc_prohibit_backup_files
:
1031 @
$(VC_LIST
) |
$(GREP
) '~$$' && \
1032 { echo
'$(ME): found version controlled backup file' 1>&2; \
1035 # Require the latest GPL.
1037 @prohibit
='either ''version [^3]' \
1038 halt
='GPL vN, N!=3' \
1039 $(_sc_search_regexp
)
1041 # Require the latest GFDL. Two regexp, since some .texi files end up
1042 # line wrapping between 'Free Documentation License,' and 'Version'.
1043 _GFDL_regexp
= (Free
''Documentation.
*Version
1\.
[^
3]|Version
1\.
[^
3] or any
)
1045 @prohibit
='$(_GFDL_regexp)' \
1046 halt
='GFDL vN, N!=3' \
1047 $(_sc_search_regexp
)
1049 # Don't use Texinfo's @acronym{}.
1050 # https://lists.gnu.org/r/bug-gnulib/2010-03/msg00321.html
1051 texinfo_suffix_re_ ?
= \.
(txi|texi
(nfo
)?
)$$
1053 @prohibit
='@acronym\{' \
1054 in_vc_files
='$(texinfo_suffix_re_)' \
1055 halt
='found use of Texinfo @acronym{}' \
1056 $(_sc_search_regexp
)
1059 Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
1061 sc_prohibit_cvs_keyword
:
1062 @prohibit
='\$$($(cvs_keywords))\$$' \
1063 halt
='do not use CVS keyword expansion' \
1064 $(_sc_search_regexp
)
1066 # This Perl code is slightly obfuscated. Not only is each "$" doubled
1067 # because it's in a Makefile, but the $$c's are comments; we cannot
1068 # use "#" due to the way the script ends up concatenated onto one line.
1069 # It would be much more concise, and would produce better output (including
1070 # counts) if written as:
1071 # perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
1072 # but that would be far less efficient, reading the entire contents
1073 # of each file, rather than just the last two bytes of each.
1074 # In addition, while the code below detects both blank lines and a missing
1075 # newline at EOF, the above detects only the former.
1077 # This is a perl script that is expected to be the single-quoted argument
1078 # to a command-line "-le". The remaining arguments are file names.
1079 # Print the name of each file that does not end in exactly one newline byte.
1080 # I.e., warn if there are blank lines (2 or more newlines), or if the
1081 # last byte is not a newline. However, currently we don't complain
1082 # about any file that contains exactly one byte.
1083 # Exit nonzero if at least one such file is found, otherwise, exit 0.
1084 # Warn about, but otherwise ignore open failure. Ignore seek/read failure.
1086 # Use this if you want to remove trailing empty lines from selected files:
1087 # perl -pi -0777 -e 's/\n\n+$/\n/' files...
1089 require_exactly_one_NL_at_EOF_
= \
1090 foreach my
$$f (@ARGV
) \
1092 open F
, "<", $$f or
(warn
"failed to open $$f: $$!\n"), next
; \
1093 my
$$p = sysseek
(F
, -2, 2); \
1094 my
$$c = "seek failure probably means file has < 2 bytes; ignore"; \
1095 my
$$last_two_bytes; \
1096 defined
$$p and
$$p = sysread F
, $$last_two_bytes, 2; \
1098 $$c = "ignore read failure"; \
1099 $$p && ($$last_two_bytes eq
"\n\n" \
1100 || substr
($$last_two_bytes,1) ne
"\n") \
1101 and
(print $$f), $$fail=1; \
1103 END
{ exit defined
$$fail }
1104 sc_prohibit_empty_lines_at_EOF
:
1105 @
$(VC_LIST_EXCEPT
) \
1106 | xargs perl
-le
'$(require_exactly_one_NL_at_EOF_)' \
1107 ||
{ echo
'$(ME): empty line(s) or no newline at EOF' 1>&2; \
1111 # Make sure we don't use st_blocks. Use ST_NBLOCKS or STP_NBLOCKS instead.
1112 # This is a bit of a kludge, since it prevents use of the string
1113 # even in comments, but for now it does the job with no false positives.
1114 sc_prohibit_stat_st_blocks
:
1115 @prohibit
='[.>]st_blocks' \
1116 halt
='do not use st_blocks; use ST_NBLOCKS or STP_NBLOCKS' \
1117 $(_sc_search_regexp
)
1119 # Make sure we don't define any S_IS* macros in src/*.c files.
1120 # They're already defined via gnulib's sys/stat.h replacement.
1121 sc_prohibit_S_IS_definition
:
1122 @prohibit
='^ *# *define *S_IS' \
1123 halt
='do not define S_IS* macros; include <sys/stat.h>' \
1124 $(_sc_search_regexp
)
1126 # Perl block to convert a match to FILE_NAME:LINENO:TEST,
1127 # that is shared by two definitions below.
1128 perl_filename_lineno_text_
= \
1130 -e
' $$n = ($$` =~ tr/\n/\n/ + 1);' \
1131 -e
' ($$v = $$&) =~ s/\n/\\n/g;' \
1132 -e
' print "$$ARGV:$$n:$$v\n";' \
1135 prohibit_doubled_words_
= \
1136 the then in an on if is it but for or at and do to can
1137 # expand the regex before running the check to avoid using expensive captures
1138 prohibit_doubled_word_expanded_
= \
1139 $(join $(prohibit_doubled_words_
),$(addprefix \s
+,$(prohibit_doubled_words_
)))
1140 prohibit_doubled_word_RE_ ?
= \
1141 /\b(?
:$(subst $(_sp
),|
,$(prohibit_doubled_word_expanded_
)))\b/gims
1142 prohibit_doubled_word_
= \
1143 -e
'while ($(prohibit_doubled_word_RE_))' \
1144 $(perl_filename_lineno_text_
)
1146 # Define this to a regular expression that matches
1147 # any filename:dd:match lines you want to ignore.
1148 # The default is to ignore no matches.
1149 ignore_doubled_word_match_RE_ ?
= ^
$$
1151 sc_prohibit_doubled_word
:
1152 @
$(VC_LIST_EXCEPT
) \
1153 | xargs perl
-n
-0777 $(prohibit_doubled_word_
) \
1154 |
$(GREP
) -vE
'$(ignore_doubled_word_match_RE_)' \
1156 && { echo
'$(ME): doubled words' 1>&2; exit
1; } \
1159 # A regular expression matching undesirable combinations of words like
1160 # "can not"; this matches them even when the two words appear on different
1161 # lines, but not when there is an intervening delimiter like "#" or "*".
1162 # Similarly undesirable, "See @xref{...}", since an @xref should start
1163 # a sentence. Explicitly prohibit any prefix of "see" or "also".
1164 # Also prohibit a prefix matching "\w+ +".
1165 # @pxref gets the same see/also treatment and should be parenthesized;
1166 # presume it must *not* start a sentence.
1167 # POSIX spells it "timestamp" rather than "time\s+stamp", so we do, too.
1168 bad_xref_re_ ?
= (?
:[\w
,:;] +|
(?
:see|also
)\s
+)\@xref\
{
1169 bad_pxref_re_ ?
= (?
:[.
!?
]|
(?
:see|also
))\s
+\@pxref\
{
1170 prohibit_undesirable_word_seq_RE_ ?
= \
1171 /(?
:\bcan\s
+not
\b|
\btime\s
+stamps?
\b|
$(bad_xref_re_
)|
$(bad_pxref_re_
))/gims
1172 prohibit_undesirable_word_seq_
= \
1173 -e
'while ($(prohibit_undesirable_word_seq_RE_))' \
1174 $(perl_filename_lineno_text_
)
1175 # Define this to a regular expression that matches
1176 # any filename:dd:match lines you want to ignore.
1177 # The default is to ignore no matches.
1178 ignore_undesirable_word_sequence_RE_ ?
= ^
$$
1180 sc_prohibit_undesirable_word_seq
:
1181 @
$(VC_LIST_EXCEPT
) \
1182 | xargs perl
-n
-0777 $(prohibit_undesirable_word_seq_
) \
1183 |
$(GREP
) -vE
'$(ignore_undesirable_word_sequence_RE_)' \
1185 && { echo
'$(ME): undesirable word sequence' >&2; exit
1; } \
1188 # Except for shell files and for loops, double semicolon is probably a mistake
1189 sc_prohibit_double_semicolon
:
1190 @prohibit
='; *;[ {} \]*(/[/*]|$$)' \
1191 in_vc_files
='\.[chly]$$' \
1192 exclude
='\bfor *\(.*\)' \
1193 halt
="Double semicolon detected" \
1194 $(_sc_search_regexp
)
1196 _ptm1
= use
"test C1 && test C2", not
"test C1 -''a C2"
1197 _ptm2
= use
"test C1 || test C2", not
"test C1 -''o C2"
1198 # Using test's -a and -o operators is not portable.
1199 # We prefer test over [, since the latter is spelled [[ in configure.ac.
1200 sc_prohibit_test_minus_ao
:
1201 @prohibit
='(\<test| \[+) .+ -[ao] ' \
1202 halt
='$(_ptm1); $(_ptm2)' \
1203 $(_sc_search_regexp
)
1205 # Avoid a test bashism.
1206 sc_prohibit_test_double_equal
:
1207 @prohibit
='(\<test| \[+) .+ == ' \
1208 containing
='#! */bin/[a-z]*sh' \
1209 halt
='use "test x = x", not "test x =''= x"' \
1210 $(_sc_search_regexp
)
1212 # Each program that uses proper_name_utf8 must link with one of the
1213 # ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
1214 # The perl -0777 invocation below extracts the possibly-multi-line
1215 # definition of LDADD from the appropriate Makefile.am and exits 0
1216 # when it contains "ICONV".
1217 sc_proper_name_utf8_requires_ICONV
:
1218 @progs
=$$($(VC_LIST_EXCEPT
) \
1219 | xargs
$(GREP
) -l
'proper_name_utf8 ''("'); \
1220 if
test "x$$progs" != x
; then \
1222 for p in
$$progs; do \
1223 dir=$$(dirname
"$$p"); \
1225 -ne
'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \
1226 $$dir/Makefile.am
&& continue
; \
1227 base
=$$(basename "$$p" .c
); \
1228 $(GREP
) "$${base}_LDADD.*ICONV)" $$dir/Makefile.am
> /dev
/null \
1229 ||
{ fail
=1; echo
1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
1231 test $$fail = 1 && \
1232 { echo
1>&2 '$(ME): the above do not link with any ICONV library'; \
1236 # Warn about "c0nst struct Foo const foo[]",
1237 # but not about "char const *const foo" or "#define const const".
1239 @prohibit
='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
1240 halt
='redundant "const" in declarations' \
1241 $(_sc_search_regexp
)
1243 sc_const_long_option
:
1244 @prohibit
='^ *static.*struct option ' \
1245 exclude
='const struct option|struct option const' \
1246 halt
='add "const" to the above declarations' \
1247 $(_sc_search_regexp
)
1250 $$($(SED
) -n
'/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
1253 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \
1257 # Ensure that we don't accidentally insert an entry into an old NEWS block.
1259 @if
test -f
$(srcdir)/NEWS
; then \
1260 test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
1261 { echo
'$(ME): you have modified old NEWS' 1>&2; exit
1; }; \
1264 # Update the hash stored above. Do this after each release and
1265 # for any corrections to old entries.
1266 update-NEWS-hash
: NEWS
1267 perl
-pi
-e
's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \
1270 # Ensure that we use only the standard $(VAR) notation,
1271 # not @...@ in Makefile.am, now that we can rely on automake
1272 # to emit a definition for each substituted variable.
1273 # However, there is still one case in which @VAR@ use is not just
1274 # legitimate, but actually required: when augmenting an automake-defined
1275 # variable with a prefix. For example, gettext uses this:
1276 # MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
1277 # otherwise, makeinfo would put German or French (current locale)
1278 # navigation hints in the otherwise-English documentation.
1280 # Allow the package to add exceptions via a hook in cfg.mk;
1281 # for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
1282 # setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
1283 _makefile_at_at_check_exceptions ?
=
1284 sc_makefile_at_at_check
:
1285 @perl
-ne
'/\@\w+\@/' \
1286 -e
' && !/(\w+)\s+=.*\@\1\@$$/' \
1287 -e
''$(_makefile_at_at_check_exceptions
) \
1288 -e
'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
1289 $$($(VC_LIST_EXCEPT
) |
$(GREP
) -E
'(^|/)(Makefile\.am|[^/]+\.mk)$$') \
1290 && { echo
'$(ME): use $$(...), not @...@' 1>&2; exit
1; } ||
:
1293 $(AM_V_GEN
)if
$(SED
) -n
$(news-check-lines-spec
)p
$< \
1294 |
$(GREP
) -E
$(news-check-regexp
) >/dev
/null
; then \
1297 echo
'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
1301 sc_makefile_TAB_only_indentation
:
1302 @prohibit
='^ [ ]{8}' \
1303 in_vc_files
='akefile|\.mk$$' \
1304 halt
='found TAB-8-space indentation' \
1305 $(_sc_search_regexp
)
1308 @prohibit
='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
1309 in_vc_files
='(^configure\.ac|\.m4)$$' \
1310 halt
='quote the first arg to AC_DEF*' \
1311 $(_sc_search_regexp
)
1313 fix_po_file_diag
= \
1314 'you have changed the set of files with translatable diagnostics;\n\
1315 apply the above patch\n'
1317 # Generate a list of files in which to search for translatable strings.
1318 perl_translatable_files_list_
= \
1319 -e
'foreach $$file (@ARGV) {' \
1320 -e
' \# Consider only file extensions with one or two letters' \
1321 -e
' $$file =~ /\...?$$/ or next;' \
1322 -e
' \# Ignore m4 and mk files' \
1323 -e
' $$file =~ /\.m[4k]$$/ and next;' \
1324 -e
' \# Ignore a .c or .h file with a corresponding .l or .y file' \
1325 -e
' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \
1327 -e
' \# Skip unreadable files' \
1328 -e
' -r $$file or next;' \
1329 -e
' print "$$file ";' \
1332 # Verify that all source files using _() (more specifically, files that
1333 # match $(_gl_translatable_string_re)) are listed in po/POTFILES.in.
1334 po_file ?
= $(srcdir)/po
/POTFILES.in
1335 generated_files ?
= $(srcdir)/lib
/*.
[ch
]
1336 _gl_translatable_string_re ?
= \b(N?_|gettext
*)\
([^
)"]*("|
$$)
1338 @if
test -f
$(po_file
); then \
1339 $(GREP
) -E
-v
'^(#|$$)' $(po_file
) \
1340 |
$(GREP
) -v
'^src/false\.c$$' |
sort > $@
-1; \
1341 { $(VC_LIST_EXCEPT
); echo
$(generated_files
); } \
1342 | xargs perl
$(perl_translatable_files_list_
) \
1343 | xargs
$(GREP
) -E
-l
'$(_gl_translatable_string_re)' \
1344 |
$(SED
) 's|^$(_dot_escaped_srcdir)/||' \
1346 diff
-u
-L
$(po_file
) -L
$(po_file
) $@
-1 $@
-2 \
1347 ||
{ printf
'$(ME): '$(fix_po_file_diag
) 1>&2; exit
1; }; \
1351 # Sometimes it is useful to change the PATH environment variable
1352 # in Makefiles. When doing so, it's better not to use the Unix-centric
1353 # path separator of ':', but rather the automake-provided '$(PATH_SEPARATOR)'.
1354 msg
= 'Do not use ":" above; use $$(PATH_SEPARATOR) instead'
1355 sc_makefile_path_separator_check
:
1356 @prohibit
='PATH[=].*:' \
1357 in_vc_files
='akefile|\.mk$$' \
1359 $(_sc_search_regexp
)
1361 sc_makefile_DISTCHECK_CONFIGURE_FLAGS
:
1362 @prohibit
='^DISTCHECK_CONFIGURE_FLAGS' \
1363 in_vc_files
='akefile|\.mk$$' \
1364 halt
="use AM_DISTCHECK_CONFIGURE_FLAGS" \
1365 $(_sc_search_regexp
)
1367 # Check that 'make alpha' will not fail at the end of the process,
1368 # i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release)
1371 $(AM_V_GEN
)if
test -d
$(release_archive_dir
); then \
1372 for file in
$(DIST_ARCHIVES
); do \
1373 for p in .
/ $(release_archive_dir
)/; do \
1374 test -e
$$p$$file || continue
; \
1376 ||
{ echo ERROR
: $$p$$file is not writable
; fail
=1; }; \
1379 test "$$fail" && exit
1 ||
: ; \
1383 v_etc_file
= $(gnulib_dir
)/lib
/version-etc.c
1384 sample-test
= tests
/sample-test
1385 texi
= doc
/$(PACKAGE
).texi
1386 # Make sure that the copyright date in $(v_etc_file) is up to date.
1387 # Do the same for the $(sample-test) and the main doc/.texi file.
1389 @require
='enum { COPYRIGHT_YEAR = '$$(date
+%Y
)' };' \
1390 in_files
=$(v_etc_file
) \
1391 halt
='out of date copyright in $(v_etc_file); update it' \
1392 $(_sc_search_regexp
)
1393 @require
='# Copyright \(C\) '$$(date
+%Y
)' Free' \
1394 in_vc_files
=$(sample-test
) \
1395 halt
='out of date copyright in $(sample-test); update it' \
1396 $(_sc_search_regexp
)
1397 @require
='Copyright @copyright\{} .*'$$(date
+%Y
) \
1398 in_vc_files
=$(texi
) \
1399 halt
='out of date copyright in $(texi); update it' \
1400 $(_sc_search_regexp
)
1402 # If tests/help-version exists and seems to be new enough, assume that its
1403 # use of init.sh and path_prepend_ is correct, and ensure that every other
1404 # use of init.sh is identical.
1405 # This is useful because help-version cross-checks prog --version
1406 # with $(VERSION), which verifies that its path_prepend_ invocation
1407 # sets PATH correctly. This is an inexpensive way to ensure that
1408 # the other init.sh-using tests also get it right.
1409 _hv_file ?
= $(srcdir)/tests
/help-version
1410 _hv_regex_weak ?
= ^
*\. .
*/init\.sh
"
1411 # Fix syntax-highlighters "
1412 _hv_regex_strong ?
= ^
*\.
"\$${srcdir=\.}/init\.sh"
1413 sc_cross_check_PATH_usage_in_tests
:
1414 @if
test -f
$(_hv_file
); then \
1415 $(GREP
) -l
'VERSION mismatch' $(_hv_file
) >/dev
/null \
1416 ||
{ echo
"$@: skipped: no such file: $(_hv_file)" 1>&2; \
1418 $(GREP
) -lE
'$(_hv_regex_strong)' $(_hv_file
) >/dev
/null \
1419 ||
{ echo
"$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
1421 good
=$$($(GREP
) -E
'$(_hv_regex_strong)' $(_hv_file
)); \
1423 | xargs
$(GREP
) -lE
'$(_hv_regex_weak)' \
1424 | xargs
$(GREP
) -LFx
"$$good" \
1426 && { printf
"$(ME): the above files use" \
1427 " path_prepend_ inconsistently\n" 1>&2; \
1432 # BRE regex of file contents to identify a test script.
1433 _test_script_regex ?
= \
<init\.sh\
>
1435 # In tests, use "compare expected actual", not the reverse.
1436 sc_prohibit_reversed_compare_failure
:
1437 @prohibit
='\<compare [^ ]+ ([^ ]*exp|/dev/null)' \
1438 containing
='$(_test_script_regex)' \
1439 halt
='reversed compare arguments' \
1440 $(_sc_search_regexp
)
1442 # #if HAVE_... will evaluate to false for any non numeric string.
1443 # That would be flagged by using -Wundef, however gnulib currently
1444 # tests many undefined macros, and so we can't enable that option.
1445 # So at least preclude common boolean strings as macro values.
1447 @prohibit
='^#define.*(yes|no|true|false)$$' \
1448 in_files
='$(CONFIG_INCLUDE)' \
1449 halt
='Use 0 or 1 for macro values' \
1450 $(_sc_search_regexp
)
1452 # Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
1453 # not be constant, or might overflow a stack. In general, use PATH_MAX as
1454 # a limit, not an array or alloca size.
1455 sc_prohibit_path_max_allocation
:
1456 @prohibit
='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \
1457 halt
='Avoid stack allocations of size PATH_MAX' \
1458 $(_sc_search_regexp
)
1460 sc_vulnerable_makefile_CVE-2009-4029
:
1461 @prohibit
='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
1462 in_files
='(^|/)Makefile\.in$$' \
1463 halt
=$$(printf
'%s\n' \
1464 'the above files are vulnerable; beware of running' \
1465 ' "make dist*" rules, and upgrade to fixed automake' \
1466 ' see https://bugzilla.redhat.com/show_bug.cgi?id=542609 for details') \
1467 $(_sc_search_regexp
)
1469 sc_vulnerable_makefile_CVE-2012-3386
:
1470 @prohibit
='chmod a\+w \$$\(distdir\)' \
1471 in_files
='(^|/)Makefile\.in$$' \
1472 halt
=$$(printf
'%s\n' \
1473 'the above files are vulnerable; beware of running' \
1474 ' "make distcheck", and upgrade to fixed automake' \
1475 ' see https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-3386 for details') \
1476 $(_sc_search_regexp
)
1478 sc_unportable_grep_q
:
1479 @prohibit
='grep -q' halt
="unportable 'grep -q', use >/dev/null instead" \
1480 $(_sc_search_regexp
)
1482 # The GNU Coding standards say that README should refer to both
1483 # INSTALL and the file that contains the copying conditions. This
1484 # shall be COPYING for GPL and COPYING.LESSER for LGPL.
1486 sc_readme_link_install
:
1487 @require
='INSTALL' \
1488 in_vc_files
='^README$$' \
1489 halt
='The README file should refer to INSTALL' \
1490 $(_sc_search_regexp
)
1492 sc_readme_link_copying
:
1493 @require
='COPYING' \
1494 in_vc_files
='^README$$' \
1495 halt
='The README file should refer to COPYING[.LESSER]' \
1496 $(_sc_search_regexp
)
1499 $(AM_V_GEN
)(unset CDPATH
; cd
$(srcdir) && $(VC
) diff
) > vc-diffs ||
:
1500 $(AM_V_at
)if
test -s vc-diffs
; then \
1502 echo
"Some files are locally modified:" 1>&2; \
1508 rel-files
= $(DIST_ARCHIVES
)
1510 gnulib-version
= $$(cd
$(gnulib_dir
) \
1511 && { git describe
2> /dev
/null || git rev-parse
--short
=10 HEAD
; } )
1512 bootstrap-tools ?
= autoconf
,automake
,gnulib
1514 gpgv
= $$(gpgv2
--version
>/dev
/null
&& echo gpgv2 || echo gpgv
)
1515 # If it's not already specified, derive the GPG key ID from
1516 # the signed tag we've just applied to mark this release.
1519 && git cat-file tag v
$(VERSION
) \
1520 |
$(gpgv
) --status-fd
1 --keyring
/dev
/null
- - 2>/dev
/null \
1521 |
$(AWK
) '/^\[GNUPG:] ERRSIG / {print $$3; exit}')
1523 $$(gpg
--list-key
--with-colons
$(gpg_key_ID
) 2>/dev
/null \
1524 |
$(AWK
) -F
: '/^uid/ {print $$10; exit}' \
1525 |
$(SED
) -n
's/.*<\(.*\)>/\1/p')
1526 gpg_keyring_url ?
= https
://savannah.gnu.org
/project
/release-gpgkeys.php?group
=$(PACKAGE
)&download
=1
1528 translation_project_ ?
= coordinator@translationproject.org
1530 # Make info-gnu the default only for a stable release.
1531 announcement_Cc_stable
= $(translation_project_
), $(PACKAGE_BUGREPORT
)
1532 announcement_mail_headers_stable
= \
1533 To
: info-gnu@gnu.org \
1534 Cc
: $(announcement_Cc_
) \
1535 Mail-Followup-To
: $(PACKAGE_BUGREPORT
)
1537 announcement_Cc_alpha
= $(translation_project_
)
1538 announcement_mail_headers_alpha
= \
1539 To
: $(PACKAGE_BUGREPORT
) \
1540 Cc
: $(announcement_Cc_
)
1542 announcement_mail_Cc_beta
= $(announcement_mail_Cc_alpha
)
1543 announcement_mail_headers_beta
= $(announcement_mail_headers_alpha
)
1545 announcement_Cc_ ?
= $(announcement_Cc_
$(release-type
))
1546 announcement_mail_headers_ ?
= $(announcement_mail_headers_
$(release-type
))
1547 announcement
: NEWS ChangeLog
$(rel-files
)
1548 # Not $(AM_V_GEN) since the output of this command serves as
1549 # announcement message: it would start with " GEN announcement".
1550 $(AM_V_at
)$(srcdir)/$(_build-aux
)/announce-gen \
1551 --mail-headers
='$(announcement_mail_headers_)' \
1552 --release-type
=$(release-type
) \
1553 --package
=$(PACKAGE
) \
1554 --prev
=$(PREV_VERSION
) \
1556 --gpg-key-id
=$(gpg_key_ID
) \
1557 $$(test -n
"$(gpg_key_email)" && \
1558 echo
--gpg-key-email
="$(gpg_key_email)") \
1559 $$(test -n
"$(gpg_keyring_url)" && \
1560 echo
--gpg-keyring-url
="$(gpg_keyring_url)") \
1561 --srcdir=$(srcdir) \
1562 --news
=$(srcdir)/NEWS \
1563 --bootstrap-tools
=$(bootstrap-tools
) \
1564 $$(case
,$(bootstrap-tools
), in
(*,gnulib
,*) \
1565 echo
--gnulib-version
=$(gnulib-version
);; esac
) \
1566 $(addprefix --url-dir
=, $(url_dir_list
))
1568 .PHONY
: release-commit
1570 $(AM_V_GEN
)cd
$(srcdir) \
1571 && $(_build-aux
)/do-release-commit-and-tag \
1572 -C
$(abs_builddir
) $(RELEASE
)
1574 ## ---------------- ##
1575 ## Updating files. ##
1576 ## ---------------- ##
1578 ftp-gnu
= https
://ftp.gnu.org
/gnu
1579 www-gnu
= https
://www.gnu.org
1581 upload_dest_dir_ ?
= $(PACKAGE
)
1583 $(srcdir)/$(_build-aux
)/gnupload
$(GNUPLOADFLAGS
) \
1584 --to
$(gnu_rel_host
):$(upload_dest_dir_
) \
1586 emit_upload_commands
:
1587 @echo
=====================================
1588 @echo
=====================================
1589 @echo
'$(upload_command)'
1590 @echo
'# send the ~/announce-$(my_distdir) e-mail'
1591 @echo
=====================================
1592 @echo
=====================================
1596 $(AM_V_GEN
)$(upload_command
)
1598 define emit-commit-log
1599 printf
'%s\n' 'maint: post-release administrivia' '' \
1600 '* NEWS: Add header line for next release.' \
1601 '* .prev-version: Record previous version.' \
1602 '* cfg.mk (old_NEWS_hash): Auto-update.'
1605 .PHONY
: no-submodule-changes
1606 no-submodule-changes
:
1607 $(AM_V_GEN
)if
test -d
$(srcdir)/.git \
1608 && git
--version
>/dev
/null
2>&1; then \
1609 diff
=$$(cd
$(srcdir) && git submodule
-q
foreach \
1610 git diff-index
--name-only HEAD
) \
1612 case
$$diff in
'') ;; \
1613 *) echo
'$(ME): submodule files are locally modified:'; \
1614 echo
"$$diff"; exit
1;; esac
; \
1619 submodule-checks ?
= no-submodule-changes public-submodule-commit
1621 # Ensure that each sub-module commit we're using is public.
1622 # Without this, it is too easy to tag and release code that
1623 # cannot be built from a fresh clone.
1624 .PHONY
: public-submodule-commit
1625 public-submodule-commit
:
1626 $(AM_V_GEN
)if
test -d
$(srcdir)/.git \
1627 && git
--version
>/dev
/null
2>&1; then \
1629 git submodule
--quiet
foreach \
1630 'test "$$(git rev-parse "$$sha1")" \
1631 = "$$(git merge-base origin "$$sha1")"' \
1632 ||
{ echo
'$(ME): found non-public submodule commit' >&2; \
1637 # This rule has a high enough utility/cost ratio that it should be a
1638 # dependent of "check" by default. However, some of us do occasionally
1639 # commit a temporary change that deliberately points to a non-public
1640 # submodule commit, and want to be able to use rules like "make check".
1641 # In that case, run e.g., "make check gl_public_submodule_commit="
1642 # to disable this test.
1643 gl_public_submodule_commit ?
= public-submodule-commit
1644 check: $(gl_public_submodule_commit
)
1646 .PHONY
: alpha beta stable release
1647 ALL_RECURSIVE_TARGETS
+= alpha beta stable
1648 alpha beta stable
: $(local-check
) writable-files
$(submodule-checks
)
1649 $(AM_V_GEN
)test $@
= stable \
1650 && { echo
$(VERSION
) |
$(GREP
) -E
'^[0-9]+(\.[0-9]+)+$$' \
1651 ||
{ echo
"invalid version string: $(VERSION)" 1>&2; exit
1;};}\
1653 $(AM_V_at
)$(MAKE
) vc-diff-check
1654 $(AM_V_at
)$(MAKE
) news-check
1655 $(AM_V_at
)$(MAKE
) distcheck
1656 $(AM_V_at
)$(MAKE
) dist
1657 $(AM_V_at
)$(MAKE
) $(release-prep-hook
) RELEASE_TYPE
=$@
1658 $(AM_V_at
)$(MAKE
) -s emit_upload_commands RELEASE_TYPE
=$@
1661 $(AM_V_GEN
)$(MAKE
) _version
1662 $(AM_V_at
)$(MAKE
) $(release-type
)
1664 # Override this in cfg.mk if you follow different procedures.
1665 release-prep-hook ?
= release-prep
1667 gl_noteworthy_news_
= * Noteworthy changes in release ?.?
(????
-??
-??
) [?
]
1668 .PHONY
: release-prep
1670 $(AM_V_GEN
)$(MAKE
) --no-print-directory
-s announcement \
1671 > ~
/announce-
$(my_distdir
)
1672 $(AM_V_at
)if
test -d
$(release_archive_dir
); then \
1673 ln
$(rel-files
) $(release_archive_dir
); \
1674 chmod a-w
$(rel-files
); \
1676 $(AM_V_at
)echo
$(VERSION
) > $(prev_version_file
)
1677 $(AM_V_at
)$(MAKE
) update-NEWS-hash
1678 $(AM_V_at
)perl
-pi \
1679 -e
'$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' \
1681 $(AM_V_at
)msg
=$$($(emit-commit-log
)) || exit
1; \
1682 cd
$(srcdir) && $(VC
) commit
-m
"$$msg" -a
1684 # Override this with e.g., -s $(srcdir)/some_other_name.texi
1685 # if the default $(PACKAGE)-derived name doesn't apply.
1690 $(AM_V_GEN
)test -z
"$(manual_title)" \
1691 && { echo
define manual_title in cfg.mk
1>&2; exit
1; } ||
:
1692 $(AM_V_at
)cd
'$(srcdir)/doc'; \
1693 $(SHELL
) ..
/$(_build-aux
)/gendocs.sh
$(gendocs_options_
) \
1694 -o
'$(abs_builddir)/doc/manual' \
1695 --email
$(PACKAGE_BUGREPORT
) $(PACKAGE
) \
1696 "$(PACKAGE_NAME) - $(manual_title)"
1697 $(AM_V_at
)echo
" *** Upload the doc/manual directory to web-cvs."
1699 .PHONY
: web-manual-update
1701 $(AM_V_GEN
)cd
$(srcdir) \
1702 && $(_build-aux
)/gnu-web-doc-update
-C
$(abs_builddir
)
1708 $(MAKE
) $(AM_MAKEFLAGS
) clean
1709 lcov
--directory .
--zerocounters
1711 COVERAGE_CCOPTS ?
= "-g --coverage"
1712 COVERAGE_OUT ?
= doc
/coverage
1715 $(MAKE
) $(AM_MAKEFLAGS
) CFLAGS
=$(COVERAGE_CCOPTS
) CXXFLAGS
=$(COVERAGE_CCOPTS
)
1716 $(MAKE
) $(AM_MAKEFLAGS
) CFLAGS
=$(COVERAGE_CCOPTS
) CXXFLAGS
=$(COVERAGE_CCOPTS
) check
1717 mkdir
-p
$(COVERAGE_OUT
)
1718 lcov
--directory .
--output-file
$(COVERAGE_OUT
)/$(PACKAGE
).
info \
1722 genhtml
--output-directory
$(COVERAGE_OUT
) \
1723 $(COVERAGE_OUT
)/$(PACKAGE
).
info \
1724 --highlight
--frames
--legend \
1725 --title
"$(PACKAGE_NAME)"
1728 $(MAKE
) init-coverage
1729 $(MAKE
) build-coverage
1730 $(MAKE
) gen-coverage
1732 # Some projects carry local adjustments for gnulib modules via patches in
1733 # a gnulib patch directory whose default name is gl/ (defined in bootstrap
1734 # via local_gl_dir=gl). Those patches become stale as the originals evolve
1735 # in gnulib. Use this rule to refresh any stale patches. It applies each
1736 # patch to the original in $(gnulib_dir) and uses the temporary result to
1737 # generate a fuzz-free .diff file. If you customize the name of your local
1738 # gnulib patch directory via bootstrap.conf, this rule detects that name.
1739 # Run this from a non-VPATH (i.e., srcdir) build directory.
1740 .PHONY
: refresh-gnulib-patches
1741 refresh-gnulib-patches
:
1743 if
test -f bootstrap.conf
; then \
1744 t
=$$(perl
-lne
'/^\s*local_gl_dir=(\S+)/ and $$d=$$1;' \
1745 -e
'END{defined $$d and print $$d}' bootstrap.conf
); \
1746 test -n
"$$t" && gl
=$$t; \
1748 for diff in
$$(cd
$$gl; git ls-files |
$(GREP
) '\.diff$$'); do \
1749 b
=$$(printf
%s
"$$diff"|
$(SED
) 's/\.diff$$//'); \
1750 VERSION_CONTROL
=none \
1751 patch
"$(gnulib_dir)/$$b" "$$gl/$$diff" || exit
1; \
1752 ( cd
$(gnulib_dir
) || exit
1; \
1753 git diff
"$$b" > "../$$gl/$$diff"; \
1754 git checkout
$$b ) || exit
1; \
1757 # Update gettext files.
1758 PACKAGE ?
= $(shell basename $(PWD
))
1759 PO_DOMAIN ?
= $(PACKAGE
)
1760 POURL
= https
://translationproject.org
/latest
/$(PO_DOMAIN
)/
1763 rm -f
$(PODIR
)/*.po
&& \
1764 echo
"$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
1765 wget
--no-verbose
--directory-prefix
$(PODIR
) --no-directories
--recursive
--level
1 --accept .po
--accept .po
.1 $(POURL
) && \
1766 echo
'en@boldquot' > $(PODIR
)/LINGUAS
&& \
1767 echo
'en@quot' >> $(PODIR
)/LINGUAS
&& \
1768 ls
$(PODIR
)/*.po |
$(SED
) 's/\.po//;s,$(PODIR)/,,' | \
1769 sort >> $(PODIR
)/LINGUAS
1773 indent_args ?
= --ignore-profile
--preprocessor-indentation
1
1774 C_SOURCES ?
= $$($(VC_LIST_EXCEPT
) | grep
'\.[ch]\(.in\)\?$$')
1775 INDENT_SOURCES ?
= $(C_SOURCES
)
1776 exclude_file_name_regexp--indent ?
= $(exclude_file_name_regexp--sc_indent
)
1779 indent
: # Running indent once is not idempotent, but running it twice is.
1780 $(AM_V_GEN
)indent
$(indent_args
) $(INDENT_SOURCES
) && \
1781 indent
$(indent_args
) $(INDENT_SOURCES
)
1784 @if
! indent
--version
2> /dev
/null | grep
'GNU indent' > /dev
/null
; then \
1785 echo
1>&2 '$(ME): sc_indent: GNU indent is missing'; \
1787 fail
=0; files
="$(INDENT_SOURCES)"; \
1788 for f in
$$files; do \
1789 indent
$(indent_args
) -st
$$f \
1790 | indent
$(indent_args
) -st
- \
1791 | diff
-u
$$f - || fail
=1; \
1793 test $$fail = 1 && \
1794 { echo
1>&2 '$(ME): code format error, try "make indent"'; \
1798 # If you want to set UPDATE_COPYRIGHT_* environment variables,
1799 # put the assignments in this variable.
1800 update-copyright-env ?
=
1802 # Run this rule once per year (usually early in January)
1803 # to update all FSF copyright year lists in your project.
1804 # If you have an additional project-specific rule,
1805 # add it in cfg.mk along with a line 'update-copyright: prereq'.
1806 # By default, exclude all variants of COPYING; you can also
1807 # add exemptions (such as ChangeLog..* for rotated change logs)
1808 # in the file .x-update-copyright.
1809 .PHONY
: update-copyright
1811 $(AM_V_GEN
)$(GREP
) -l
-w Copyright \
1812 $$(export VC_LIST_EXCEPT_DEFAULT
=COPYING
&& $(VC_LIST_EXCEPT
)) \
1813 |
$(update-copyright-env
) xargs
$(srcdir)/$(_build-aux
)/$@
1815 # This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
1816 # overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
1818 # NOTE: to override any _gl_TS_* default value, you must
1819 # define the variable(s) using "export" in cfg.mk.
1822 ALL_RECURSIVE_TARGETS
+= sc_tight_scope
1823 sc_tight_scope
: tight-scope.mk
1825 if
! $(GREP
) '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \
1827 && ! $(GREP
) -w noinst_HEADERS
$(srcdir)/$(_gl_TS_dir
)/Makefile.am \
1828 > /dev
/null
2>&1; then \
1829 echo
'$(ME): skipping $@'; \
1831 $(MAKE
) -s
-C
$(_gl_TS_dir
) \
1833 -f
$(abs_top_srcdir
)/cfg.mk \
1834 -f
$(abs_top_builddir
)/$< \
1841 tight-scope.mk
: $(ME
)
1842 @perl
-ne
'/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME
) > $@
-t
1848 # Most functions should have static scope.
1849 # Any that don't must be marked with 'extern', but 'main'
1850 # and 'usage' are exceptions: they're always extern, but
1851 # do not need to be marked. Symbols matching '__.*' are
1852 # reserved by the compiler, so are automatically excluded below.
1853 _gl_TS_unmarked_extern_functions ?
= main usage
1854 _gl_TS_function_match ?
= /^
(?
:$(_gl_TS_extern
)) +.
*?
(\w
+) *\
(/
1856 # If your project uses a macro like "XTERN", then put
1857 # the following in cfg.mk to override this default:
1858 # export _gl_TS_extern = extern|XTERN
1859 _gl_TS_extern ?
= extern
1861 # The second nm|grep checks for file-scope variables with 'extern' scope.
1862 # Without gnulib's progname module, you might put program_name here.
1863 # Symbols matching '__.*' are reserved by the compiler,
1864 # so are automatically excluded below.
1865 _gl_TS_unmarked_extern_vars ?
=
1867 # NOTE: the _match variables are perl expressions -- not mere regular
1868 # expressions -- so that you can extend them to match other patterns
1869 # and easily extract matched variable names.
1870 # For example, if your project declares some global variables via
1871 # a macro like this: GLOBAL(type, var_name, initializer), then you
1872 # can override this definition to automatically extract those names:
1873 # export _gl_TS_var_match = \
1874 # /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
1875 _gl_TS_var_match ?
= /^
(?
:$(_gl_TS_extern
)) .
*?
(\w
+)(\
[.
*?
])?
;/
1877 # The names of object files in (or relative to) $(_gl_TS_dir).
1878 _gl_TS_obj_files ?
= *.
$(OBJEXT
)
1880 # Files in which to search for the one-line style extern declarations.
1881 # $(_gl_TS_dir)-relative.
1882 _gl_TS_headers ?
= $(noinst_HEADERS
)
1883 _gl_TS_other_headers ?
= *.h
1885 .PHONY
: _gl_tight_scope
1886 _gl_tight_scope
: $(bin_PROGRAMS
)
1887 sed_wrap
='s/^/^_?/;s/$$/$$/'; \
1888 t
=exceptions-
$$$$; \
1889 trap
's=$$?; rm -f $$t; exit $$s' 0; \
1890 for sig in
1 2 3 13 15; do \
1891 eval
"trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
1893 src
=`for f in $(sort $(SOURCES)); do \
1894 test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
1895 hdr
=`for f in $(_gl_TS_headers); do \
1896 test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
1897 ( printf
'%s\n' '__.*' $(_gl_TS_unmarked_extern_functions
); \
1898 $(GREP
) -h
-A1
'^extern .*[^;]$$' $$src \
1899 |
$(GREP
) -vE
'^(extern |--|#)' |
$(SED
) 's/ .*//; /^$$/d'; \
1901 '$(_gl_TS_function_match) and print $$1' $$hdr; \
1902 ) |
sort -u |
$(SED
) "$$sed_wrap" > $$t; \
1903 nm
-g
$(_gl_TS_obj_files
)|
$(SED
) -n
's/.* T //p'|
$(GREP
) -Ev
-f
$$t \
1904 && { echo the above functions should have static scope
>&2; \
1906 ( printf
'%s\n' '__.*' main
$(_gl_TS_unmarked_extern_vars
); \
1907 perl
-lne
'$(_gl_TS_var_match) and print $$1' \
1908 $$hdr $(_gl_TS_other_headers
) \
1909 ) |
sort -u |
$(SED
) "$$sed_wrap" > $$t; \
1910 nm
-g
$(_gl_TS_obj_files
) |
$(SED
) -n
's/.* [BCDGRS] //p' \
1911 |
sort -u |
$(GREP
) -Ev
-f
$$t \
1912 && { echo the above variables should have static scope
>&2; \