| 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 |
gzip_rsyncable := \ |
|---|
| 27 |
$(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable) |
|---|
| 28 |
GZIP_ENV = '--no-name --best $(gzip_rsyncable)' |
|---|
| 29 |
|
|---|
| 30 |
GIT = git |
|---|
| 31 |
VC = $(GIT) |
|---|
| 32 |
VC-tag = git tag -s -m '$(VERSION)' |
|---|
| 33 |
|
|---|
| 34 |
VC_LIST = build-aux/vc-list-files |
|---|
| 35 |
|
|---|
| 36 |
VC_LIST_EXCEPT = \ |
|---|
| 37 |
$(VC_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi |
|---|
| 38 |
|
|---|
| 39 |
ifeq ($(origin prev_version_file), undefined) |
|---|
| 40 |
prev_version_file = $(srcdir)/.prev-version |
|---|
| 41 |
endif |
|---|
| 42 |
|
|---|
| 43 |
PREV_VERSION := $(shell cat $(prev_version_file)) |
|---|
| 44 |
VERSION_REGEXP = $(subst .,\.,$(VERSION)) |
|---|
| 45 |
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION)) |
|---|
| 46 |
|
|---|
| 47 |
ifeq ($(VC),$(GIT)) |
|---|
| 48 |
this-vc-tag = v$(VERSION) |
|---|
| 49 |
this-vc-tag-regexp = v$(VERSION_REGEXP) |
|---|
| 50 |
else |
|---|
| 51 |
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]') |
|---|
| 52 |
tag-this-version = $(subst .,_,$(VERSION)) |
|---|
| 53 |
this-vc-tag = $(tag-package)-$(tag-this-version) |
|---|
| 54 |
this-vc-tag-regexp = $(this-vc-tag) |
|---|
| 55 |
endif |
|---|
| 56 |
my_distdir = $(PACKAGE)-$(VERSION) |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
release_archive_dir ?= ../release |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
export LC_ALL = C |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \ |
|---|
| 73 |
) |
|---|
| 74 |
.PHONY: $(syntax-check-rules) |
|---|
| 75 |
|
|---|
| 76 |
local-checks-available = \ |
|---|
| 77 |
po-check copyright-check m4-check author_mark_check \ |
|---|
| 78 |
patch-check strftime-check $(syntax-check-rules) \ |
|---|
| 79 |
makefile_path_separator_check \ |
|---|
| 80 |
makefile-check check-AUTHORS |
|---|
| 81 |
.PHONY: $(local-checks-available) |
|---|
| 82 |
|
|---|
| 83 |
local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available)) |
|---|
| 84 |
|
|---|
| 85 |
syntax-check: $(local-check) |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
sc_avoid_if_before_free: |
|---|
| 98 |
@$(srcdir)/build-aux/useless-if-before-free \ |
|---|
| 99 |
$(useless_free_options) \ |
|---|
| 100 |
$$($(VC_LIST_EXCEPT)) && \ |
|---|
| 101 |
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \ |
|---|
| 102 |
exit 1; } || : |
|---|
| 103 |
|
|---|
| 104 |
sc_cast_of_argument_to_free: |
|---|
| 105 |
@grep -nE '\<free *\( *\(' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 106 |
{ echo '$(ME): don'\''t cast free argument' 1>&2; \ |
|---|
| 107 |
exit 1; } || : |
|---|
| 108 |
|
|---|
| 109 |
sc_cast_of_x_alloc_return_value: |
|---|
| 110 |
@grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 111 |
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \ |
|---|
| 112 |
exit 1; } || : |
|---|
| 113 |
|
|---|
| 114 |
sc_cast_of_alloca_return_value: |
|---|
| 115 |
@grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 116 |
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \ |
|---|
| 117 |
exit 1; } || : |
|---|
| 118 |
|
|---|
| 119 |
sc_space_tab: |
|---|
| 120 |
@grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 121 |
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \ |
|---|
| 122 |
1>&2; exit 1; } || : |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
sc_prohibit_atoi_atof: |
|---|
| 128 |
@grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 129 |
{ echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf' \ |
|---|
| 130 |
1>&2; exit 1; } || : |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
sc_prohibit_strcmp: |
|---|
| 134 |
@grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *==' \ |
|---|
| 135 |
$$($(VC_LIST_EXCEPT)) && \ |
|---|
| 136 |
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \ |
|---|
| 137 |
1>&2; exit 1; } || : |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
sc_error_exit_success: |
|---|
| 142 |
@grep -nF 'error (EXIT_SUCCESS,' \ |
|---|
| 143 |
$$(find -type f -name '*.[chly]') && \ |
|---|
| 144 |
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \ |
|---|
| 145 |
exit 1; } || : |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
sc_error_message_warn_fatal: |
|---|
| 150 |
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \ |
|---|
| 151 |
| grep -E '"Warning|"Fatal|"fatal' && \ |
|---|
| 152 |
{ echo '$(ME): use FATAL, WARNING or warning' 1>&2; \ |
|---|
| 153 |
exit 1; } || : |
|---|
| 154 |
|
|---|
| 155 |
# Error messages should not start with a capital letter |
|---|
| 156 |
sc_error_message_uppercase: |
|---|
| 157 |
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \ |
|---|
| 158 |
| grep -E '"[A-Z]' \ |
|---|
| 159 |
| grep -vE '"FATAL|"WARNING|"Java|"C |
|---|
| 160 |
{ echo '$(ME): found capitalized error message' 1>&2; \ |
|---|
| 161 |
exit 1; } || : |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
sc_error_message_period: |
|---|
| 165 |
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \ |
|---|
| 166 |
| grep -E '[^."]\."' && \ |
|---|
| 167 |
{ echo '$(ME): found error message ending in period' 1>&2; \ |
|---|
| 168 |
exit 1; } || : |
|---|
| 169 |
|
|---|
| 170 |
sc_file_system: |
|---|
| 171 |
@grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 172 |
{ echo '$(ME): found use of "file''system";' \ |
|---|
| 173 |
'rewrite to use "file system"' 1>&2; \ |
|---|
| 174 |
exit 1; } || : |
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
sc_no_have_config_h: |
|---|
| 178 |
@grep -n '^ |
|---|
| 179 |
{ echo '$(ME): found use of HAVE''_CONFIG_H; remove' \ |
|---|
| 180 |
1>&2; exit 1; } || : |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
sc_require_config_h: |
|---|
| 184 |
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ |
|---|
| 185 |
grep -L '^ |
|---|
| 186 |
$$($(VC_LIST_EXCEPT) | grep '\.c$$') \ |
|---|
| 187 |
| grep . && \ |
|---|
| 188 |
{ echo '$(ME): the above files do not include <config.h>' \ |
|---|
| 189 |
1>&2; exit 1; } || :; \ |
|---|
| 190 |
else :; \ |
|---|
| 191 |
fi |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
define _header_without_use |
|---|
| 197 |
h_esc=`echo "$$h"|sed 's/\./\\./'`; \ |
|---|
| 198 |
if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ |
|---|
| 199 |
files=$$(grep -l '^# *include '"$$h_esc" \ |
|---|
| 200 |
$$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \ |
|---|
| 201 |
grep -LE "$$re" $$files | grep . && \ |
|---|
| 202 |
{ echo "$(ME): the above files include $$h but don't use it" \ |
|---|
| 203 |
1>&2; exit 1; } || :; \ |
|---|
| 204 |
else :; \ |
|---|
| 205 |
fi |
|---|
| 206 |
endef |
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
sc_prohibit_assert_without_use: |
|---|
| 210 |
@h='<assert.h>' re='\<assert *\(' $(_header_without_use) |
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
sc_prohibit_getopt_without_use: |
|---|
| 214 |
@h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use) |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
sc_prohibit_quotearg_without_use: |
|---|
| 218 |
@h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use) |
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
sc_prohibit_quote_without_use: |
|---|
| 222 |
@h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use) |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
sc_prohibit_long_options_without_use: |
|---|
| 226 |
@h='"long-options.h"' re='\<parse_long_options *\(' \ |
|---|
| 227 |
$(_header_without_use) |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
sc_prohibit_inttostr_without_use: |
|---|
| 231 |
@h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \ |
|---|
| 232 |
$(_header_without_use) |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
sc_prohibit_error_without_use: |
|---|
| 236 |
@h='"error.h"' \ |
|---|
| 237 |
re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\ |
|---|
| 238 |
$(_header_without_use) |
|---|
| 239 |
|
|---|
| 240 |
sc_prohibit_safe_read_without_use: |
|---|
| 241 |
@h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \ |
|---|
| 242 |
$(_header_without_use) |
|---|
| 243 |
|
|---|
| 244 |
sc_prohibit_argmatch_without_use: |
|---|
| 245 |
@h='"argmatch.h"' \ |
|---|
| 246 |
re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \ |
|---|
| 247 |
$(_header_without_use) |
|---|
| 248 |
|
|---|
| 249 |
sc_prohibit_root_dev_ino_without_use: |
|---|
| 250 |
@h='"root-dev-ino.h"' \ |
|---|
| 251 |
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \ |
|---|
| 252 |
$(_header_without_use) |
|---|
| 253 |
|
|---|
| 254 |
sc_obsolete_symbols: |
|---|
| 255 |
@grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ |
|---|
| 256 |
$$($(VC_LIST_EXCEPT)) && \ |
|---|
| 257 |
{ echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \ |
|---|
| 258 |
1>&2; exit 1; } || : |
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
sc_changelog: |
|---|
| 264 |
@grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \ |
|---|
| 265 |
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \ |
|---|
| 266 |
exit 1; } || : |
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
dd_c = $(srcdir)/src/dd.c |
|---|
| 271 |
sc_dd_max_sym_length: |
|---|
| 272 |
ifneq ($(wildcard $(dd_c)),) |
|---|
| 273 |
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\ |
|---|
| 274 |
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \ |
|---|
| 275 |
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \ |
|---|
| 276 |
| wc --max-line-length); \ |
|---|
| 277 |
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \ |
|---|
| 278 |
|tr -d '"' | wc --max-line-length); \ |
|---|
| 279 |
if test "$$len" = "$$max"; then :; else \ |
|---|
| 280 |
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \ |
|---|
| 281 |
exit 1; \ |
|---|
| 282 |
fi |
|---|
| 283 |
endif |
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
sc_prohibit_jm_in_m4: |
|---|
| 289 |
@grep -nE 'jm_[A-Z]' \ |
|---|
| 290 |
$$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \ |
|---|
| 291 |
{ echo '$(ME): do not use jm_ in m4 macro names' \ |
|---|
| 292 |
1>&2; exit 1; } || : |
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
sc_root_tests: |
|---|
| 296 |
@if test -d tests \ |
|---|
| 297 |
&& grep check-root tests/Makefile.am>/dev/null 2>&1; then \ |
|---|
| 298 |
t1=sc-root.expected; t2=sc-root.actual; \ |
|---|
| 299 |
grep -nl '^require_root_$$' \ |
|---|
| 300 |
$$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \ |
|---|
| 301 |
sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \ |
|---|
| 302 |
$(srcdir)/tests/Makefile.am \ |
|---|
| 303 |
| sed 's/^ *//;/^root_tests =/d' \ |
|---|
| 304 |
| tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \ |
|---|
| 305 |
diff -u $$t1 $$t2 || diff=1; \ |
|---|
| 306 |
rm -f $$t1 $$t2; \ |
|---|
| 307 |
test "$$diff" \ |
|---|
| 308 |
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \ |
|---|
| 309 |
exit 1; } || :; \ |
|---|
| 310 |
fi |
|---|
| 311 |
|
|---|
| 312 |
headers_with_interesting_macro_defs = \ |
|---|
| 313 |
exit.h \ |
|---|
| 314 |
fcntl_.h \ |
|---|
| 315 |
fnmatch_.h \ |
|---|
| 316 |
intprops.h \ |
|---|
| 317 |
inttypes_.h \ |
|---|
| 318 |
lchown.h \ |
|---|
| 319 |
openat.h \ |
|---|
| 320 |
stat-macros.h \ |
|---|
| 321 |
stdint_.h |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
.re-defmac: |
|---|
| 326 |
@(cd $(srcdir)/lib; \ |
|---|
| 327 |
for f in $(headers_with_interesting_macro_defs); do \ |
|---|
| 328 |
test -f $$f && \ |
|---|
| 329 |
sed -n '/^ |
|---|
| 330 |
done; \ |
|---|
| 331 |
) | sort -u \ |
|---|
| 332 |
| grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \ |
|---|
| 333 |
| sed 's/^/^ |
|---|
| 334 |
> $@-t |
|---|
| 335 |
@mv $@-t $@ |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
sc_always_defined_macros: .re-defmac |
|---|
| 339 |
@if test -f $(srcdir)/src/system.h; then \ |
|---|
| 340 |
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \ |
|---|
| 341 |
grep -f .re-defmac $$($(VC_LIST)) \ |
|---|
| 342 |
&& { echo '$(ME): define the above via some gnulib .h file' \ |
|---|
| 343 |
1>&2; exit 1; } || :; \ |
|---|
| 344 |
fi |
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
.re-list: |
|---|
| 349 |
@sed -n '/^ |
|---|
| 350 |
| grep -Ev 'sys/(param|file)\.h' \ |
|---|
| 351 |
| sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \ |
|---|
| 352 |
> $@-t |
|---|
| 353 |
@mv $@-t $@ |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
sc_system_h_headers: .re-list |
|---|
| 358 |
@if test -f $(srcdir)/src/system.h; then \ |
|---|
| 359 |
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \ |
|---|
| 360 |
grep -nE -f .re-list \ |
|---|
| 361 |
$$($(VC_LIST) src | \ |
|---|
| 362 |
grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \ |
|---|
| 363 |
&& { echo '$(ME): the above are already included via system.h'\ |
|---|
| 364 |
1>&2; exit 1; } || :; \ |
|---|
| 365 |
fi |
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
sc_program_name: |
|---|
| 370 |
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ |
|---|
| 371 |
files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \ |
|---|
| 372 |
grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \ |
|---|
| 373 |
| grep . && \ |
|---|
| 374 |
{ echo '$(ME): the above files do not call set_program_name' \ |
|---|
| 375 |
1>&2; exit 1; } || :; \ |
|---|
| 376 |
else :; \ |
|---|
| 377 |
fi |
|---|
| 378 |
|
|---|
| 379 |
# Require that the final line of each test-lib.sh-using test be this one: |
|---|
| 380 |
# (exit $fail); exit $fail |
|---|
| 381 |
# Note: this test requires GNU grep's --label= option. |
|---|
| 382 |
sc_require_test_exit_idiom: |
|---|
| 383 |
@if test -f $(srcdir)/tests/test-lib.sh; then \ |
|---|
| 384 |
die=0; \ |
|---|
| 385 |
for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \ |
|---|
| 386 |
tail -n1 $$i | grep '^(exit \$$fail); exit \$$fail$$' > /dev/null \ |
|---|
| 387 |
&& : || { die=1; echo $$i; } \ |
|---|
| 388 |
done; \ |
|---|
| 389 |
test $$die = 1 && \ |
|---|
| 390 |
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \ |
|---|
| 391 |
echo 1>&2 '(exit $$fail); exit $$fail'; \ |
|---|
| 392 |
exit 1; } || :; \ |
|---|
| 393 |
fi |
|---|
| 394 |
|
|---|
| 395 |
sc_sun_os_names: |
|---|
| 396 |
@grep -nEi \ |
|---|
| 397 |
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \ |
|---|
| 398 |
$$($(VC_LIST_EXCEPT)) && \ |
|---|
| 399 |
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \ |
|---|
| 400 |
exit 1; } || : |
|---|
| 401 |
|
|---|
| 402 |
sc_the_the: |
|---|
| 403 |
@grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 404 |
{ echo '$(ME): found use of "the ''the";' 1>&2; \ |
|---|
| 405 |
exit 1; } || : |
|---|
| 406 |
|
|---|
| 407 |
sc_tight_scope: |
|---|
| 408 |
$(MAKE) -C src $@ |
|---|
| 409 |
|
|---|
| 410 |
sc_trailing_blank: |
|---|
| 411 |
@grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 412 |
{ echo '$(ME): found trailing blank(s)' \ |
|---|
| 413 |
1>&2; exit 1; } || : |
|---|
| 414 |
|
|---|
| 415 |
# Match lines like the following, but where there is only one space |
|---|
| 416 |
# between the options and the description: |
|---|
| 417 |
# -D, --all-repeated[=delimit-method] print all duplicate lines\n |
|---|
| 418 |
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)? |
|---|
| 419 |
sc_two_space_separator_in_usage: |
|---|
| 420 |
@grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ |
|---|
| 421 |
$$($(VC_LIST_EXCEPT)) && \ |
|---|
| 422 |
{ echo "$(ME): help2man requires at least two spaces between"; \ |
|---|
| 423 |
echo "$(ME): an option and its description"; \ |
|---|
| 424 |
1>&2; exit 1; } || : |
|---|
| 425 |
|
|---|
| 426 |
# Look for diagnostics that aren't marked for translation. |
|---|
| 427 |
# This won't find any for which error's format string is on a separate line. |
|---|
| 428 |
sc_unmarked_diagnostics: |
|---|
| 429 |
@grep -nE \ |
|---|
| 430 |
'\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \ |
|---|
| 431 |
| grep -v '_''(' && \ |
|---|
| 432 |
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \ |
|---|
| 433 |
exit 1; } || : |
|---|
| 434 |
|
|---|
| 435 |
# Avoid useless parentheses like those in this example: |
|---|
| 436 |
# #if defined (SYMBOL) || defined (SYM2) |
|---|
| 437 |
sc_useless_cpp_parens: |
|---|
| 438 |
@grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 439 |
{ echo '$(ME): found useless parentheses in cpp directive' \ |
|---|
| 440 |
1>&2; exit 1; } || : |
|---|
| 441 |
|
|---|
| 442 |
# Require the latest GPL. |
|---|
| 443 |
sc_GPL_version: |
|---|
| 444 |
@grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \ |
|---|
| 445 |
{ echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || : |
|---|
| 446 |
|
|---|
| 447 |
# Perl-based tests used to exec perl from a #!/bin/sh script. |
|---|
| 448 |
# Now they all start with #!/usr/bin/perl and the portability |
|---|
| 449 |
# infrastructure is in tests/Makefile.am. Make sure no old-style |
|---|
| 450 |
# script sneaks back in. |
|---|
| 451 |
sc_no_exec_perl_coreutils: |
|---|
| 452 |
@if test -f $(srcdir)/tests/Coreutils.pm; then \ |
|---|
| 453 |
grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \ |
|---|
| 454 |
{ echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \ |
|---|
| 455 |
exit 1; } || :; \ |
|---|
| 456 |
fi |
|---|
| 457 |
|
|---|
| 458 |
NEWS_hash = \ |
|---|
| 459 |
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ |
|---|
| 460 |
$(srcdir)/NEWS | md5sum -) |
|---|
| 461 |
|
|---|
| 462 |
# Ensure that we don't accidentally insert an entry into an old NEWS block. |
|---|
| 463 |
sc_immutable_NEWS: |
|---|
| 464 |
@if test -f $(srcdir)/NEWS; then \ |
|---|
| 465 |
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \ |
|---|
| 466 |
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \ |
|---|
| 467 |
fi |
|---|
| 468 |
|
|---|
| 469 |
# Each program that uses proper_name_utf8 must link with |
|---|
| 470 |
# one of the ICONV libraries. |
|---|
| 471 |
sc_proper_name_utf8_requires_ICONV: |
|---|
| 472 |
@progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\ |
|---|
| 473 |
if test "x$$progs" != x; then \ |
|---|
| 474 |
fail=0; \ |
|---|
| 475 |
for p in $$progs; do \ |
|---|
| 476 |
dir=$$(dirname "$$p"); \ |
|---|
| 477 |
base=$$(basename "$$p" .c); \ |
|---|
| 478 |
grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \ |
|---|
| 479 |
|| { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \ |
|---|
| 480 |
done; \ |
|---|
| 481 |
test $$fail = 1 && \ |
|---|
| 482 |
{ echo 1>&2 '$(ME): the above do not link with any ICONV library'; \ |
|---|
| 483 |
exit 1; } || :; \ |
|---|
| 484 |
fi |
|---|
| 485 |
|
|---|
| 486 |
# Warn about "c0nst struct Foo const foo[]", |
|---|
| 487 |
# but not about "char const *const foo" or "#define const const". |
|---|
| 488 |
sc_redundant_const: |
|---|
| 489 |
@grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \ |
|---|
| 490 |
$$($(VC_LIST_EXCEPT)) && \ |
|---|
| 491 |
{ echo 1>&2 '$(ME): redundant "const" in declarations'; \ |
|---|
| 492 |
exit 1; } || : |
|---|
| 493 |
|
|---|
| 494 |
sc_const_long_option: |
|---|
| 495 |
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \ |
|---|
| 496 |
| grep -Ev 'const struct option|struct option const' && { \ |
|---|
| 497 |
echo 1>&2 '$(ME): add "const" to the above declarations'; \ |
|---|
| 498 |
exit 1; } || : |
|---|
| 499 |
|
|---|
| 500 |
# Update the hash stored above. Do this after each release and |
|---|
| 501 |
# for any corrections to old entries. |
|---|
| 502 |
update-NEWS-hash: NEWS |
|---|
| 503 |
perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \ |
|---|
| 504 |
$(srcdir)/cfg.mk |
|---|
| 505 |
|
|---|
| 506 |
epoch_date = 1970-01-01 00:00:00.000000000 +0000 |
|---|
| 507 |
# Ensure that the c99-to-c89 patch applies cleanly. |
|---|
| 508 |
patch-check: |
|---|
| 509 |
rm -rf src-c89 $@.1 $@.2 |
|---|
| 510 |
cp -a src src-c89 |
|---|
| 511 |
(cd src-c89; patch -p1 -V never --fuzz=0) < src/c99-to-c89.diff \ |
|---|
| 512 |
> $@.1 2>&1 |
|---|
| 513 |
if test "$(REGEN_PATCH)" = yes; then \ |
|---|
| 514 |
diff -upr src src-c89 | sed 's,src-c89/,src/,' \ |
|---|
| 515 |
| grep -vE '^(Only in|File )' \ |
|---|
| 516 |
| perl -pe 's/^((?:\+\+\+|---) \S+\t).*/$${1}$(epoch_date)/;' \ |
|---|
| 517 |
-e 's/^ $$//' \ |
|---|
| 518 |
> new-diff || : ; fi |
|---|
| 519 |
grep -v '^patching file ' $@.1 > $@.2 || : |
|---|
| 520 |
msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \ |
|---|
| 521 |
rm -f src-c89/*.o || msg='rm failed'; \ |
|---|
| 522 |
$(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \ |
|---|
| 523 |
|| msg='compile failure with extra options'; \ |
|---|
| 524 |
test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \ |
|---|
| 525 |
test "$$msg" = ok |
|---|
| 526 |
|
|---|
| 527 |
# Ensure that date's --help output stays in sync with the info |
|---|
| 528 |
# documentation for GNU strftime. The only exception is %N, |
|---|
| 529 |
# which date accepts but GNU strftime does not. |
|---|
| 530 |
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/' |
|---|
| 531 |
strftime-check: |
|---|
| 532 |
if test -f $(srcdir)/src/date.c; then \ |
|---|
| 533 |
grep '^ %. ' $(srcdir)/src/date.c | sort \ |
|---|
| 534 |
| $(extract_char) > $@-src; \ |
|---|
| 535 |
{ echo N; \ |
|---|
| 536 |
info libc date calendar format | grep '^ `%.'\' \ |
|---|
| 537 |
| $(extract_char); } | sort > $@-info; \ |
|---|
| 538 |
diff -u $@-src $@-info || exit 1; \ |
|---|
| 539 |
rm -f $@-src $@-info; \ |
|---|
| 540 |
fi |
|---|
| 541 |
|
|---|
| 542 |
check-AUTHORS: |
|---|
| 543 |
$(MAKE) -C src $@ |
|---|
| 544 |
|
|---|
| 545 |
# Ensure that we use only the standard $(VAR) notation, |
|---|
| 546 |
# not @...@ in Makefile.am, now that we can rely on automake |
|---|
| 547 |
# to emit a definition for each substituted variable. |
|---|
| 548 |
makefile-check: |
|---|
| 549 |
@grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \ |
|---|
| 550 |
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : |
|---|
| 551 |
|
|---|
| 552 |
news-date-check: NEWS |
|---|
| 553 |
today=`date +%Y-%m-%d`; \ |
|---|
| 554 |
if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \ |
|---|
| 555 |
>/dev/null; then \ |
|---|
| 556 |
:; \ |
|---|
| 557 |
else \ |
|---|
| 558 |
echo "version or today's date is not in NEWS" 1>&2; \ |
|---|
| 559 |
exit 1; \ |
|---|
| 560 |
fi |
|---|
| 561 |
|
|---|
| 562 |
changelog-check: |
|---|
| 563 |
if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \ |
|---|
| 564 |
>/dev/null; then \ |
|---|
| 565 |
:; \ |
|---|
| 566 |
else \ |
|---|
| 567 |
echo "$(VERSION) not in ChangeLog" 1>&2; \ |
|---|
| 568 |
exit 1; \ |
|---|
| 569 |
fi |
|---|
| 570 |
|
|---|
| 571 |
m4-check: |
|---|
| 572 |
@grep -n 'AC_DEFUN([^[]' m4/*.m4 \ |
|---|
| 573 |
&& { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \ |
|---|
| 574 |
exit 1; } || : |
|---|
| 575 |
|
|---|
| 576 |
# Verify that all source files using _() are listed in po/POTFILES.in. |
|---|
| 577 |
po-check: |
|---|
| 578 |
@if test -f po/POTFILES.in; then \ |
|---|
| 579 |
grep -E -v '^(#|$$)' po/POTFILES.in \ |
|---|
| 580 |
| grep -v '^src/false\.c$$' | sort > $@-1; \ |
|---|
| 581 |
files=; \ |
|---|
| 582 |
for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \ |
|---|
| 583 |
case $$file in \ |
|---|
| 584 |
*.?|*.??) ;; \ |
|---|
| 585 |
*) continue;; \ |
|---|
| 586 |
esac; \ |
|---|
| 587 |
case $$file in \ |
|---|
| 588 |
*.[ch]) \ |
|---|
| 589 |
base=`expr " $$file" : ' \(.*\)\..'`; \ |
|---|
| 590 |
{ test -f $$base.l || test -f $$base.y; } && continue;; \ |
|---|
| 591 |
esac; \ |
|---|
| 592 |
files="$$files $$file"; \ |
|---|
| 593 |
done; \ |
|---|
| 594 |
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \ |
|---|
| 595 |
| sort -u > $@-2; \ |
|---|
| 596 |
diff -u $@-1 $@-2 || exit 1; \ |
|---|
| 597 |
rm -f $@-1 $@-2; \ |
|---|
| 598 |
fi |
|---|
| 599 |
|
|---|
| 600 |
# In a definition of #define AUTHORS "... and ..." where the RHS contains |
|---|
| 601 |
# the English word `and', the string must be marked with `N_ (...)' so that |
|---|
| 602 |
# gettext recognizes it as a string requiring translation. |
|---|
| 603 |
author_mark_check: |
|---|
| 604 |
@grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \ |
|---|
| 605 |
{ echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \ |
|---|
| 606 |
exit 1; } || : |
|---|
| 607 |
|
|---|
| 608 |
# Sometimes it is useful to change the PATH environment variable |
|---|
| 609 |
# in Makefiles. When doing so, it's better not to use the Unix-centric |
|---|
| 610 |
# path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'. |
|---|
| 611 |
# It'd be better to use `find -print0 ...|xargs -0 ...', but less portable, |
|---|
| 612 |
# and there probably aren't many projects with so many Makefile.am files |
|---|
| 613 |
# that we'd have to worry about limits on command line length. |
|---|
| 614 |
msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead' |
|---|
| 615 |
makefile_path_separator_check: |
|---|
| 616 |
@grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \ |
|---|
| 617 |
&& { echo $(msg) 1>&2; exit 1; } || : |
|---|
| 618 |
|
|---|
| 619 |
# Check that `make alpha' will not fail at the end of the process. |
|---|
| 620 |
writable-files: |
|---|
| 621 |
if test -d $(release_archive_dir); then :; else \ |
|---|
| 622 |
for file in $(distdir).tar.gz \ |
|---|
| 623 |
$(release_archive_dir)/$(distdir).tar.gz; do \ |
|---|
| 624 |
test -e $$file || continue; \ |
|---|
| 625 |
test -w $$file \ |
|---|
| 626 |
|| { echo ERROR: $$file is not writable; fail=1; }; \ |
|---|
| 627 |
done; \ |
|---|
| 628 |
test "$$fail" && exit 1 || : ; \ |
|---|
| 629 |
fi |
|---|
| 630 |
|
|---|
| 631 |
v_etc_file = lib/version-etc.c |
|---|
| 632 |
sample-test = tests/sample-test |
|---|
| 633 |
texi = doc/$(PACKAGE).texi |
|---|
| 634 |
# Make sure that the copyright date in $(v_etc_file) is up to date. |
|---|
| 635 |
# Do the same for the $(sample-test) and the main doc/.texi file. |
|---|
| 636 |
copyright-check: |
|---|
| 637 |
@if test -f $(v_etc_file); then \ |
|---|
| 638 |
grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \ |
|---|
| 639 |
>/dev/null \ |
|---|
| 640 |
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \ |
|---|
| 641 |
exit 1; }; \ |
|---|
| 642 |
fi |
|---|
| 643 |
@if test -f $(sample-test); then \ |
|---|
| 644 |
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \ |
|---|
| 645 |
>/dev/null \ |
|---|
| 646 |
|| { echo 'out of date copyright in $(sample-test); update it' 1>&2; \ |
|---|
| 647 |
exit 1; }; \ |
|---|
| 648 |
fi |
|---|
| 649 |
@if test -f $(texi); then \ |
|---|
| 650 |
grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \ |
|---|
| 651 |
>/dev/null \ |
|---|
| 652 |
|| { echo 'out of date copyright in $(texi); update it' 1>&2; \ |
|---|
| 653 |
exit 1; }; \ |
|---|
| 654 |
fi |
|---|
| 655 |
|
|---|
| 656 |
vc-diff-check: |
|---|
| 657 |
$(VC) diff > vc-diffs || : |
|---|
| 658 |
if test -s vc-diffs; then \ |
|---|
| 659 |
cat vc-diffs; \ |
|---|
| 660 |
echo "Some files are locally modified:" 1>&2; \ |
|---|
| 661 |
exit 1; \ |
|---|
| 662 |
else \ |
|---|
| 663 |
rm vc-diffs; \ |
|---|
| 664 |
fi |
|---|
| 665 |
|
|---|
| 666 |
cvs-check: vc-diff-check |
|---|
| 667 |
|
|---|
| 668 |
maintainer-distcheck: |
|---|
| 669 |
$(MAKE) distcheck |
|---|
| 670 |
$(MAKE) taint-distcheck |
|---|
| 671 |
$(MAKE) my-distcheck |
|---|
| 672 |
|
|---|
| 673 |
|
|---|
| 674 |
# Don't make a distribution if checks fail. |
|---|
| 675 |
# Also, make sure the NEWS file is up-to-date. |
|---|
| 676 |
vc-dist: $(local-check) cvs-check maintainer-distcheck |
|---|
| 677 |
$(MAKE) dist |
|---|
| 678 |
|
|---|
| 679 |
# Use this to make sure we don't run these programs when building |
|---|
| 680 |
# from a virgin tgz file, below. |
|---|
| 681 |
null_AM_MAKEFLAGS = \ |
|---|
| 682 |
ACLOCAL=false \ |
|---|
| 683 |
AUTOCONF=false \ |
|---|
| 684 |
AUTOMAKE=false \ |
|---|
| 685 |
AUTOHEADER=false \ |
|---|
| 686 |
MAKEINFO=false |
|---|
| 687 |
|
|---|
| 688 |
built_programs = \ |
|---|
| 689 |
$$(cd src && echo '_spy:;@echo $$(sbin_PROGRAMS)' \ |
|---|
| 690 |
| MAKEFLAGS= $(MAKE) -s make -f Makefile -f - _spy) |
|---|
| 691 |
|
|---|
| 692 |
|
|---|