| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
ME := maint.mk |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
AWK ?= awk |
| 28 |
GREP ?= grep |
| 29 |
SED ?= sed |
| 30 |
|
| 31 |
|
| 32 |
_empty = |
| 33 |
_sp = $(_empty) $(_empty) |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
_equal = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
member-check = \ |
| 45 |
$(strip \ |
| 46 |
$(if $($(1)), \ |
| 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))) |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
gzip_rsyncable := \ |
| 56 |
$(shell gzip --help 2>/dev/null|$(GREP) rsyncable >/dev/null \ |
| 57 |
&& printf %s --rsyncable) |
| 58 |
GZIP_ENV = '--no-name --best $(gzip_rsyncable)' |
| 59 |
|
| 60 |
GIT = git |
| 61 |
VC = $(GIT) |
| 62 |
|
| 63 |
VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir) |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
gnulib_dir ?= $(srcdir)/gnulib |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$ |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
_dot_escaped_srcdir = $(subst .,\.,$(srcdir)) |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
ifeq ($(srcdir),.) |
| 81 |
_prepend_srcdir_prefix = |
| 82 |
else |
| 83 |
_prepend_srcdir_prefix = | $(SED) 's|^|$(srcdir)/|' |
| 84 |
endif |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
_sc_excl = \ |
| 90 |
$(or $(exclude_file_name_regexp--$@),^$$) |
| 91 |
VC_LIST_EXCEPT = \ |
| 92 |
$(VC_LIST) | $(SED) 's|^$(_dot_escaped_srcdir)/||' \ |
| 93 |
| if test -f $(srcdir)/.x-$@; then $(GREP) -vEf $(srcdir)/.x-$@; \ |
| 94 |
else $(GREP) -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \ |
| 95 |
| $(GREP) -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \ |
| 96 |
$(_prepend_srcdir_prefix) |
| 97 |
|
| 98 |
ifeq ($(origin prev_version_file), undefined) |
| 99 |
prev_version_file = $(srcdir)/.prev-version |
| 100 |
endif |
| 101 |
|
| 102 |
PREV_VERSION := $(shell cat $(prev_version_file) 2>/dev/null) |
| 103 |
VERSION_REGEXP = $(subst .,\.,$(VERSION)) |
| 104 |
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION)) |
| 105 |
|
| 106 |
ifeq ($(VC),$(GIT)) |
| 107 |
this-vc-tag = v$(VERSION) |
| 108 |
this-vc-tag-regexp = v$(VERSION_REGEXP) |
| 109 |
else |
| 110 |
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]') |
| 111 |
tag-this-version = $(subst .,_,$(VERSION)) |
| 112 |
this-vc-tag = $(tag-package)-$(tag-this-version) |
| 113 |
this-vc-tag-regexp = $(this-vc-tag) |
| 114 |
endif |
| 115 |
my_distdir = $(PACKAGE)-$(VERSION) |
| 116 |
|
| 117 |
|
| 118 |
release_archive_dir ?= ../release |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
ifdef RELEASE |
| 123 |
VERSION := $(word 1, $(RELEASE)) |
| 124 |
RELEASE_TYPE ?= $(word 2, $(RELEASE)) |
| 125 |
endif |
| 126 |
|
| 127 |
|
| 128 |
RELEASE_TYPES = alpha beta stable |
| 129 |
release-type = $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES)) |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
gnu_ftp_host-alpha = alpha.gnu.org |
| 135 |
gnu_ftp_host-beta = alpha.gnu.org |
| 136 |
gnu_ftp_host-stable = ftp.gnu.org |
| 137 |
gnu_rel_host ?= $(gnu_ftp_host-$(release-type)) |
| 138 |
|
| 139 |
url_dir_list ?= $(if $(call _equal,$(gnu_rel_host),ftp.gnu.org), \ |
| 140 |
https://ftpmirror.gnu.org/$(PACKAGE), \ |
| 141 |
https://$(gnu_rel_host)/gnu/$(PACKAGE)) |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
today = $(shell date +%Y-%m-%d) |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
news-check-lines-spec ?= 1,10 |
| 152 |
news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)' |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
export LC_ALL = C |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
ifneq ($(_gl-Makefile),) |
| 163 |
_cfg_mk := $(wildcard $(srcdir)/cfg.mk) |
| 164 |
|
| 165 |
|
| 166 |
syntax-check-rules := $(sort $(shell $(SED) -n \ |
| 167 |
's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(srcdir)/$(ME) $(_cfg_mk))) |
| 168 |
.PHONY: $(syntax-check-rules) |
| 169 |
|
| 170 |
ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0) |
| 171 |
local-checks-available += $(syntax-check-rules) |
| 172 |
else |
| 173 |
local-checks-available += no-vc-detected |
| 174 |
no-vc-detected: |
| 175 |
@echo "No version control files detected; skipping syntax check" |
| 176 |
endif |
| 177 |
.PHONY: $(local-checks-available) |
| 178 |
|
| 179 |
|
| 180 |
$(syntax-check-rules): %: %.m |
| 181 |
sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules)) |
| 182 |
.PHONY: $(sc_m_rules_) |
| 183 |
$(sc_m_rules_): |
| 184 |
@echo $(patsubst sc_%.m, %, $@) |
| 185 |
@date +%s.%N > .sc-start-$(basename $@) |
| 186 |
|
| 187 |
|
| 188 |
sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules)) |
| 189 |
.PHONY: $(sc_z_rules_) |
| 190 |
$(sc_z_rules_): %.z: % |
| 191 |
@end=$$(date +%s.%N); \ |
| 192 |
start=$$(cat .sc-start-$*); \ |
| 193 |
rm -f .sc-start-$*; \ |
| 194 |
$(AWK) -v s=$$start -v e=$$end \ |
| 195 |
'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
local-check := \ |
| 200 |
$(patsubst sc_%, sc_%.z, \ |
| 201 |
$(filter-out $(local-checks-to-skip), $(local-checks-available))) |
| 202 |
|
| 203 |
syntax-check: $(local-check) |
| 204 |
endif |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
export require = |
| 263 |
export prohibit = |
| 264 |
export exclude = |
| 265 |
export in_vc_files = |
| 266 |
export in_files = |
| 267 |
export containing = |
| 268 |
export non_containing = |
| 269 |
export halt = |
| 270 |
export with_grep_options = |
| 271 |
|
| 272 |
|
| 273 |
export ignore_case = |
| 274 |
_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :) |
| 275 |
|
| 276 |
define _sc_say_and_exit |
| 277 |
dummy=; : so we do not need a semicolon before each use; \ |
| 278 |
{ printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; }; |
| 279 |
endef |
| 280 |
|
| 281 |
define _sc_search_regexp |
| 282 |
dummy=; : so we do not need a semicolon before each use; \ |
| 283 |
\ |
| 284 |
: Check arguments; \ |
| 285 |
test -n "$$prohibit" && test -n "$$require" \ |
| 286 |
&& { msg='Cannot specify both prohibit and require' \ |
| 287 |
$(_sc_say_and_exit) } || :; \ |
| 288 |
test -z "$$prohibit" && test -z "$$require" \ |
| 289 |
&& { msg='Should specify either prohibit or require' \ |
| 290 |
$(_sc_say_and_exit) } || :; \ |
| 291 |
test -z "$$prohibit" && test -n "$$exclude" \ |
| 292 |
&& { msg='Use of exclude requires a prohibit pattern' \ |
| 293 |
$(_sc_say_and_exit) } || :; \ |
| 294 |
test -n "$$in_vc_files" && test -n "$$in_files" \ |
| 295 |
&& { msg='Cannot specify both in_vc_files and in_files' \ |
| 296 |
$(_sc_say_and_exit) } || :; \ |
| 297 |
test "x$$halt" != x \ |
| 298 |
|| { msg='halt not defined' $(_sc_say_and_exit) }; \ |
| 299 |
\ |
| 300 |
: Filter by file name; \ |
| 301 |
if test -n "$$in_files"; then \ |
| 302 |
files=$$(find $(srcdir) | $(GREP) -E "$$in_files" \ |
| 303 |
| $(GREP) -Ev '$(_sc_excl)'); \ |
| 304 |
else \ |
| 305 |
files=$$($(VC_LIST_EXCEPT)); \ |
| 306 |
if test -n "$$in_vc_files"; then \ |
| 307 |
files=$$(echo "$$files" | $(GREP) -E "$$in_vc_files"); \ |
| 308 |
fi; \ |
| 309 |
fi; \ |
| 310 |
\ |
| 311 |
: Filter by content; \ |
| 312 |
test -n "$$files" \ |
| 313 |
&& test -n "$$containing" \ |
| 314 |
&& { files=$$(echo "$$files" | xargs $(GREP) -l "$$containing"); } \ |
| 315 |
|| :; \ |
| 316 |
test -n "$$files" \ |
| 317 |
&& test -n "$$non_containing" \ |
| 318 |
&& { files=$$(echo "$$files" | xargs $(GREP) -vl "$$non_containing"); } \ |
| 319 |
|| :; \ |
| 320 |
\ |
| 321 |
: Check for the construct; \ |
| 322 |
if test -n "$$files"; then \ |
| 323 |
if test -n "$$prohibit"; then \ |
| 324 |
echo "$$files" \ |
| 325 |
| xargs $(GREP) $$with_grep_options $(_ignore_case) -nE \ |
| 326 |
"$$prohibit" /dev/null \ |
| 327 |
| $(GREP) -vE "$${exclude:-^$$}" \ |
| 328 |
&& { msg="$$halt" $(_sc_say_and_exit) } \ |
| 329 |
|| :; \ |
| 330 |
else \ |
| 331 |
echo "$$files" \ |
| 332 |
| xargs \ |
| 333 |
$(GREP) $$with_grep_options $(_ignore_case) -LE "$$require" \ |
| 334 |
| $(GREP) . \ |
| 335 |
&& { msg="$$halt" $(_sc_say_and_exit) } \ |
| 336 |
|| :; \ |
| 337 |
fi \ |
| 338 |
else :; \ |
| 339 |
fi || :; |
| 340 |
endef |
| 341 |
|
| 342 |
sc_avoid_if_before_free: |
| 343 |
@$(VC_LIST_EXCEPT) \ |
| 344 |
| $(GREP) -v useless-if-before-free \ |
| 345 |
| xargs \ |
| 346 |
$(srcdir)/$(_build-aux)/useless-if-before-free \ |
| 347 |
$(useless_free_options) \ |
| 348 |
&& { printf '$(ME): found useless "if"' \ |
| 349 |
' before "free" above\n' 1>&2; \ |
| 350 |
exit 1; } \ |
| 351 |
|| : |
| 352 |
|
| 353 |
sc_cast_of_argument_to_free: |
| 354 |
@prohibit='\<free *\( *\(' halt="don't cast free argument" \ |
| 355 |
$(_sc_search_regexp) |
| 356 |
|
| 357 |
sc_cast_of_x_alloc_return_value: |
| 358 |
@prohibit='\*\) *x(m|c|re)alloc\>' \ |
| 359 |
halt="don't cast x*alloc return value" \ |
| 360 |
$(_sc_search_regexp) |
| 361 |
|
| 362 |
sc_cast_of_alloca_return_value: |
| 363 |
@prohibit='\*\) *alloca\>' \ |
| 364 |
halt="don't cast alloca return value" \ |
| 365 |
$(_sc_search_regexp) |
| 366 |
|
| 367 |
sc_space_tab: |
| 368 |
@prohibit='[ ] ' \ |
| 369 |
halt='found SPACE-TAB sequence; remove the SPACE' \ |
| 370 |
$(_sc_search_regexp) |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
sc_prohibit_atoi_atof: |
| 376 |
@prohibit='\<([fs]?scanf|ato([filq]|ll)) *\(' \ |
| 377 |
halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \ |
| 378 |
$(_sc_search_regexp) |
| 379 |
|
| 380 |
|
| 381 |
sp_ = strcmp *\(.+\) |
| 382 |
sc_prohibit_strcmp: |
| 383 |
@prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \ |
| 384 |
exclude='# *define STRN?EQ\(' \ |
| 385 |
halt='replace strcmp calls above with STREQ/STRNEQ' \ |
| 386 |
$(_sc_search_regexp) |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
sc_prohibit_strncpy: |
| 392 |
@prohibit='\<strncpy *\(' \ |
| 393 |
halt='do not use strncpy, period' \ |
| 394 |
$(_sc_search_regexp) |
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
sc_prohibit_magic_number_exit: |
| 407 |
@prohibit='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]' \ |
| 408 |
exclude='exit \(77\)|error ?\(((0|77),|[^,]*)' \ |
| 409 |
halt='use EXIT_* values rather than magic number' \ |
| 410 |
$(_sc_search_regexp) |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
sc_prohibit_gnu_make_extensions_awk_ = \ |
| 424 |
BEGIN { \ |
| 425 |
RS = "\n\n"; \ |
| 426 |
in_rules = 0; \ |
| 427 |
} \ |
| 428 |
/^\# Files/ { \ |
| 429 |
in_rules = 1; \ |
| 430 |
} \ |
| 431 |
/\$$</ && in_rules && $$0 !~ /^(.*\n)*\.\w+(\.\w+)?:/ { \ |
| 432 |
print "Error: " file ": $$< in a non implicit rule\n" $$0; \ |
| 433 |
status = 1; \ |
| 434 |
} \ |
| 435 |
END { \ |
| 436 |
exit status; \ |
| 437 |
} |
| 438 |
sc_prohibit_gnu_make_extensions: |
| 439 |
@if $(AWK) --version | grep GNU >/dev/null 2>&1; then \ |
| 440 |
(cd $(srcdir) && autoconf --trace AC_CONFIG_FILES:'$$1') | \ |
| 441 |
tr ' ' '\n' | \ |
| 442 |
$(SED) -ne '/Makefile/{s/\.in$$//;p;}' | \ |
| 443 |
while read m; do \ |
| 444 |
$(MAKE) -qp -f $$m .DUMMY-TARGET 2>/dev/null | \ |
| 445 |
$(AWK) -v file=$$m -e '$($@_awk_)' || exit 1; \ |
| 446 |
done; \ |
| 447 |
fi |
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
sc_error_exit_success: |
| 452 |
@prohibit='error *\(EXIT_SUCCESS,' \ |
| 453 |
in_vc_files='\.[chly]$$' \ |
| 454 |
halt='found error (EXIT_SUCCESS' \ |
| 455 |
$(_sc_search_regexp) |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
sc_error_message_warn_fatal: |
| 460 |
@$(VC_LIST_EXCEPT) \ |
| 461 |
| xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ |
| 462 |
| $(GREP) -E '"Warning|"Fatal|"fatal' \ |
| 463 |
&& { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \ |
| 464 |
exit 1; } \ |
| 465 |
|| : |
| 466 |
|
| 467 |
|
| 468 |
sc_error_message_uppercase: |
| 469 |
@$(VC_LIST_EXCEPT) \ |
| 470 |
| xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ |
| 471 |
| $(GREP) -E '"[A-Z]' \ |
| 472 |
| $(GREP) -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' \ |
| 473 |
&& { echo '$(ME): found capitalized error message' 1>&2; \ |
| 474 |
exit 1; } \ |
| 475 |
|| : |
| 476 |
|
| 477 |
|
| 478 |
sc_error_message_period: |
| 479 |
@$(VC_LIST_EXCEPT) \ |
| 480 |
| xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ |
| 481 |
| $(GREP) -E '[^."]\."' \ |
| 482 |
&& { echo '$(ME): found error message ending in period' 1>&2; \ |
| 483 |
exit 1; } \ |
| 484 |
|| : |
| 485 |
|
| 486 |
sc_file_system: |
| 487 |
@prohibit=file''system \ |
| 488 |
exclude='/proc/filesystems' \ |
| 489 |
ignore_case=1 \ |
| 490 |
halt='found use of "file''system"; spell it "file system"' \ |
| 491 |
$(_sc_search_regexp) |
| 492 |
|
| 493 |
|
| 494 |
sc_prohibit_have_config_h: |
| 495 |
@prohibit='^# *if.*HAVE''_CONFIG_H' \ |
| 496 |
halt='found use of HAVE''_CONFIG_H; remove' \ |
| 497 |
$(_sc_search_regexp) |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
config_h_header ?= <config\.h> |
| 503 |
sc_require_config_h: |
| 504 |
@require='^# *include $(config_h_header)' \ |
| 505 |
in_vc_files='\.c$$' \ |
| 506 |
halt='the above files do not include <config.h>' \ |
| 507 |
$(_sc_search_regexp) |
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
perl_config_h_first_ = \ |
| 512 |
-e 'BEGIN {$$ret = 0}' \ |
| 513 |
-e 'if (/^\# *include\b/) {' \ |
| 514 |
-e ' if (not m{^\# *include $(config_h_header)}) {' \ |
| 515 |
-e ' print "$$ARGV\n";' \ |
| 516 |
-e ' $$ret = 1;' \ |
| 517 |
-e ' }' \ |
| 518 |
-e ' \# Move on to next file after first include' \ |
| 519 |
-e ' close ARGV;' \ |
| 520 |
-e '}' \ |
| 521 |
-e 'END {exit $$ret}' |
| 522 |
|
| 523 |
# You must include <config.h> before including any other header file. |
| 524 |
# This can possibly be via a package-specific header, if given by cfg.mk. |
| 525 |
sc_require_config_h_first: |
| 526 |
@if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ |
| 527 |
files=$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \ |
| 528 |
perl -n $(perl_config_h_first_) $$files || \ |
| 529 |
{ echo '$(ME): the above files include some other header' \ |
| 530 |
'before <config.h>' 1>&2; exit 1; } || :; \ |
| 531 |
else :; \ |
| 532 |
fi |
| 533 |
|
| 534 |
sc_prohibit_HAVE_MBRTOWC: |
| 535 |
@prohibit='\bHAVE_MBRTOWC\b' \ |
| 536 |
halt="do not use $$prohibit; it is always defined" \ |
| 537 |
$(_sc_search_regexp) |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
define _sc_header_without_use |
| 543 |
dummy=; : so we do not need a semicolon before each use; \ |
| 544 |
h_esc=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \ |
| 545 |
if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ |
| 546 |
files=$$($(GREP) -l '^# *include '"$$h_esc" \ |
| 547 |
$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$')) && \ |
| 548 |
$(GREP) -LE "$$re" $$files | $(GREP) . && \ |
| 549 |
{ echo "$(ME): the above files include $$h but don't use it" \ |
| 550 |
1>&2; exit 1; } || :; \ |
| 551 |
else :; \ |
| 552 |
fi |
| 553 |
endef |
| 554 |
|
| 555 |
# Prohibit the inclusion of assert.h without an actual use of assert. |
| 556 |
sc_prohibit_assert_without_use: |
| 557 |
@h='assert.h' re='\<assert *\(' $(_sc_header_without_use) |
| 558 |
|
| 559 |
|
| 560 |
sc_prohibit_close_stream_without_use: |
| 561 |
@h='close-stream.h' re='\<close_stream *\(' $(_sc_header_without_use) |
| 562 |
|
| 563 |
|
| 564 |
sc_prohibit_getopt_without_use: |
| 565 |
@h='getopt.h' re='\<getopt(_long)? *\(' $(_sc_header_without_use) |
| 566 |
|
| 567 |
|
| 568 |
sc_prohibit_quotearg_without_use: |
| 569 |
@h='quotearg.h' re='\<quotearg(_[^ ]+)? *\(' $(_sc_header_without_use) |
| 570 |
|
| 571 |
|
| 572 |
sc_prohibit_quote_without_use: |
| 573 |
@h='quote.h' re='\<quote((_n)? *\(|_quoting_options\>)' \ |
| 574 |
$(_sc_header_without_use) |
| 575 |
|
| 576 |
|
| 577 |
sc_prohibit_long_options_without_use: |
| 578 |
@h='long-options.h' re='\<parse_(long_options|gnu_standard_options_only) *\(' \ |
| 579 |
$(_sc_header_without_use) |
| 580 |
|
| 581 |
|
| 582 |
sc_prohibit_inttostr_without_use: |
| 583 |
@h='inttostr.h' re='\<(off|[iu]max|uint)tostr *\(' \ |
| 584 |
$(_sc_header_without_use) |
| 585 |
|
| 586 |
|
| 587 |
sc_prohibit_ignore_value_without_use: |
| 588 |
@h='ignore-value.h' re='\<ignore_(value|ptr) *\(' \ |
| 589 |
$(_sc_header_without_use) |
| 590 |
|
| 591 |
|
| 592 |
sc_prohibit_error_without_use: |
| 593 |
@h='error.h' \ |
| 594 |
re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\ |
| 595 |
$(_sc_header_without_use) |
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
_xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup) |
| 614 |
_xa2 = X([CZ]|N?M)ALLOC |
| 615 |
sc_prohibit_xalloc_without_use: |
| 616 |
@h='xalloc.h' \ |
| 617 |
re='\<($(_xa1)|$(_xa2)) *\('\ |
| 618 |
$(_sc_header_without_use) |
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
_hash_re = \ |
| 623 |
clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning |
| 624 |
_hash_fn = \<($(_hash_re)) *\( |
| 625 |
_hash_struct = (struct )?\<[Hh]ash_(table|tuning)\> |
| 626 |
sc_prohibit_hash_without_use: |
| 627 |
@h='hash.h' \ |
| 628 |
re='$(_hash_fn)|$(_hash_struct)'\ |
| 629 |
$(_sc_header_without_use) |
| 630 |
|
| 631 |
sc_prohibit_cloexec_without_use: |
| 632 |
@h='cloexec.h' re='\<(set_cloexec_flag|dup_cloexec) *\(' \ |
| 633 |
$(_sc_header_without_use) |
| 634 |
|
| 635 |
sc_prohibit_posixver_without_use: |
| 636 |
@h='posixver.h' re='\<posix2_version *\(' $(_sc_header_without_use) |
| 637 |
|
| 638 |
sc_prohibit_same_without_use: |
| 639 |
@h='same.h' re='\<same_name(at)? *\(' $(_sc_header_without_use) |
| 640 |
|
| 641 |
sc_prohibit_hash_pjw_without_use: |
| 642 |
@h='hash-pjw.h' \ |
| 643 |
re='\<hash_pjw\>' \ |
| 644 |
$(_sc_header_without_use) |
| 645 |
|
| 646 |
sc_prohibit_safe_read_without_use: |
| 647 |
@h='safe-read.h' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \ |
| 648 |
$(_sc_header_without_use) |
| 649 |
|
| 650 |
sc_prohibit_argmatch_without_use: |
| 651 |
@h='argmatch.h' \ |
| 652 |
re='(\<(ARGMATCH_DEFINE_GROUP|ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \ |
| 653 |
$(_sc_header_without_use) |
| 654 |
|
| 655 |
sc_prohibit_canonicalize_without_use: |
| 656 |
@h='canonicalize.h' \ |
| 657 |
re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode|file_name)' \ |
| 658 |
$(_sc_header_without_use) |
| 659 |
|
| 660 |
sc_prohibit_root_dev_ino_without_use: |
| 661 |
@h='root-dev-ino.h' \ |
| 662 |
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \ |
| 663 |
$(_sc_header_without_use) |
| 664 |
|
| 665 |
sc_prohibit_openat_without_use: |
| 666 |
@h='openat.h' \ |
| 667 |
re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat|(FCHMOD|FCHOWN|STAT)AT_INLINE)\>' \ |
| 668 |
$(_sc_header_without_use) |
| 669 |
|
| 670 |
|
| 671 |
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\ |
| 672 |
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper |
| 673 |
sc_prohibit_c_ctype_without_use: |
| 674 |
@h='c-ctype.h' re='\<c_($(ctype_re)) *\(' \ |
| 675 |
$(_sc_header_without_use) |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
_sig_functions = \ |
| 681 |
bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \ |
| 682 |
sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \ |
| 683 |
siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \ |
| 684 |
sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo |
| 685 |
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions))) |
| 686 |
|
| 687 |
_sig_types_and_consts = \ |
| 688 |
MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \ |
| 689 |
SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \ |
| 690 |
SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \ |
| 691 |
SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \ |
| 692 |
sigstack sigval stack_t ucontext_t |
| 693 |
|
| 694 |
|
| 695 |
_sig_names = \ |
| 696 |
SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \ |
| 697 |
SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \ |
| 698 |
SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \ |
| 699 |
SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \ |
| 700 |
SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \ |
| 701 |
SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \ |
| 702 |
SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \ |
| 703 |
SIGXCPU SIGXFSZ |
| 704 |
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts))) |
| 705 |
|
| 706 |
|
| 707 |
sc_prohibit_signal_without_use: |
| 708 |
@h='signal.h' \ |
| 709 |
re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \ |
| 710 |
$(_sc_header_without_use) |
| 711 |
|
| 712 |
|
| 713 |
sc_prohibit_stdio--_without_use: |
| 714 |
@h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\(' \ |
| 715 |
$(_sc_header_without_use) |
| 716 |
|
| 717 |
|
| 718 |
sc_prohibit_stdio-safer_without_use: |
| 719 |
@h='stdio-safer.h' re='\<((f(re)?|p)open|tmpfile)_safer *\(' \ |
| 720 |
$(_sc_header_without_use) |
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
sc_prohibit_strings_without_use: |
| 725 |
@h='strings.h' \ |
| 726 |
re='\<(strn?casecmp|ffs(ll)?)\>' \ |
| 727 |
$(_sc_header_without_use) |
| 728 |
|
| 729 |
|
| 730 |
gl_extract_define_simple = \ |
| 731 |
/^\# *define ([A-Z]\w+)\(/ and print $$1 |
| 732 |
|
| 733 |
_intprops_names = \ |
| 734 |
$(shell f=$(gnulib_dir)/lib/intprops.h; \ |
| 735 |
perl -lne '$(gl_extract_define_simple)' $$f | sort -u | tr '\n' ' ') |
| 736 |
|
| 737 |
_intprops_syms_re = $(subst $(_sp),|,$(strip $(_intprops_names))) |
| 738 |
|
| 739 |
sc_prohibit_intprops_without_use: |
| 740 |
@h='intprops.h' \ |
| 741 |
re='\<($(_intprops_syms_re)) *\(' \ |
| 742 |
$(_sc_header_without_use) |
| 743 |
|
| 744 |
_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t |
| 745 |
|
| 746 |
sc_prohibit_stddef_without_use: |
| 747 |
@h='stddef.h' \ |
| 748 |
re='\<($(_stddef_syms_re))\>' \ |
| 749 |
$(_sc_header_without_use) |
| 750 |
|
| 751 |
_de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)? |
| 752 |
_de2 = (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(64)? |
| 753 |
_de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen |
| 754 |
_dirent_syms_re = $(_de1)|$(_de2)|$(_de3) |
| 755 |
|
| 756 |
sc_prohibit_dirent_without_use: |
| 757 |
@h='dirent.h' \ |
| 758 |
re='\<($(_dirent_syms_re))\>' \ |
| 759 |
$(_sc_header_without_use) |
| 760 |
|
| 761 |
|
| 762 |
sc_prohibit_verify_without_use: |
| 763 |
@h='verify.h' \ |
| 764 |
re='\<(verify(true|expr)?|assume|static_assert) *\(' \ |
| 765 |
$(_sc_header_without_use) |
| 766 |
|
| 767 |
|
| 768 |
sc_prohibit_xfreopen_without_use: |
| 769 |
@h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use) |
| 770 |
|
| 771 |
sc_obsolete_symbols: |
| 772 |
@prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ |
| 773 |
halt='do not use HAVE''_FCNTL_H or O'_NDELAY \ |
| 774 |
$(_sc_search_regexp) |
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
sc_changelog: |
| 780 |
@prohibit='^[^12 ]' \ |
| 781 |
in_vc_files='^ChangeLog$$' \ |
| 782 |
halt='found unexpected prefix in a ChangeLog' \ |
| 783 |
$(_sc_search_regexp) |
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
sc_bindtextdomain: |
| 788 |
@require='bindtextdomain *\(' \ |
| 789 |
in_vc_files='\.c$$' \ |
| 790 |
containing='\<main *(' \ |
| 791 |
halt='the above files do not call bindtextdomain' \ |
| 792 |
$(_sc_search_regexp) |
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
Exit_witness_file ?= tests/test-lib.sh |
| 798 |
Exit_base := $(notdir $(Exit_witness_file)) |
| 799 |
sc_require_test_exit_idiom: |
| 800 |
@if test -f $(srcdir)/$(Exit_witness_file); then \ |
| 801 |
die=0; \ |
| 802 |
for i in $$($(GREP) -l -F 'srcdir/$(Exit_base)' \ |
| 803 |
$$($(VC_LIST) tests)); do \ |
| 804 |
tail -n1 $$i | $(GREP) '^Exit .' > /dev/null \ |
| 805 |
&& : || { die=1; echo $$i; } \ |
| 806 |
done; \ |
| 807 |
test $$die = 1 && \ |
| 808 |
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \ |
| 809 |
echo 1>&2 'Exit something'; \ |
| 810 |
exit 1; } || :; \ |
| 811 |
fi |
| 812 |
|
| 813 |
sc_trailing_blank: |
| 814 |
@prohibit='[ ]$$' \ |
| 815 |
halt='found trailing blank(s)' \ |
| 816 |
exclude='^Binary file .* matches$$' \ |
| 817 |
$(_sc_search_regexp) |
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)? |
| 823 |
sc_two_space_separator_in_usage: |
| 824 |
@prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ |
| 825 |
halt='help2man requires at least two spaces between an option and its description'\ |
| 826 |
$(_sc_search_regexp) |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
_gl_translatable_diag_func_re ?= error |
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
sc_unmarked_diagnostics: |
| 835 |
@prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \ |
| 836 |
exclude='(_|ngettext ?)\(' \ |
| 837 |
halt='found unmarked diagnostic(s)' \ |
| 838 |
$(_sc_search_regexp) |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
sc_useless_cpp_parens: |
| 843 |
@prohibit='^# *if .*defined *\(' \ |
| 844 |
halt='found useless parentheses in cpp directive' \ |
| 845 |
$(_sc_search_regexp) |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
gl_assured_headers_ = \ |
| 852 |
cd $(gnulib_dir)/lib && echo *.in.h|$(SED) 's/\.in\.h//g' |
| 853 |
|
| 854 |
|
| 855 |
az_ = abcdefghijklmnopqrstuvwxyz |
| 856 |
AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ |
| 857 |
gl_header_upper_case_or_ = \ |
| 858 |
$$($(gl_assured_headers_) \ |
| 859 |
| tr $(az_)/.- $(AZ_)___ \ |
| 860 |
| tr -s ' ' '|' \ |
| 861 |
) |
| 862 |
sc_prohibit_always_true_header_tests: |
| 863 |
@or=$(gl_header_upper_case_or_); \ |
| 864 |
re="HAVE_($$or)_H"; \ |
| 865 |
prohibit='\<'"$$re"'\>' \ |
| 866 |
halt=$$(printf '%s\n' \ |
| 867 |
'do not test the above HAVE_<header>_H symbol(s);' \ |
| 868 |
' with the corresponding gnulib module, they are always true') \ |
| 869 |
$(_sc_search_regexp) |
| 870 |
|
| 871 |
sc_prohibit_defined_have_decl_tests: |
| 872 |
@prohibit='(#[ ]*ifn?def|\<defined)\>[ (]+HAVE_DECL_' \ |
| 873 |
halt='HAVE_DECL macros are always defined' \ |
| 874 |
$(_sc_search_regexp) |
| 875 |
|
| 876 |
|
| 877 |
gl_other_headers_ ?= \ |
| 878 |
intprops.h \ |
| 879 |
openat.h \ |
| 880 |
stat-macros.h |
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
gl_extract_significant_defines_ = \ |
| 887 |
/^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\ |
| 888 |
&& $$2 !~ /(?:rpl_|_used_without_)/\ |
| 889 |
&& $$1 !~ /^(?:NSIG|ENODATA)$$/\ |
| 890 |
&& $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\ |
| 891 |
and print $$1 |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
define def_sym_regex |
| 896 |
gen_h=$(gl_generated_headers_); \ |
| 897 |
(cd $(gnulib_dir)/lib; \ |
| 898 |
for f in *.in.h $(gl_other_headers_); do \ |
| 899 |
test -f $$f \ |
| 900 |
&& perl -lne '$(gl_extract_significant_defines_)' $$f; \ |
| 901 |
done; \ |
| 902 |
) | sort -u \ |
| 903 |
| $(SED) 's/^/^ *# *(define|undef) */;s/$$/\\>/' |
| 904 |
endef |
| 905 |
|
| 906 |
|
| 907 |
sc_prohibit_always-defined_macros: |
| 908 |
@if test -d $(gnulib_dir); then \ |
| 909 |
case $$(echo all: | $(GREP) -l -f - Makefile) in Makefile);; *) \ |
| 910 |
echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \ |
| 911 |
esac; \ |
| 912 |
regex=$$($(def_sym_regex)); export regex; \ |
| 913 |
$(VC_LIST_EXCEPT) \ |
| 914 |
| xargs sh -c 'echo $$regex | $(GREP) -E -f - "$$@"' \ |
| 915 |
dummy /dev/null \ |
| 916 |
&& { printf '$(ME): define the above' \ |
| 917 |
' via some gnulib .h file\n' 1>&2; \ |
| 918 |
exit 1; } \ |
| 919 |
|| :; \ |
| 920 |
fi |
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
sc_prohibit_backup_files: |
| 925 |
@$(VC_LIST) | $(GREP) '~$$' && \ |
| 926 |
{ echo '$(ME): found version controlled backup file' 1>&2; \ |
| 927 |
exit 1; } || : |
| 928 |
|
| 929 |
|
| 930 |
sc_GPL_version: |
| 931 |
@prohibit='either ''version [^3]' \ |
| 932 |
halt='GPL vN, N!=3' \ |
| 933 |
$(_sc_search_regexp) |
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any) |
| 938 |
sc_GFDL_version: |
| 939 |
@prohibit='$(_GFDL_regexp)' \ |
| 940 |
halt='GFDL vN, N!=3' \ |
| 941 |
$(_sc_search_regexp) |
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$ |
| 946 |
sc_texinfo_acronym: |
| 947 |
@prohibit='@acronym\{' \ |
| 948 |
in_vc_files='$(texinfo_suffix_re_)' \ |
| 949 |
halt='found use of Texinfo @acronym{}' \ |
| 950 |
$(_sc_search_regexp) |
| 951 |
|
| 952 |
cvs_keywords = \ |
| 953 |
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State |
| 954 |
|
| 955 |
sc_prohibit_cvs_keyword: |
| 956 |
@prohibit='\$$($(cvs_keywords))\$$' \ |
| 957 |
halt='do not use CVS keyword expansion' \ |
| 958 |
$(_sc_search_regexp) |
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
require_exactly_one_NL_at_EOF_ = \ |
| 984 |
foreach my $$f (@ARGV) \ |
| 985 |
{ \ |
| 986 |
open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \ |
| 987 |
my $$p = sysseek (F, -2, 2); \ |
| 988 |
my $$c = "seek failure probably means file has < 2 bytes; ignore"; \ |
| 989 |
my $$last_two_bytes; \ |
| 990 |
defined $$p and $$p = sysread F, $$last_two_bytes, 2; \ |
| 991 |
close F; \ |
| 992 |
$$c = "ignore read failure"; \ |
| 993 |
$$p && ($$last_two_bytes eq "\n\n" \ |
| 994 |
|| substr ($$last_two_bytes,1) ne "\n") \ |
| 995 |
and (print $$f), $$fail=1; \ |
| 996 |
} \ |
| 997 |
END { exit defined $$fail } |
| 998 |
sc_prohibit_empty_lines_at_EOF: |
| 999 |
@$(VC_LIST_EXCEPT) \ |
| 1000 |
| xargs perl -le '$(require_exactly_one_NL_at_EOF_)' \ |
| 1001 |
|| { echo '$(ME): empty line(s) or no newline at EOF' 1>&2; \ |
| 1002 |
exit 1; } \ |
| 1003 |
|| : |
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
sc_prohibit_stat_st_blocks: |
| 1009 |
@prohibit='[.>]st_blocks' \ |
| 1010 |
halt='do not use st_blocks; use ST_NBLOCKS' \ |
| 1011 |
$(_sc_search_regexp) |
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
sc_prohibit_S_IS_definition: |
| 1016 |
@prohibit='^ *# *define *S_IS' \ |
| 1017 |
halt='do not define S_IS* macros; include <sys/stat.h>' \ |
| 1018 |
$(_sc_search_regexp) |
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
perl_filename_lineno_text_ = \ |
| 1023 |
-e ' {' \ |
| 1024 |
-e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \ |
| 1025 |
-e ' ($$v = $$&) =~ s/\n/\\n/g;' \ |
| 1026 |
-e ' print "$$ARGV:$$n:$$v\n";' \ |
| 1027 |
-e ' }' |
| 1028 |
|
| 1029 |
prohibit_doubled_words_ = \ |
| 1030 |
the then in an on if is it but for or at and do to |
| 1031 |
# expand the regex before running the check to avoid using expensive captures |
| 1032 |
prohibit_doubled_word_expanded_ = \ |
| 1033 |
$(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_words_))) |
| 1034 |
prohibit_doubled_word_RE_ ?= \ |
| 1035 |
/\b(?:$(subst $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims |
| 1036 |
prohibit_doubled_word_ = \ |
| 1037 |
-e 'while ($(prohibit_doubled_word_RE_))' \ |
| 1038 |
$(perl_filename_lineno_text_) |
| 1039 |
|
| 1040 |
# Define this to a regular expression that matches |
| 1041 |
# any filename:dd:match lines you want to ignore. |
| 1042 |
# The default is to ignore no matches. |
| 1043 |
ignore_doubled_word_match_RE_ ?= ^$$ |
| 1044 |
|
| 1045 |
sc_prohibit_doubled_word: |
| 1046 |
@$(VC_LIST_EXCEPT) \ |
| 1047 |
| xargs perl -n -0777 $(prohibit_doubled_word_) \ |
| 1048 |
| $(GREP) -vE '$(ignore_doubled_word_match_RE_)' \ |
| 1049 |
| $(GREP) . \ |
| 1050 |
&& { echo '$(ME): doubled words' 1>&2; exit 1; } \ |
| 1051 |
|| : |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
bad_xref_re_ ?= (?:[\w,:;] +|(?:see|also)\s+)\@xref\{ |
| 1063 |
bad_pxref_re_ ?= (?:[.!?]|(?:see|also))\s+\@pxref\{ |
| 1064 |
prohibit_undesirable_word_seq_RE_ ?= \ |
| 1065 |
/(?:\bcan\s+not\b|\btime\s+stamps?\b|$(bad_xref_re_)|$(bad_pxref_re_))/gims |
| 1066 |
prohibit_undesirable_word_seq_ = \ |
| 1067 |
-e 'while ($(prohibit_undesirable_word_seq_RE_))' \ |
| 1068 |
$(perl_filename_lineno_text_) |
| 1069 |
# Define this to a regular expression that matches |
| 1070 |
# any filename:dd:match lines you want to ignore. |
| 1071 |
# The default is to ignore no matches. |
| 1072 |
ignore_undesirable_word_sequence_RE_ ?= ^$$ |
| 1073 |
|
| 1074 |
sc_prohibit_undesirable_word_seq: |
| 1075 |
@$(VC_LIST_EXCEPT) \ |
| 1076 |
| xargs perl -n -0777 $(prohibit_undesirable_word_seq_) \ |
| 1077 |
| $(GREP) -vE '$(ignore_undesirable_word_sequence_RE_)' \ |
| 1078 |
| $(GREP) . \ |
| 1079 |
&& { echo '$(ME): undesirable word sequence' >&2; exit 1; } \ |
| 1080 |
|| : |
| 1081 |
|
| 1082 |
# Except for shell files and for loops, double semicolon is probably a mistake |
| 1083 |
sc_prohibit_double_semicolon: |
| 1084 |
@prohibit='; *;[ {} \]*(/[/*]|$$)' \ |
| 1085 |
in_vc_files='\.[chly]$$' \ |
| 1086 |
exclude='\bfor *\(.*\)' \ |
| 1087 |
halt="Double semicolon detected" \ |
| 1088 |
$(_sc_search_regexp) |
| 1089 |
|
| 1090 |
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2" |
| 1091 |
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2" |
| 1092 |
|
| 1093 |
|
| 1094 |
sc_prohibit_test_minus_ao: |
| 1095 |
@prohibit='(\<test| \[+) .+ -[ao] ' \ |
| 1096 |
halt='$(_ptm1); $(_ptm2)' \ |
| 1097 |
$(_sc_search_regexp) |
| 1098 |
|
| 1099 |
|
| 1100 |
sc_prohibit_test_double_equal: |
| 1101 |
@prohibit='(\<test| \[+) .+ == ' \ |
| 1102 |
containing='#! */bin/[a-z]*sh' \ |
| 1103 |
halt='use "test x = x", not "test x =''= x"' \ |
| 1104 |
$(_sc_search_regexp) |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
sc_proper_name_utf8_requires_ICONV: |
| 1112 |
@progs=$$($(VC_LIST_EXCEPT) \ |
| 1113 |
| xargs $(GREP) -l 'proper_name_utf8 ''("'); \ |
| 1114 |
if test "x$$progs" != x; then \ |
| 1115 |
fail=0; \ |
| 1116 |
for p in $$progs; do \ |
| 1117 |
dir=$$(dirname "$$p"); \ |
| 1118 |
perl -0777 \ |
| 1119 |
-ne 'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \ |
| 1120 |
$$dir/Makefile.am && continue; \ |
| 1121 |
base=$$(basename "$$p" .c); \ |
| 1122 |
$(GREP) "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \ |
| 1123 |
|| { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \ |
| 1124 |
done; \ |
| 1125 |
test $$fail = 1 && \ |
| 1126 |
{ echo 1>&2 '$(ME): the above do not link with any ICONV library'; \ |
| 1127 |
exit 1; } || :; \ |
| 1128 |
fi |
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
sc_redundant_const: |
| 1133 |
@prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \ |
| 1134 |
halt='redundant "const" in declarations' \ |
| 1135 |
$(_sc_search_regexp) |
| 1136 |
|
| 1137 |
sc_const_long_option: |
| 1138 |
@prohibit='^ *static.*struct option ' \ |
| 1139 |
exclude='const struct option|struct option const' \ |
| 1140 |
halt='add "const" to the above declarations' \ |
| 1141 |
$(_sc_search_regexp) |
| 1142 |
|
| 1143 |
NEWS_hash = \ |
| 1144 |
$$($(SED) -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ |
| 1145 |
$(srcdir)/NEWS \ |
| 1146 |
| perl -0777 -pe \ |
| 1147 |
's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \ |
| 1148 |
| md5sum - \ |
| 1149 |
| $(SED) 's/ .*//') |
| 1150 |
|
| 1151 |
|
| 1152 |
sc_immutable_NEWS: |
| 1153 |
@if test -f $(srcdir)/NEWS; then \ |
| 1154 |
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \ |
| 1155 |
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \ |
| 1156 |
fi |
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
update-NEWS-hash: NEWS |
| 1161 |
perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \ |
| 1162 |
$(srcdir)/cfg.mk |
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
_makefile_at_at_check_exceptions ?= |
| 1178 |
sc_makefile_at_at_check: |
| 1179 |
@perl -ne '/\@\w+\@/' \ |
| 1180 |
-e ' && !/(\w+)\s+=.*\@\1\@$$/' \ |
| 1181 |
-e ''$(_makefile_at_at_check_exceptions) \ |
| 1182 |
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \ |
| 1183 |
$$($(VC_LIST_EXCEPT) | $(GREP) -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \ |
| 1184 |
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : |
| 1185 |
|
| 1186 |
news-check: NEWS |
| 1187 |
$(AM_V_GEN)if $(SED) -n $(news-check-lines-spec)p $< \ |
| 1188 |
| $(GREP) -E $(news-check-regexp) >/dev/null; then \ |
| 1189 |
:; \ |
| 1190 |
else \ |
| 1191 |
echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ |
| 1192 |
exit 1; \ |
| 1193 |
fi |
| 1194 |
|
| 1195 |
sc_makefile_TAB_only_indentation: |
| 1196 |
@prohibit='^ [ ]{8}' \ |
| 1197 |
in_vc_files='akefile|\.mk$$' \ |
| 1198 |
halt='found TAB-8-space indentation' \ |
| 1199 |
$(_sc_search_regexp) |
| 1200 |
|
| 1201 |
sc_m4_quote_check: |
| 1202 |
@prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \ |
| 1203 |
in_vc_files='(^configure\.ac|\.m4)$$' \ |
| 1204 |
halt='quote the first arg to AC_DEF*' \ |
| 1205 |
$(_sc_search_regexp) |
| 1206 |
|
| 1207 |
fix_po_file_diag = \ |
| 1208 |
'you have changed the set of files with translatable diagnostics;\n\ |
| 1209 |
apply the above patch\n' |
| 1210 |
|
| 1211 |
|
| 1212 |
perl_translatable_files_list_ = \ |
| 1213 |
-e 'foreach $$file (@ARGV) {' \ |
| 1214 |
-e ' \# Consider only file extensions with one or two letters' \ |
| 1215 |
-e ' $$file =~ /\...?$$/ or next;' \ |
| 1216 |
-e ' \# Ignore m4 and mk files' \ |
| 1217 |
-e ' $$file =~ /\.m[4k]$$/ and next;' \ |
| 1218 |
-e ' \# Ignore a .c or .h file with a corresponding .l or .y file' \ |
| 1219 |
-e ' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \ |
| 1220 |
-e ' and next;' \ |
| 1221 |
-e ' \# Skip unreadable files' \ |
| 1222 |
-e ' -r $$file or next;' \ |
| 1223 |
-e ' print "$$file ";' \ |
| 1224 |
-e '}' |
| 1225 |
|
| 1226 |
# Verify that all source files using _() (more specifically, files that |
| 1227 |
|
| 1228 |
po_file ?= $(srcdir)/po/POTFILES.in |
| 1229 |
generated_files ?= $(srcdir)/lib/*.[ch] |
| 1230 |
_gl_translatable_string_re ?= \b(N?_|gettext *)\([^)"]*("|$$) |
| 1231 |
sc_po_check: |
| 1232 |
@if test -f $(po_file); then \ |
| 1233 |
$(GREP) -E -v '^(#|$$)' $(po_file) \ |
| 1234 |
| $(GREP) -v '^src/false\.c$$' | sort > $@-1; \ |
| 1235 |
{ $(VC_LIST_EXCEPT); echo $(generated_files); } \ |
| 1236 |
| xargs perl $(perl_translatable_files_list_) \ |
| 1237 |
| xargs $(GREP) -E -l '$(_gl_translatable_string_re)' \ |
| 1238 |
| $(SED) 's|^$(_dot_escaped_srcdir)/||' \ |
| 1239 |
| sort -u > $@-2; \ |
| 1240 |
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \ |
| 1241 |
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \ |
| 1242 |
rm -f $@-1 $@-2; \ |
| 1243 |
fi |
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
msg = 'Do not use ":" above; use $$(PATH_SEPARATOR) instead' |
| 1249 |
sc_makefile_path_separator_check: |
| 1250 |
@prohibit='PATH[=].*:' \ |
| 1251 |
in_vc_files='akefile|\.mk$$' \ |
| 1252 |
halt=$(msg) \ |
| 1253 |
$(_sc_search_regexp) |
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
writable-files: |
| 1259 |
$(AM_V_GEN)if test -d $(release_archive_dir); then \ |
| 1260 |
for file in $(DIST_ARCHIVES); do \ |
| 1261 |
for p in ./ $(release_archive_dir)/; do \ |
| 1262 |
test -e $$p$$file || continue; \ |
| 1263 |
test -w $$p$$file \ |
| 1264 |
|| { echo ERROR: $$p$$file is not writable; fail=1; }; \ |
| 1265 |
done; \ |
| 1266 |
done; \ |
| 1267 |
test "$$fail" && exit 1 || : ; \ |
| 1268 |
else :; \ |
| 1269 |
fi |
| 1270 |
|
| 1271 |
v_etc_file = $(gnulib_dir)/lib/version-etc.c |
| 1272 |
sample-test = tests/sample-test |
| 1273 |
texi = doc/$(PACKAGE).texi |
| 1274 |
|
| 1275 |
|
| 1276 |
sc_copyright_check: |
| 1277 |
@require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \ |
| 1278 |
in_files=$(v_etc_file) \ |
| 1279 |
halt='out of date copyright in $(v_etc_file); update it' \ |
| 1280 |
$(_sc_search_regexp) |
| 1281 |
@require='# Copyright \(C\) '$$(date +%Y)' Free' \ |
| 1282 |
in_vc_files=$(sample-test) \ |
| 1283 |
halt='out of date copyright in $(sample-test); update it' \ |
| 1284 |
$(_sc_search_regexp) |
| 1285 |
@require='Copyright @copyright\{\} .*'$$(date +%Y) \ |
| 1286 |
in_vc_files=$(texi) \ |
| 1287 |
halt='out of date copyright in $(texi); update it' \ |
| 1288 |
$(_sc_search_regexp) |
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
_hv_file ?= $(srcdir)/tests/help-version |
| 1298 |
_hv_regex_weak ?= ^ *\. .*/init\.sh" |
| 1299 |
|
| 1300 |
_hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh" |
| 1301 |
sc_cross_check_PATH_usage_in_tests: |
| 1302 |
@if test -f $(_hv_file); then \ |
| 1303 |
$(GREP) -l 'VERSION mismatch' $(_hv_file) >/dev/null \ |
| 1304 |
|| { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \ |
| 1305 |
exit 0; }; \ |
| 1306 |
$(GREP) -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \ |
| 1307 |
|| { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \ |
| 1308 |
exit 1; }; \ |
| 1309 |
good=$$($(GREP) -E '$(_hv_regex_strong)' $(_hv_file)); \ |
| 1310 |
$(VC_LIST_EXCEPT) \ |
| 1311 |
| xargs $(GREP) -lE '$(_hv_regex_weak)' \ |
| 1312 |
| xargs $(GREP) -LFx "$$good" \ |
| 1313 |
| $(GREP) . \ |
| 1314 |
&& { printf "$(ME): the above files use" \ |
| 1315 |
" path_prepend_ inconsistently\n" 1>&2; \ |
| 1316 |
exit 1; } \ |
| 1317 |
|| :; \ |
| 1318 |
fi |
| 1319 |
|
| 1320 |
|
| 1321 |
_test_script_regex ?= \<init\.sh\> |
| 1322 |
|
| 1323 |
|
| 1324 |
sc_prohibit_reversed_compare_failure: |
| 1325 |
@prohibit='\<compare [^ ]+ ([^ ]*exp|/dev/null)' \ |
| 1326 |
containing='$(_test_script_regex)' \ |
| 1327 |
halt='reversed compare arguments' \ |
| 1328 |
$(_sc_search_regexp) |
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
sc_Wundef_boolean: |
| 1335 |
@prohibit='^#define.*(yes|no|true|false)$$' \ |
| 1336 |
in_files='$(CONFIG_INCLUDE)' \ |
| 1337 |
halt='Use 0 or 1 for macro values' \ |
| 1338 |
$(_sc_search_regexp) |
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
sc_prohibit_path_max_allocation: |
| 1344 |
@prohibit='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \ |
| 1345 |
halt='Avoid stack allocations of size PATH_MAX' \ |
| 1346 |
$(_sc_search_regexp) |
| 1347 |
|
| 1348 |
sc_vulnerable_makefile_CVE-2009-4029: |
| 1349 |
@prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \ |
| 1350 |
in_files='(^|/)Makefile\.in$$' \ |
| 1351 |
halt=$$(printf '%s\n' \ |
| 1352 |
'the above files are vulnerable; beware of running' \ |
| 1353 |
' "make dist*" rules, and upgrade to fixed automake' \ |
| 1354 |
' see https://bugzilla.redhat.com/show_bug.cgi?id=542609 for details') \ |
| 1355 |
$(_sc_search_regexp) |
| 1356 |
|
| 1357 |
sc_vulnerable_makefile_CVE-2012-3386: |
| 1358 |
@prohibit='chmod a\+w \$$\(distdir\)' \ |
| 1359 |
in_files='(^|/)Makefile\.in$$' \ |
| 1360 |
halt=$$(printf '%s\n' \ |
| 1361 |
'the above files are vulnerable; beware of running' \ |
| 1362 |
' "make distcheck", and upgrade to fixed automake' \ |
| 1363 |
' see https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-3386 for details') \ |
| 1364 |
$(_sc_search_regexp) |
| 1365 |
|
| 1366 |
vc-diff-check: |
| 1367 |
$(AM_V_GEN)(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || : |
| 1368 |
$(AM_V_at)if test -s vc-diffs; then \ |
| 1369 |
cat vc-diffs; \ |
| 1370 |
echo "Some files are locally modified:" 1>&2; \ |
| 1371 |
exit 1; \ |
| 1372 |
else \ |
| 1373 |
rm vc-diffs; \ |
| 1374 |
fi |
| 1375 |
|
| 1376 |
rel-files = $(DIST_ARCHIVES) |
| 1377 |
|
| 1378 |
gnulib-version = $$(cd $(gnulib_dir) \ |
| 1379 |
&& { git describe || git rev-parse --short=10 HEAD; } ) |
| 1380 |
bootstrap-tools ?= autoconf,automake,gnulib |
| 1381 |
|
| 1382 |
gpgv = $$(gpgv2 --version >/dev/null && echo gpgv2 || echo gpgv) |
| 1383 |
|
| 1384 |
|
| 1385 |
gpg_key_ID ?= \ |
| 1386 |
$$(cd $(srcdir) \ |
| 1387 |
&& git cat-file tag v$(VERSION) \ |
| 1388 |
| $(gpgv) --status-fd 1 --keyring /dev/null - - 2>/dev/null \ |
| 1389 |
| $(AWK) '/^\[GNUPG:\] ERRSIG / {print $$3; exit}') |
| 1390 |
|
| 1391 |
translation_project_ ?= [email protected] |
| 1392 |
|
| 1393 |
|
| 1394 |
announcement_Cc_stable = $(translation_project_), $(PACKAGE_BUGREPORT) |
| 1395 |
announcement_mail_headers_stable = \ |
| 1396 |
To: [email protected] \ |
| 1397 |
Cc: $(announcement_Cc_) \ |
| 1398 |
Mail-Followup-To: $(PACKAGE_BUGREPORT) |
| 1399 |
|
| 1400 |
announcement_Cc_alpha = $(translation_project_) |
| 1401 |
announcement_mail_headers_alpha = \ |
| 1402 |
To: $(PACKAGE_BUGREPORT) \ |
| 1403 |
Cc: $(announcement_Cc_) |
| 1404 |
|
| 1405 |
announcement_mail_Cc_beta = $(announcement_mail_Cc_alpha) |
| 1406 |
announcement_mail_headers_beta = $(announcement_mail_headers_alpha) |
| 1407 |
|
| 1408 |
announcement_mail_Cc_ ?= $(announcement_mail_Cc_$(release-type)) |
| 1409 |
announcement_mail_headers_ ?= $(announcement_mail_headers_$(release-type)) |
| 1410 |
announcement: NEWS ChangeLog $(rel-files) |
| 1411 |
|
| 1412 |
|
| 1413 |
$(AM_V_at)$(srcdir)/$(_build-aux)/announce-gen \ |
| 1414 |
--mail-headers='$(announcement_mail_headers_)' \ |
| 1415 |
--release-type=$(release-type) \ |
| 1416 |
--package=$(PACKAGE) \ |
| 1417 |
--prev=$(PREV_VERSION) \ |
| 1418 |
--curr=$(VERSION) \ |
| 1419 |
--gpg-key-id=$(gpg_key_ID) \ |
| 1420 |
--srcdir=$(srcdir) \ |
| 1421 |
--news=$(srcdir)/NEWS \ |
| 1422 |
--bootstrap-tools=$(bootstrap-tools) \ |
| 1423 |
$$(case ,$(bootstrap-tools), in (*,gnulib,*) \ |
| 1424 |
echo --gnulib-version=$(gnulib-version);; esac) \ |
| 1425 |
--no-print-checksums \ |
| 1426 |
$(addprefix --url-dir=, $(url_dir_list)) |
| 1427 |
|
| 1428 |
.PHONY: release-commit |
| 1429 |
release-commit: |
| 1430 |
$(AM_V_GEN)cd $(srcdir) \ |
| 1431 |
&& $(_build-aux)/do-release-commit-and-tag \ |
| 1432 |
-C $(abs_builddir) $(RELEASE) |
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
ftp-gnu = https://ftp.gnu.org/gnu |
| 1439 |
www-gnu = https://www.gnu.org |
| 1440 |
|
| 1441 |
upload_dest_dir_ ?= $(PACKAGE) |
| 1442 |
upload_command = \ |
| 1443 |
$(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \ |
| 1444 |
--to $(gnu_rel_host):$(upload_dest_dir_) \ |
| 1445 |
$(rel-files) |
| 1446 |
emit_upload_commands: |
| 1447 |
@echo ===================================== |
| 1448 |
@echo ===================================== |
| 1449 |
@echo '$(upload_command)' |
| 1450 |
@echo '# send the ~/announce-$(my_distdir) e-mail' |
| 1451 |
@echo ===================================== |
| 1452 |
@echo ===================================== |
| 1453 |
|
| 1454 |
.PHONY: upload |
| 1455 |
upload: |
| 1456 |
$(AM_V_GEN)$(upload_command) |
| 1457 |
|
| 1458 |
define emit-commit-log |
| 1459 |
printf '%s\n' 'maint: post-release administrivia' '' \ |
| 1460 |
'* NEWS: Add header line for next release.' \ |
| 1461 |
'* .prev-version: Record previous version.' \ |
| 1462 |
'* cfg.mk (old_NEWS_hash): Auto-update.' |
| 1463 |
endef |
| 1464 |
|
| 1465 |
.PHONY: no-submodule-changes |
| 1466 |
no-submodule-changes: |
| 1467 |
$(AM_V_GEN)if test -d $(srcdir)/.git \ |
| 1468 |
&& git --version >/dev/null 2>&1; then \ |
| 1469 |
diff=$$(cd $(srcdir) && git submodule -q foreach \ |
| 1470 |
git diff-index --name-only HEAD) \ |
| 1471 |
|| exit 1; \ |
| 1472 |
case $$diff in '') ;; \ |
| 1473 |
*) echo '$(ME): submodule files are locally modified:'; \ |
| 1474 |
echo "$$diff"; exit 1;; esac; \ |
| 1475 |
else \ |
| 1476 |
: ; \ |
| 1477 |
fi |
| 1478 |
|
| 1479 |
submodule-checks ?= no-submodule-changes public-submodule-commit |
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
.PHONY: public-submodule-commit |
| 1485 |
public-submodule-commit: |
| 1486 |
$(AM_V_GEN)if test -d $(srcdir)/.git \ |
| 1487 |
&& git --version >/dev/null 2>&1; then \ |
| 1488 |
cd $(srcdir) && \ |
| 1489 |
git submodule --quiet foreach \ |
| 1490 |
'test "$$(git rev-parse "$$sha1")" \ |
| 1491 |
= "$$(git merge-base origin "$$sha1")"' \ |
| 1492 |
|| { echo '$(ME): found non-public submodule commit' >&2; \ |
| 1493 |
exit 1; }; \ |
| 1494 |
else \ |
| 1495 |
: ; \ |
| 1496 |
fi |
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
gl_public_submodule_commit ?= public-submodule-commit |
| 1504 |
check: $(gl_public_submodule_commit) |
| 1505 |
|
| 1506 |
.PHONY: alpha beta stable release |
| 1507 |
ALL_RECURSIVE_TARGETS += alpha beta stable |
| 1508 |
alpha beta stable: $(local-check) writable-files $(submodule-checks) |
| 1509 |
$(AM_V_GEN)test $@ = stable \ |
| 1510 |
&& { echo $(VERSION) | $(GREP) -E '^[0-9]+(\.[0-9]+)+$$' \ |
| 1511 |
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ |
| 1512 |
|| : |
| 1513 |
$(AM_V_at)$(MAKE) vc-diff-check |
| 1514 |
$(AM_V_at)$(MAKE) news-check |
| 1515 |
$(AM_V_at)$(MAKE) distcheck |
| 1516 |
$(AM_V_at)$(MAKE) dist |
| 1517 |
$(AM_V_at)$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@ |
| 1518 |
$(AM_V_at)$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@ |
| 1519 |
|
| 1520 |
release: |
| 1521 |
$(AM_V_GEN)$(MAKE) _version |
| 1522 |
$(AM_V_GEN)$(MAKE) $(release-type) |
| 1523 |
|
| 1524 |
|
| 1525 |
release-prep-hook ?= release-prep |
| 1526 |
|
| 1527 |
gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?] |
| 1528 |
.PHONY: release-prep |
| 1529 |
release-prep: |
| 1530 |
$(AM_V_GEN)$(MAKE) --no-print-directory -s announcement \ |
| 1531 |
> ~/announce-$(my_distdir) |
| 1532 |
$(AM_V_at)if test -d $(release_archive_dir); then \ |
| 1533 |
ln $(rel-files) $(release_archive_dir); \ |
| 1534 |
chmod a-w $(rel-files); \ |
| 1535 |
fi |
| 1536 |
$(AM_V_at)echo $(VERSION) > $(prev_version_file) |
| 1537 |
$(AM_V_at)$(MAKE) update-NEWS-hash |
| 1538 |
$(AM_V_at)perl -pi \ |
| 1539 |
-e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' \ |
| 1540 |
$(srcdir)/NEWS |
| 1541 |
$(AM_V_at)msg=$$($(emit-commit-log)) || exit 1; \ |
| 1542 |
cd $(srcdir) && $(VC) commit -m "$$msg" -a |
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
gendocs_options_ ?= |
| 1547 |
|
| 1548 |
.PHONY: web-manual |
| 1549 |
web-manual: |
| 1550 |
$(AM_V_GEN)test -z "$(manual_title)" \ |
| 1551 |
&& { echo define manual_title in cfg.mk 1>&2; exit 1; } || : |
| 1552 |
$(AM_V_at)cd '$(srcdir)/doc'; \ |
| 1553 |
$(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \ |
| 1554 |
-o '$(abs_builddir)/doc/manual' \ |
| 1555 |
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \ |
| 1556 |
"$(PACKAGE_NAME) - $(manual_title)" |
| 1557 |
$(AM_V_at)echo " *** Upload the doc/manual directory to web-cvs." |
| 1558 |
|
| 1559 |
.PHONY: web-manual-update |
| 1560 |
web-manual-update: |
| 1561 |
$(AM_V_GEN)cd $(srcdir) \ |
| 1562 |
&& $(_build-aux)/gnu-web-doc-update -C $(abs_builddir) |
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
init-coverage: |
| 1568 |
$(MAKE) $(AM_MAKEFLAGS) clean |
| 1569 |
lcov --directory . --zerocounters |
| 1570 |
|
| 1571 |
COVERAGE_CCOPTS ?= "-g --coverage" |
| 1572 |
COVERAGE_OUT ?= doc/coverage |
| 1573 |
|
| 1574 |
build-coverage: |
| 1575 |
$(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) |
| 1576 |
$(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check |
| 1577 |
mkdir -p $(COVERAGE_OUT) |
| 1578 |
lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \ |
| 1579 |
--capture |
| 1580 |
|
| 1581 |
gen-coverage: |
| 1582 |
genhtml --output-directory $(COVERAGE_OUT) \ |
| 1583 |
$(COVERAGE_OUT)/$(PACKAGE).info \ |
| 1584 |
--highlight --frames --legend \ |
| 1585 |
--title "$(PACKAGE_NAME)" |
| 1586 |
|
| 1587 |
coverage: |
| 1588 |
$(MAKE) init-coverage |
| 1589 |
$(MAKE) build-coverage |
| 1590 |
$(MAKE) gen-coverage |
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
.PHONY: refresh-gnulib-patches |
| 1601 |
refresh-gnulib-patches: |
| 1602 |
gl=gl; \ |
| 1603 |
if test -f bootstrap.conf; then \ |
| 1604 |
t=$$(perl -lne '/^\s*local_gl_dir=(\S+)/ and $$d=$$1;' \ |
| 1605 |
-e 'END{defined $$d and print $$d}' bootstrap.conf); \ |
| 1606 |
test -n "$$t" && gl=$$t; \ |
| 1607 |
fi; \ |
| 1608 |
for diff in $$(cd $$gl; git ls-files | $(GREP) '\.diff$$'); do \ |
| 1609 |
b=$$(printf %s "$$diff"|$(SED) 's/\.diff$$//'); \ |
| 1610 |
VERSION_CONTROL=none \ |
| 1611 |
patch "$(gnulib_dir)/$$b" "$$gl/$$diff" || exit 1; \ |
| 1612 |
( cd $(gnulib_dir) || exit 1; \ |
| 1613 |
git diff "$$b" > "../$$gl/$$diff"; \ |
| 1614 |
git checkout $$b ) || exit 1; \ |
| 1615 |
done |
| 1616 |
|
| 1617 |
|
| 1618 |
PACKAGE ?= $(shell basename $(PWD)) |
| 1619 |
PO_DOMAIN ?= $(PACKAGE) |
| 1620 |
POURL = https://translationproject.org/latest/$(PO_DOMAIN)/ |
| 1621 |
PODIR ?= po |
| 1622 |
refresh-po: |
| 1623 |
rm -f $(PODIR)/*.po && \ |
| 1624 |
echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \ |
| 1625 |
wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \ |
| 1626 |
echo 'en@boldquot' > $(PODIR)/LINGUAS && \ |
| 1627 |
echo 'en@quot' >> $(PODIR)/LINGUAS && \ |
| 1628 |
ls $(PODIR)/*.po | $(SED) 's/\.po//;s,$(PODIR)/,,' | \ |
| 1629 |
sort >> $(PODIR)/LINGUAS |
| 1630 |
|
| 1631 |
|
| 1632 |
INDENT_SOURCES ?= $(C_SOURCES) |
| 1633 |
.PHONY: indent |
| 1634 |
indent: |
| 1635 |
indent $(INDENT_SOURCES) |
| 1636 |
indent $(INDENT_SOURCES) |
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
update-copyright-env ?= |
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
.PHONY: update-copyright |
| 1650 |
update-copyright: |
| 1651 |
$(AM_V_GEN)$(GREP) -l -w Copyright \ |
| 1652 |
$$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \ |
| 1653 |
| $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@ |
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
_gl_TS_dir ?= src |
| 1661 |
|
| 1662 |
ALL_RECURSIVE_TARGETS += sc_tight_scope |
| 1663 |
sc_tight_scope: tight-scope.mk |
| 1664 |
@fail=0; \ |
| 1665 |
if ! $(GREP) '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \ |
| 1666 |
> /dev/null \ |
| 1667 |
&& ! $(GREP) -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \ |
| 1668 |
> /dev/null 2>&1; then \ |
| 1669 |
echo '$(ME): skipping $@'; \ |
| 1670 |
else \ |
| 1671 |
$(MAKE) -s -C $(_gl_TS_dir) \ |
| 1672 |
-f Makefile \ |
| 1673 |
-f $(abs_top_srcdir)/cfg.mk \ |
| 1674 |
-f $(abs_top_builddir)/$< \ |
| 1675 |
_gl_tight_scope \ |
| 1676 |
|| fail=1; \ |
| 1677 |
fi; \ |
| 1678 |
rm -f $<; \ |
| 1679 |
exit $$fail |
| 1680 |
|
| 1681 |
tight-scope.mk: $(ME) |
| 1682 |
@rm -f $@ $@-t |
| 1683 |
@perl -ne '/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME) > $@-t |
| 1684 |
@chmod a=r $@-t && mv $@-t $@ |
| 1685 |
|
| 1686 |
ifeq (a,b) |
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
_gl_TS_unmarked_extern_functions ?= main usage |
| 1695 |
_gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\w+) *\(/ |
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
_gl_TS_extern ?= extern |
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
_gl_TS_unmarked_extern_vars ?= |
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/ |
| 1717 |
|
| 1718 |
|
| 1719 |
_gl_TS_obj_files ?= *.$(OBJEXT) |
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
_gl_TS_headers ?= $(noinst_HEADERS) |
| 1724 |
_gl_TS_other_headers ?= *.h |
| 1725 |
|
| 1726 |
.PHONY: _gl_tight_scope |
| 1727 |
_gl_tight_scope: $(bin_PROGRAMS) |
| 1728 |
sed_wrap='s/^/^_?/;s/$$/$$/'; \ |
| 1729 |
t=exceptions-$$$$; \ |
| 1730 |
trap 's=$$?; rm -f $$t; exit $$s' 0; \ |
| 1731 |
for sig in 1 2 3 13 15; do \ |
| 1732 |
eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \ |
| 1733 |
done; \ |
| 1734 |
src=`for f in $(SOURCES); do \ |
| 1735 |
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \ |
| 1736 |
hdr=`for f in $(_gl_TS_headers); do \ |
| 1737 |
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \ |
| 1738 |
( printf '%s\n' '__.*' $(_gl_TS_unmarked_extern_functions); \ |
| 1739 |
$(GREP) -h -A1 '^extern .*[^;]$$' $$src \ |
| 1740 |
| $(GREP) -vE '^(extern |--|#)' | $(SED) 's/ .*//; /^$$/d'; \ |
| 1741 |
perl -lne \ |
| 1742 |
'$(_gl_TS_function_match) and print $$1' $$hdr; \ |
| 1743 |
) | sort -u | $(SED) "$$sed_wrap" > $$t; \ |
| 1744 |
nm -g $(_gl_TS_obj_files)|$(SED) -n 's/.* T //p'|$(GREP) -Ev -f $$t \ |
| 1745 |
&& { echo the above functions should have static scope >&2; \ |
| 1746 |
exit 1; } || : ; \ |
| 1747 |
( printf '%s\n' '__.*' main $(_gl_TS_unmarked_extern_vars); \ |
| 1748 |
perl -lne '$(_gl_TS_var_match) and print $$1' \ |
| 1749 |
$$hdr $(_gl_TS_other_headers) \ |
| 1750 |
) | sort -u | $(SED) "$$sed_wrap" > $$t; \ |
| 1751 |
nm -g $(_gl_TS_obj_files) | $(SED) -n 's/.* [BCDGRS] //p' \ |
| 1752 |
| sort -u | $(GREP) -Ev -f $$t \ |
| 1753 |
&& { echo the above variables should have static scope >&2; \ |
| 1754 |
exit 1; } || : |
| 1755 |
|
| 1756 |
endif |