2
2
# This Makefile fragment tries to be general-purpose enough to be
3
3
# used by many projects via the gnulib maintainer-makefile module.
5
## Copyright (C) 2001-2011 Free Software Foundation, Inc.
5
## Copyright (C) 2001-2012 Free Software Foundation, Inc.
7
7
## This program is free software: you can redistribute it and/or modify
8
8
## it under the terms of the GNU General Public License as published by
21
21
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
24
# Override this in cfg.mk if you use a non-standard build-aux directory.
25
build_aux ?= $(srcdir)/build-aux
24
# Diagnostic for continued use of deprecated variable.
28
set $$(_build-aux) relative to $$(srcdir) instead of $$(build_aux)")
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)))
27
53
# Do not save the original name or timestamp in the .tar.gz file.
28
54
# Use --rsyncable if available.
48
74
# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
49
75
# when $(srcdir) is not ".".
51
_prepend_srcdir_prefix =
77
_prepend_srcdir_prefix =
53
_prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
79
_prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
56
82
# In order to be able to consistently filter "."-relative names,
57
83
# (i.e., with no $(srcdir) prefix), this definition is careful to
58
84
# remove any $(srcdir) prefix, and to restore what it removes.
60
$(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
86
$(or $(exclude_file_name_regexp--$@),^$$)
62
88
$(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
63
89
| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
74
100
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
76
102
ifeq ($(VC),$(GIT))
77
this-vc-tag = v$(VERSION)
78
this-vc-tag-regexp = v$(VERSION_REGEXP)
103
this-vc-tag = v$(VERSION)
104
this-vc-tag-regexp = v$(VERSION_REGEXP)
80
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
81
tag-this-version = $(subst .,_,$(VERSION))
82
this-vc-tag = $(tag-package)-$(tag-this-version)
83
this-vc-tag-regexp = $(this-vc-tag)
106
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
107
tag-this-version = $(subst .,_,$(VERSION))
108
this-vc-tag = $(tag-package)-$(tag-this-version)
109
this-vc-tag-regexp = $(this-vc-tag)
85
111
my_distdir = $(PACKAGE)-$(VERSION)
87
113
# Old releases are stored here.
88
114
release_archive_dir ?= ../release
116
# If RELEASE_TYPE is undefined, but RELEASE is, use its second word.
117
# But overwrite VERSION.
119
VERSION := $(word 1, $(RELEASE))
120
RELEASE_TYPE ?= $(word 2, $(RELEASE))
123
# Validate and return $(RELEASE_TYPE), or die.
124
RELEASE_TYPES = alpha beta stable
125
release-type = $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES))
90
127
# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
91
128
# Use alpha.gnu.org for alpha and beta releases.
92
129
# Use ftp.gnu.org for stable releases.
93
130
gnu_ftp_host-alpha = alpha.gnu.org
94
131
gnu_ftp_host-beta = alpha.gnu.org
95
132
gnu_ftp_host-stable = ftp.gnu.org
96
gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE))
133
gnu_rel_host ?= $(gnu_ftp_host-$(release-type))
98
ifeq ($(gnu_rel_host),ftp.gnu.org)
99
url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE)
101
url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
135
url_dir_list ?= $(if $(call _equal,$(gnu_rel_host),ftp.gnu.org), \
136
http://ftpmirror.gnu.org/$(PACKAGE), \
137
ftp://$(gnu_rel_host)/gnu/$(PACKAGE))
104
139
# Override this in cfg.mk if you are using a different format in your
123
158
_cfg_mk := $(shell test -f $(srcdir)/cfg.mk && echo '$(srcdir)/cfg.mk')
125
# Collect the names of rules starting with `sc_'.
160
# Collect the names of rules starting with 'sc_'.
126
161
syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
127
162
$(srcdir)/$(ME) $(_cfg_mk)))
128
163
.PHONY: $(syntax-check-rules)
130
165
ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0)
131
local-checks-available += $(syntax-check-rules)
166
local-checks-available += $(syntax-check-rules)
133
local-checks-available += no-vc-detected
168
local-checks-available += no-vc-detected
135
170
@echo "No version control files detected; skipping syntax check"
174
209
# Regular expression (ERE) denoting either a forbidden construct
175
210
# or a required construct. Those arguments are exclusive.
214
# Regular expression (ERE) denoting lines to ignore that matched
215
# a prohibit construct. For example, this can be used to exclude
216
# comments that mention why the nearby code uses an alternative
217
# construct instead of the simpler prohibited construct.
177
219
# in_vc_files | in_files
179
# grep-E-style regexp denoting the files to check. If no files
180
# are specified the default are all the files that are under
221
# grep-E-style regexp selecting the files to check. For in_vc_files,
222
# the regexp is used to select matching files from the list of all
223
# version-controlled files; for in_files, it's from the names printed
224
# by "find $(srcdir)". When neither is specified, use all files that
225
# are under version control.
183
227
# containing | non_containing
217
272
{ printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; };
220
# _sc_search_regexp used to be named _prohibit_regexp. However,
221
# upgrading to the new definition and leaving the old name undefined
222
# would usually convert each custom rule using $(_prohibit_regexp)
223
# (usually defined in cfg.mk) into a no-op. This definition ensures
224
# that people know right away if they're still using the old name.
225
# FIXME: remove in 2012.
227
$(error '*** you need to s/_prohibit_regexp/_sc_search_regexp/, and adapt')
229
275
define _sc_search_regexp
230
276
dummy=; : so we do not need a semicolon before each use; \
236
282
test -z "$$prohibit" && test -z "$$require" \
237
283
&& { msg='Should specify either prohibit or require' \
238
284
$(_sc_say_and_exit) } || :; \
285
test -z "$$prohibit" && test -n "$$exclude" \
286
&& { msg='Use of exclude requires a prohibit pattern' \
287
$(_sc_say_and_exit) } || :; \
239
288
test -n "$$in_vc_files" && test -n "$$in_files" \
240
289
&& { msg='Cannot specify both in_vc_files and in_files' \
241
290
$(_sc_say_and_exit) } || :; \
276
326
sc_avoid_if_before_free:
277
@$(build_aux)/useless-if-before-free \
327
@$(srcdir)/$(_build-aux)/useless-if-before-free \
278
328
$(useless_free_options) \
279
329
$$($(VC_LIST_EXCEPT) | grep -v useless-if-before-free) && \
280
330
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
283
333
sc_cast_of_argument_to_free:
284
@prohibit='\<free *\( *\(' halt='don'\''t cast free argument' \
334
@prohibit='\<free *\( *\(' halt="don't cast free argument" \
285
335
$(_sc_search_regexp)
287
337
sc_cast_of_x_alloc_return_value:
288
338
@prohibit='\*\) *x(m|c|re)alloc\>' \
289
halt='don'\''t cast x*alloc return value' \
339
halt="don't cast x*alloc return value" \
290
340
$(_sc_search_regexp)
292
342
sc_cast_of_alloca_return_value:
293
343
@prohibit='\*\) *alloca\>' \
294
halt='don'\''t cast alloca return value' \
344
halt="don't cast alloca return value" \
295
345
$(_sc_search_regexp)
308
358
$(_sc_search_regexp)
310
360
# Use STREQ rather than comparing strcmp == 0, or != 0.
311
362
sc_prohibit_strcmp:
312
@grep -nE '! *str''cmp *\(|\<str''cmp *\(.+\) *[!=]=' \
313
$$($(VC_LIST_EXCEPT)) \
314
| grep -vE ':# *define STRN?EQ\(' && \
315
{ echo '$(ME): replace str''cmp calls above with STREQ/STRNEQ' \
363
@prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \
364
exclude='# *define STRN?EQ\(' \
365
halt='replace strcmp calls above with STREQ/STRNEQ' \
368
# Really. You don't want to use this function.
369
# It may fail to NUL-terminate the destination,
370
# and always NUL-pads out to the specified length.
372
@prohibit='\<strncpy *\(' \
373
halt='do not use strncpy, period' \
318
376
# Pass EXIT_*, not number, to usage, exit, and error (when exiting)
319
377
# Convert all uses automatically, via these two commands:
326
384
# | xargs --no-run-if-empty \
327
385
# perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
328
386
sc_prohibit_magic_number_exit:
329
@prohibit='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
330
halt='use EXIT_* values rather than magic number' \
387
@prohibit='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]' \
388
exclude='exit \(77\)|error ?\(((0|77),|[^,]*)' \
389
halt='use EXIT_* values rather than magic number' \
331
390
$(_sc_search_regexp)
333
392
# Using EXIT_SUCCESS as the first argument to error is misleading,
334
# since when that parameter is 0, error does not exit. Use `0' instead.
393
# since when that parameter is 0, error does not exit. Use '0' instead.
335
394
sc_error_exit_success:
336
395
@prohibit='error *\(EXIT_SUCCESS,' \
337
396
in_vc_files='\.[chly]$$' \
338
397
halt='found error (EXIT_SUCCESS' \
339
398
$(_sc_search_regexp)
341
# `FATAL:' should be fully upper-cased in error messages
342
# `WARNING:' should be fully upper-cased, or fully lower-cased
400
# "FATAL:" should be fully upper-cased in error messages
401
# "WARNING:" should be fully upper-cased, or fully lower-cased
343
402
sc_error_message_warn_fatal:
344
403
@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
345
404
| grep -E '"Warning|"Fatal|"fatal' && \
439
498
# Don't include quote.h unless you use one of its functions.
440
499
sc_prohibit_quote_without_use:
441
@h='quote.h' re='\<quote(_n)? *\(' $(_sc_header_without_use)
500
@h='quote.h' re='\<quote((_n)? *\(|_quoting_options\>)' \
501
$(_sc_header_without_use)
443
503
# Don't include this header unless you use one of its functions.
444
504
sc_prohibit_long_options_without_use:
618
676
# Prohibit the inclusion of stddef.h without an actual use.
619
677
sc_prohibit_stddef_without_use:
621
re='\<($(_stddef_syms_re)) *\(' \
679
re='\<($(_stddef_syms_re))\>' \
680
$(_sc_header_without_use)
682
_de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)?
683
_de2 = (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(64)?
684
_de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
685
_dirent_syms_re = $(_de1)|$(_de2)|$(_de3)
686
# Prohibit the inclusion of dirent.h without an actual use.
687
sc_prohibit_dirent_without_use:
689
re='\<($(_dirent_syms_re))\>' \
622
690
$(_sc_header_without_use)
624
692
# Prohibit the inclusion of verify.h without an actual use.
703
772
# Look for diagnostics that aren't marked for translation.
704
773
# This won't find any for which error's format string is on a separate line.
705
774
sc_unmarked_diagnostics:
707
'\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
708
$$($(VC_LIST_EXCEPT)) \
709
| grep -Ev '(_|ngettext ?)\(' && \
710
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
775
@prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
776
exclude='(_|ngettext ?)\(' \
777
halt='found unmarked diagnostic(s)' \
713
780
# Avoid useless parentheses like those in this example:
714
781
# #if defined (SYMBOL) || defined (SYM2)
750
822
# Perl -lne code to extract "significant" cpp-defined symbols from a
751
823
# gnulib header file, eliminating a few common false-positives.
824
# The exempted names below are defined only conditionally in gnulib,
825
# and hence sometimes must/may be defined in application code.
752
826
gl_extract_significant_defines_ = \
753
827
/^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
754
828
&& $$2 !~ /(?:rpl_|_used_without_)/\
755
&& $$1 !~ /^(?:NSIG)$$/\
829
&& $$1 !~ /^(?:NSIG|ENODATA)$$/\
756
830
&& $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\
831
906
# This is a perl script that is expected to be the single-quoted argument
832
907
# to a command-line "-le". The remaining arguments are file names.
833
# Print the name of each file that ends in exactly one newline byte.
908
# Print the name of each file that does not end in exactly one newline byte.
834
909
# I.e., warn if there are blank lines (2 or more newlines), or if the
835
910
# last byte is not a newline. However, currently we don't complain
836
911
# about any file that contains exactly one byte.
903
978
# A regular expression matching undesirable combinations of words like
904
979
# "can not"; this matches them even when the two words appear on different
905
980
# lines, but not when there is an intervening delimiter like "#" or "*".
981
# Similarly undesirable, "See @xref{...}", since an @xref should start
982
# a sentence. Explicitly prohibit any prefix of "see" or "also".
983
# Also prohibit a prefix matching "\w+ +".
984
# @pxref gets the same see/also treatment and should be parenthesized;
985
# presume it must *not* start a sentence.
986
bad_xref_re_ ?= (?:[\w,:;] +|(?:see|also)\s+)\@xref\{
987
bad_pxref_re_ ?= (?:[.!?]|(?:see|also))\s+\@pxref\{
906
988
prohibit_undesirable_word_seq_RE_ ?= \
989
/(?:\bcan\s+not\b|$(bad_xref_re_)|$(bad_pxref_re_))/gims
908
990
prohibit_undesirable_word_seq_ = \
909
991
-e 'while ($(prohibit_undesirable_word_seq_RE_))' \
910
992
$(perl_filename_lineno_text_)
966
1048
$(_sc_search_regexp)
968
1050
sc_const_long_option:
969
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
970
| grep -Ev 'const struct option|struct option const' && { \
971
echo 1>&2 '$(ME): add "const" to the above declarations'; \
1051
@prohibit='^ *static.*struct option ' \
1052
exclude='const struct option|struct option const' \
1053
halt='add "const" to the above declarations' \
1054
$(_sc_search_regexp)
975
1057
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
1007
1089
# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
1008
1090
_makefile_at_at_check_exceptions ?=
1009
1091
sc_makefile_at_at_check:
1010
@perl -ne '/\@[A-Z_0-9]+\@/' \
1011
-e ' && !/([A-Z_0-9]+)\s+=.*\@\1\@$$/' \
1092
@perl -ne '/\@\w+\@/' \
1093
-e ' && !/(\w+)\s+=.*\@\1\@$$/' \
1012
1094
-e ''$(_makefile_at_at_check_exceptions) \
1013
1095
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
1014
1096
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \
1015
1097
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
1017
1099
news-check: NEWS
1018
if sed -n $(news-check-lines-spec)p $(srcdir)/NEWS \
1100
$(AM_V_GEN)if sed -n $(news-check-lines-spec)p $< \
1019
1101
| grep -E $(news-check-regexp) >/dev/null; then \
1071
1153
# Sometimes it is useful to change the PATH environment variable
1072
1154
# in Makefiles. When doing so, it's better not to use the Unix-centric
1073
# path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
1074
msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
1155
# path separator of ':', but rather the automake-provided '$(PATH_SEPARATOR)'.
1156
msg = 'Do not use ":" above; use $$(PATH_SEPARATOR) instead'
1075
1157
sc_makefile_path_separator_check:
1076
1158
@prohibit='PATH[=].*:' \
1077
1159
in_vc_files='akefile|\.mk$$' \
1079
1161
$(_sc_search_regexp)
1081
# Check that `make alpha' will not fail at the end of the process.
1163
# Check that 'make alpha' will not fail at the end of the process,
1164
# i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release)
1082
1166
writable-files:
1083
if test -d $(release_archive_dir); then :; else \
1084
for file in $(distdir).tar.gz \
1085
$(release_archive_dir)/$(distdir).tar.gz; do \
1086
test -e $$file || continue; \
1088
|| { echo ERROR: $$file is not writable; fail=1; }; \
1167
$(AM_V_GEN)if test -d $(release_archive_dir); then \
1168
for file in $(DIST_ARCHIVES); do \
1169
for p in ./ $(release_archive_dir)/; do \
1170
test -e $$p$$file || continue; \
1172
|| { echo ERROR: $$p$$file is not writable; fail=1; }; \
1090
1175
test "$$fail" && exit 1 || : ; \
1093
1179
v_etc_file = $(gnulib_dir)/lib/version-etc.c
1136
1222
1>&2; exit 1; } || :; \
1225
# BRE regex of file contents to identify a test script.
1226
_test_script_regex ?= \<init\.sh\>
1228
# In tests, use "compare expected actual", not the reverse.
1229
sc_prohibit_reversed_compare_failure:
1230
@prohibit='\<compare [^ ]+ ([^ ]*exp|/dev/null)' \
1231
containing='$(_test_script_regex)' \
1232
halt='reversed compare arguments' \
1233
$(_sc_search_regexp)
1139
1235
# #if HAVE_... will evaluate to false for any non numeric string.
1140
1236
# That would be flagged by using -Wundef, however gnulib currently
1141
1237
# tests many undefined macros, and so we can't enable that option.
1150
1246
# not be constant, or might overflow a stack. In general, use PATH_MAX as
1151
1247
# a limit, not an array or alloca size.
1152
1248
sc_prohibit_path_max_allocation:
1153
@prohibit='(\balloca *\([^)]*|\[[^]]*)PATH_MAX' \
1249
@prohibit='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \
1154
1250
halt='Avoid stack allocations of size PATH_MAX' \
1155
1251
$(_sc_search_regexp)
1157
1253
sc_vulnerable_makefile_CVE-2009-4029:
1158
1254
@prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
1159
in_files=$$(find $(srcdir) -name Makefile.in) \
1255
in_files='(^|/)Makefile\.in$$' \
1160
1256
halt=$$(printf '%s\n' \
1161
1257
'the above files are vulnerable; beware of running' \
1162
1258
' "make dist*" rules, and upgrade to fixed automake' \
1163
1259
' see http://bugzilla.redhat.com/542609 for details') \
1164
1260
$(_sc_search_regexp)
1262
sc_vulnerable_makefile_CVE-2012-3386:
1263
@prohibit='chmod a\+w \$$\(distdir\)' \
1264
in_files='(^|/)Makefile\.in$$' \
1265
halt=$$(printf '%s\n' \
1266
'the above files are vulnerable; beware of running' \
1267
' "make distcheck", and upgrade to fixed automake' \
1268
' see http://bugzilla.redhat.com/CVE-2012-3386 for details') \
1269
$(_sc_search_regexp)
1167
(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
1168
if test -s vc-diffs; then \
1272
$(AM_V_GEN)(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
1273
$(AM_V_at)if test -s vc-diffs; then \
1169
1274
cat vc-diffs; \
1170
1275
echo "Some files are locally modified:" 1>&2; \
1182
1287
# If it's not already specified, derive the GPG key ID from
1183
1288
# the signed tag we've just applied to mark this release.
1185
$$(git cat-file tag v$(VERSION) > .ann-sig \
1186
&& gpgv .ann-sig - < /dev/null 2>&1 \
1187
| sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig)
1291
&& git cat-file tag v$(VERSION) \
1292
| gpgv --status-fd 1 --keyring /dev/null - - 2>/dev/null \
1293
| awk '/^\[GNUPG:\] ERRSIG / {print $$3; exit}')
1189
1295
translation_project_ ?= coordinator@translationproject.org
1191
1297
# Make info-gnu the default only for a stable release.
1192
ifeq ($(RELEASE_TYPE),stable)
1193
announcement_Cc_ ?= $(translation_project_), $(PACKAGE_BUGREPORT)
1194
announcement_mail_headers_ ?= \
1195
To: info-gnu@gnu.org \
1196
Cc: $(announcement_Cc_) \
1197
Mail-Followup-To: $(PACKAGE_BUGREPORT)
1199
announcement_Cc_ ?= $(translation_project_)
1200
announcement_mail_headers_ ?= \
1201
To: $(PACKAGE_BUGREPORT) \
1202
Cc: $(announcement_Cc_)
1298
announcement_Cc_stable = $(translation_project_), $(PACKAGE_BUGREPORT)
1299
announcement_mail_headers_stable = \
1300
To: info-gnu@gnu.org \
1301
Cc: $(announcement_Cc_) \
1302
Mail-Followup-To: $(PACKAGE_BUGREPORT)
1304
announcement_Cc_alpha = $(translation_project_)
1305
announcement_mail_headers_alpha = \
1306
To: $(PACKAGE_BUGREPORT) \
1307
Cc: $(announcement_Cc_)
1309
announcement_mail_Cc_beta = $(announcement_mail_Cc_alpha)
1310
announcement_mail_headers_beta = $(announcement_mail_headers_alpha)
1312
announcement_mail_Cc_ ?= $(announcement_mail_Cc_$(release-type))
1313
announcement_mail_headers_ ?= $(announcement_mail_headers_$(release-type))
1205
1314
announcement: NEWS ChangeLog $(rel-files)
1206
@$(build_aux)/announce-gen \
1315
# Not $(AM_V_GEN) since the output of this command serves as
1316
# annoucement message: it would start with " GEN announcement".
1317
$(AM_V_at)$(srcdir)/$(_build-aux)/announce-gen \
1207
1318
--mail-headers='$(announcement_mail_headers_)' \
1208
--release-type=$(RELEASE_TYPE) \
1319
--release-type=$(release-type) \
1209
1320
--package=$(PACKAGE) \
1210
1321
--prev=$(PREV_VERSION) \
1211
1322
--curr=$(VERSION) \
1212
1323
--gpg-key-id=$(gpg_key_ID) \
1324
--srcdir=$(srcdir) \
1213
1325
--news=$(srcdir)/NEWS \
1214
1326
--bootstrap-tools=$(bootstrap-tools) \
1215
--gnulib-version=$(gnulib-version) \
1327
$$(case ,$(bootstrap-tools), in (*,gnulib,*) \
1328
echo --gnulib-version=$(gnulib-version);; esac) \
1216
1329
--no-print-checksums \
1217
1330
$(addprefix --url-dir=, $(url_dir_list))
1332
.PHONY: release-commit
1334
$(AM_V_GEN)cd $(srcdir) \
1335
&& $(_build-aux)/do-release-commit-and-tag \
1336
-C $(abs_builddir) $(RELEASE)
1219
1338
## ---------------- ##
1220
1339
## Updating files. ##
1221
1340
## ---------------- ##
1224
1343
www-gnu = http://www.gnu.org
1226
1345
upload_dest_dir_ ?= $(PACKAGE)
1347
$(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \
1348
--to $(gnu_rel_host):$(upload_dest_dir_) \
1227
1350
emit_upload_commands:
1228
1351
@echo =====================================
1229
1352
@echo =====================================
1230
@echo "$(build_aux)/gnupload $(GNUPLOADFLAGS) \\"
1231
@echo " --to $(gnu_rel_host):$(upload_dest_dir_) \\"
1232
@echo " $(rel-files)"
1353
@echo '$(upload_command)'
1233
1354
@echo '# send the ~/announce-$(my_distdir) e-mail'
1234
1355
@echo =====================================
1235
1356
@echo =====================================
1360
$(AM_V_GEN)$(upload_command)
1237
1362
define emit-commit-log
1238
printf '%s\n' 'post-release administrivia' '' \
1239
'* NEWS: Add header line for next release.' \
1240
'* .prev-version: Record previous version.' \
1363
printf '%s\n' 'maint: post-release administrivia' '' \
1364
'* NEWS: Add header line for next release.' \
1365
'* .prev-version: Record previous version.' \
1241
1366
'* cfg.mk (old_NEWS_hash): Auto-update.'
1244
1369
.PHONY: no-submodule-changes
1245
1370
no-submodule-changes:
1246
if test -d $(srcdir)/.git; then \
1371
$(AM_V_GEN)if test -d $(srcdir)/.git; then \
1247
1372
diff=$$(cd $(srcdir) && git submodule -q foreach \
1248
1373
git diff-index --name-only HEAD) \
1279
1404
gl_public_submodule_commit ?= public-submodule-commit
1280
1405
check: $(gl_public_submodule_commit)
1282
.PHONY: alpha beta stable
1407
.PHONY: alpha beta stable release
1283
1408
ALL_RECURSIVE_TARGETS += alpha beta stable
1284
1409
alpha beta stable: $(local-check) writable-files $(submodule-checks)
1410
$(AM_V_GEN)test $@ = stable \
1286
1411
&& { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
1287
1412
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
1289
$(MAKE) vc-diff-check
1292
$(MAKE) dist XZ_OPT=-9ev
1293
$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
1294
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
1414
$(AM_V_at)$(MAKE) vc-diff-check
1415
$(AM_V_at)$(MAKE) news-check
1416
$(AM_V_at)$(MAKE) distcheck
1417
$(AM_V_at)$(MAKE) dist
1418
$(AM_V_at)$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
1419
$(AM_V_at)$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
1422
$(AM_V_GEN)$(MAKE) $(release-type)
1296
1424
# Override this in cfg.mk if you follow different procedures.
1297
1425
release-prep-hook ?= release-prep
1299
1427
gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?]
1300
1428
.PHONY: release-prep
1302
case $$RELEASE_TYPE in alpha|beta|stable) ;; \
1303
*) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
1304
$(MAKE) --no-print-directory -s announcement > ~/announce-$(my_distdir)
1305
if test -d $(release_archive_dir); then \
1430
$(AM_V_GEN)$(MAKE) --no-print-directory -s announcement \
1431
> ~/announce-$(my_distdir)
1432
$(AM_V_at)if test -d $(release_archive_dir); then \
1306
1433
ln $(rel-files) $(release_archive_dir); \
1307
1434
chmod a-w $(rel-files); \
1309
echo $(VERSION) > $(prev_version_file)
1310
$(MAKE) update-NEWS-hash
1311
perl -pi -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' NEWS
1312
$(emit-commit-log) > .ci-msg
1313
$(VC) commit -F .ci-msg -a
1436
$(AM_V_at)echo $(VERSION) > $(prev_version_file)
1437
$(AM_V_at)$(MAKE) update-NEWS-hash
1438
$(AM_V_at)perl -pi \
1439
-e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' \
1441
$(AM_V_at)msg=$$($(emit-commit-log)) || exit 1; \
1442
cd $(srcdir) && $(VC) commit -m "$$msg" -a
1316
1444
# Override this with e.g., -s $(srcdir)/some_other_name.texi
1317
1445
# if the default $(PACKAGE)-derived name doesn't apply.
1320
1448
.PHONY: web-manual
1322
@test -z "$(manual_title)" \
1450
$(AM_V_GEN)test -z "$(manual_title)" \
1323
1451
&& { echo define manual_title in cfg.mk 1>&2; exit 1; } || :
1324
@cd '$(srcdir)/doc'; \
1325
$(SHELL) ../build-aux/gendocs.sh $(gendocs_options_) \
1452
$(AM_V_at)cd '$(srcdir)/doc'; \
1453
$(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \
1326
1454
-o '$(abs_builddir)/doc/manual' \
1327
1455
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \
1328
1456
"$(PACKAGE_NAME) - $(manual_title)"
1329
@echo " *** Upload the doc/manual directory to web-cvs."
1457
$(AM_V_at)echo " *** Upload the doc/manual directory to web-cvs."
1459
.PHONY: web-manual-update
1461
$(AM_V_GEN)cd $(srcdir) \
1462
&& $(_build-aux)/gnu-web-doc-update -C $(abs_builddir)
1331
1465
# Code Coverage
1353
1487
coverage: init-coverage build-coverage gen-coverage
1489
# Some projects carry local adjustments for gnulib modules via patches in
1490
# a gnulib patch directory whose default name is gl/ (defined in bootstrap
1491
# via local_gl_dir=gl). Those patches become stale as the originals evolve
1492
# in gnulib. Use this rule to refresh any stale patches. It applies each
1493
# patch to the original in $(gnulib_dir) and uses the temporary result to
1494
# generate a fuzz-free .diff file. If you customize the name of your local
1495
# gnulib patch directory via bootstrap.conf, this rule detects that name.
1496
# Run this from a non-VPATH (i.e., srcdir) build directory.
1497
.PHONY: refresh-gnulib-patches
1498
refresh-gnulib-patches:
1500
if test -f bootstrap.conf; then \
1501
t=$$(perl -lne '/^\s*local_gl_dir=(\S+)/ and $$d=$$1;' \
1502
-e 'END{defined $$d and print $$d}' bootstrap.conf); \
1503
test -n "$$t" && gl=$$t; \
1505
for diff in $$(cd $$gl; git ls-files | grep '\.diff$$'); do \
1506
b=$$(printf %s "$$diff"|sed 's/\.diff$$//'); \
1507
VERSION_CONTROL=none \
1508
patch "$(gnulib_dir)/$$b" "$$gl/$$diff" || exit 1; \
1509
( cd $(gnulib_dir) || exit 1; \
1510
git diff "$$b" > "../$$gl/$$diff"; \
1511
git checkout $$b ) || exit 1; \
1355
1514
# Update gettext files.
1356
1515
PACKAGE ?= $(shell basename $(PWD))
1357
1516
PO_DOMAIN ?= $(PACKAGE)
1363
1522
wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
1364
1523
echo 'en@boldquot' > $(PODIR)/LINGUAS && \
1365
1524
echo 'en@quot' >> $(PODIR)/LINGUAS && \
1366
ls $(PODIR)/*.po | sed 's/\.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
1525
ls $(PODIR)/*.po | sed 's/\.po//;s,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
1368
1527
# Running indent once is not idempotent, but running it twice is.
1369
1528
INDENT_SOURCES ?= $(C_SOURCES)
1385
1544
# in the file .x-update-copyright.
1386
1545
.PHONY: update-copyright
1387
1546
update-copyright:
1388
grep -l -w Copyright \
1547
$(AM_V_GEN)grep -l -w Copyright \
1389
1548
$$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \
1390
| $(update-copyright-env) xargs $(build_aux)/$@
1549
| $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@
1392
1551
# This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
1393
1552
# overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
1410
1570
-f $(abs_top_builddir)/$< \
1411
1571
_gl_tight_scope \
1416
1577
tight-scope.mk: $(ME)
1418
@perl -ne '/^# TS-start/.../^# TS-end/ and print' $(ME) > $@-t
1579
@perl -ne '/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME) > $@-t
1419
1580
@chmod a=r $@-t && mv $@-t $@
1424
1585
# Most functions should have static scope.
1425
# Any that don't must be marked with `extern', but `main'
1426
# and `usage' are exceptions: they're always extern, but
1427
# do not need to be marked. Symbols matching `__.*' are
1586
# Any that don't must be marked with 'extern', but 'main'
1587
# and 'usage' are exceptions: they're always extern, but
1588
# do not need to be marked. Symbols matching '__.*' are
1428
1589
# reserved by the compiler, so are automatically excluded below.
1429
1590
_gl_TS_unmarked_extern_functions ?= main usage
1430
1591
_gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\S+) *\(/
1434
1595
# export _gl_TS_extern = extern|XTERN
1435
1596
_gl_TS_extern ?= extern
1437
# The second nm|grep checks for file-scope variables with `extern' scope.
1598
# The second nm|grep checks for file-scope variables with 'extern' scope.
1438
1599
# Without gnulib's progname module, you might put program_name here.
1439
# Symbols matching `__.*' are reserved by the compiler,
1600
# Symbols matching '__.*' are reserved by the compiler,
1440
1601
# so are automatically excluded below.
1441
1602
_gl_TS_unmarked_extern_vars ?=
1478
1640
&& { echo the above functions should have static scope >&2; \
1479
1641
exit 1; } || : ; \
1480
1642
( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars); \
1481
perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' $$hdr *.h \
1643
perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' \
1644
$$hdr $(_gl_TS_other_headers) \
1482
1645
) | sort -u > $$t; \
1483
1646
nm -e $(_gl_TS_obj_files) | sed -n 's/.* [BCDGRS] //p' \
1484
1647
| sort -u | grep -Ev -f $$t \