~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to maint.mk

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
4
4
 
5
 
## Copyright (C) 2001-2011 Free Software Foundation, Inc.
 
5
## Copyright (C) 2001-2012 Free Software Foundation, Inc.
6
6
##
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))
22
22
ME := maint.mk
23
23
 
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.
 
25
# Remove in 2013
 
26
ifneq ($(build_aux),)
 
27
 $(error "$(ME): \
 
28
set $$(_build-aux) relative to $$(srcdir) instead of $$(build_aux)")
 
29
endif
 
30
 
 
31
# Helper variables.
 
32
_empty =
 
33
_sp = $(_empty) $(_empty)
 
34
 
 
35
# _equal,S1,S2
 
36
# ------------
 
37
# If S1 == S2, return S1, otherwise the empty string.
 
38
_equal = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
 
39
 
 
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.
 
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)))
26
52
 
27
53
# Do not save the original name or timestamp in the .tar.gz file.
28
54
# Use --rsyncable if available.
34
60
GIT = git
35
61
VC = $(GIT)
36
62
 
37
 
VC_LIST = $(build_aux)/vc-list-files -C $(srcdir)
 
63
VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir)
38
64
 
39
65
# You can override this variable in cfg.mk to set your own regexp
40
66
# matching files to ignore.
48
74
# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
49
75
# when $(srcdir) is not ".".
50
76
ifeq ($(srcdir),.)
51
 
_prepend_srcdir_prefix =
 
77
  _prepend_srcdir_prefix =
52
78
else
53
 
_prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
 
79
  _prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
54
80
endif
55
81
 
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.
59
85
_sc_excl = \
60
 
  $(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
 
86
  $(or $(exclude_file_name_regexp--$@),^$$)
61
87
VC_LIST_EXCEPT = \
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))
75
101
 
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)
79
105
else
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)
84
110
endif
85
111
my_distdir = $(PACKAGE)-$(VERSION)
86
112
 
87
113
# Old releases are stored here.
88
114
release_archive_dir ?= ../release
89
115
 
 
116
# If RELEASE_TYPE is undefined, but RELEASE is, use its second word.
 
117
# But overwrite VERSION.
 
118
ifdef RELEASE
 
119
  VERSION := $(word 1, $(RELEASE))
 
120
  RELEASE_TYPE ?= $(word 2, $(RELEASE))
 
121
endif
 
122
 
 
123
# Validate and return $(RELEASE_TYPE), or die.
 
124
RELEASE_TYPES = alpha beta stable
 
125
release-type = $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES))
 
126
 
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))
97
134
 
98
 
ifeq ($(gnu_rel_host),ftp.gnu.org)
99
 
url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE)
100
 
else
101
 
url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
102
 
endif
 
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))
103
138
 
104
139
# Override this in cfg.mk if you are using a different format in your
105
140
# NEWS file.
122
157
 
123
158
_cfg_mk := $(shell test -f $(srcdir)/cfg.mk && echo '$(srcdir)/cfg.mk')
124
159
 
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)
129
164
 
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)
132
167
else
133
 
local-checks-available += no-vc-detected
 
168
  local-checks-available += no-vc-detected
134
169
no-vc-detected:
135
170
        @echo "No version control files detected; skipping syntax check"
136
171
endif
174
209
#     Regular expression (ERE) denoting either a forbidden construct
175
210
#     or a required construct.  Those arguments are exclusive.
176
211
#
 
212
#  exclude
 
213
#
 
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.
 
218
#
177
219
#  in_vc_files | in_files
178
220
#
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
181
 
#     version control.
 
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.
182
226
#
183
227
#  containing | non_containing
184
228
#
208
252
# when filtering by name via in_files, we explicitly filter out matching
209
253
# names here as well.
210
254
 
 
255
# Initialize each, so that envvar settings cannot interfere.
 
256
export require =
 
257
export prohibit =
 
258
export exclude =
 
259
export in_vc_files =
 
260
export in_files =
 
261
export containing =
 
262
export non_containing =
 
263
export halt =
 
264
export with_grep_options =
 
265
 
211
266
# By default, _sc_search_regexp does not ignore case.
212
267
export ignore_case =
213
268
_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :)
217
272
   { printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; };
218
273
endef
219
274
 
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.
226
 
_prohibit_regexp = \
227
 
  $(error '*** you need to s/_prohibit_regexp/_sc_search_regexp/, and adapt')
228
 
 
229
275
define _sc_search_regexp
230
276
   dummy=; : so we do not need a semicolon before each use;             \
231
277
                                                                        \
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) } || :;                                   \
245
294
   : Filter by file name;                                               \
246
295
   if test -n "$$in_files"; then                                        \
247
296
     files=$$(find $(srcdir) | grep -E "$$in_files"                     \
248
 
              | grep -Ev '$(exclude_file_name_regexp--$@)');            \
 
297
              | grep -Ev '$(_sc_excl)');                                \
249
298
   else                                                                 \
250
299
     files=$$($(VC_LIST_EXCEPT));                                       \
251
300
     if test -n "$$in_vc_files"; then                                   \
263
312
   if test -n "$$files"; then                                           \
264
313
     if test -n "$$prohibit"; then                                      \
265
314
       grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
 
315
         | grep -vE "$${exclude:-^$$}"                                  \
266
316
         && { msg="$$halt" $(_sc_say_and_exit) } || :;                  \
267
317
     else                                                               \
268
318
       grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
274
324
endef
275
325
 
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;  \
281
331
            exit 1; } || :
282
332
 
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)
286
336
 
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)
291
341
 
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)
296
346
 
297
347
sc_space_tab:
299
349
        halt='found SPACE-TAB sequence; remove the SPACE'               \
300
350
          $(_sc_search_regexp)
301
351
 
302
 
# Don't use *scanf or the old ato* functions in `real' code.
 
352
# Don't use *scanf or the old ato* functions in "real" code.
303
353
# They provide no error checking mechanism.
304
354
# Instead, use strto* functions.
305
355
sc_prohibit_atoi_atof:
308
358
          $(_sc_search_regexp)
309
359
 
310
360
# Use STREQ rather than comparing strcmp == 0, or != 0.
 
361
sp_ = strcmp *\(.+\)
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' \
316
 
                1>&2; exit 1; } || :
 
363
        @prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)'         \
 
364
        exclude='# *define STRN?EQ\('                                   \
 
365
        halt='replace strcmp calls above with STREQ/STRNEQ'             \
 
366
          $(_sc_search_regexp)
 
367
 
 
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.
 
371
sc_prohibit_strncpy:
 
372
        @prohibit='\<strncpy *\('                                       \
 
373
        halt='do not use strncpy, period'                               \
 
374
          $(_sc_search_regexp)
317
375
 
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)
332
391
 
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)
340
399
 
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' &&                       \
438
497
 
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)
442
502
 
443
503
# Don't include this header unless you use one of its functions.
444
504
sc_prohibit_long_options_without_use:
507
567
 
508
568
sc_prohibit_hash_pjw_without_use:
509
569
        @h='hash-pjw.h' \
510
 
        re='\<hash_pjw *\(' \
 
570
        re='\<hash_pjw\>' \
511
571
          $(_sc_header_without_use)
512
572
 
513
573
sc_prohibit_safe_read_without_use:
521
581
 
522
582
sc_prohibit_canonicalize_without_use:
523
583
        @h='canonicalize.h' \
524
 
        re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode)' \
 
584
        re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode|file_name)' \
525
585
          $(_sc_header_without_use)
526
586
 
527
587
sc_prohibit_root_dev_ino_without_use:
541
601
        @h='c-ctype.h' re='\<c_($(ctype_re)) *\(' \
542
602
          $(_sc_header_without_use)
543
603
 
544
 
_empty =
545
 
_sp = $(_empty) $(_empty)
546
604
# The following list was generated by running:
547
605
# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
548
606
#   | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
618
676
# Prohibit the inclusion of stddef.h without an actual use.
619
677
sc_prohibit_stddef_without_use:
620
678
        @h='stddef.h'                                                   \
621
 
        re='\<($(_stddef_syms_re)) *\('                                 \
 
679
        re='\<($(_stddef_syms_re))\>'                                   \
 
680
          $(_sc_header_without_use)
 
681
 
 
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:
 
688
        @h='dirent.h'                                                   \
 
689
        re='\<($(_dirent_syms_re))\>'                                   \
622
690
          $(_sc_header_without_use)
623
691
 
624
692
# Prohibit the inclusion of verify.h without an actual use.
685
753
sc_trailing_blank:
686
754
        @prohibit='[     ]$$'                                           \
687
755
        halt='found trailing blank(s)'                                  \
 
756
        exclude='^Binary file .* matches$$'                             \
688
757
          $(_sc_search_regexp)
689
758
 
690
759
# Match lines like the following, but where there is only one space
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:
706
 
        @grep -nE                                                       \
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;            \
711
 
            exit 1; } || :
 
775
        @prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
 
776
        exclude='(_|ngettext ?)\('                                      \
 
777
        halt='found unmarked diagnostic(s)'                             \
 
778
          $(_sc_search_regexp)
712
779
 
713
780
# Avoid useless parentheses like those in this example:
714
781
# #if defined (SYMBOL) || defined (SYM2)
741
808
        '  with the corresponding gnulib module, they are always true') \
742
809
          $(_sc_search_regexp)
743
810
 
 
811
sc_prohibit_defined_have_decl_tests:
 
812
        @prohibit='#[    ]*if(n?def|.*\<defined)\>[      (]+HAVE_DECL_' \
 
813
        halt='HAVE_DECL macros are always defined'                      \
 
814
          $(_sc_search_regexp)
 
815
 
744
816
# ==================================================================
745
817
gl_other_headers_ ?= \
746
818
  intprops.h    \
749
821
 
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)$$/\
757
831
    and print $$1
758
832
 
762
836
        gen_h=$(gl_generated_headers_);                                 \
763
837
        (cd $(gnulib_dir)/lib;                                          \
764
838
          for f in *.in.h $(gl_other_headers_); do                      \
765
 
            perl -lne '$(gl_extract_significant_defines_)' $$f;         \
 
839
            test -f $$f                                                 \
 
840
              && perl -lne '$(gl_extract_significant_defines_)' $$f;    \
766
841
          done;                                                         \
767
842
        ) | sort -u                                                     \
768
843
          | sed 's/^/^ *# *(define|undef)  */;s/$$/\\>/'
830
905
#
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_ ?=                                    \
907
 
  /\bcan\s+not\b/gims
 
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)
967
1049
 
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'; \
972
 
              exit 1; } || :
 
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)
973
1055
 
974
1056
NEWS_hash =                                                             \
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; } || :
1016
1098
 
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             \
1020
1102
          :;                                                            \
1021
1103
        else                                                            \
1070
1152
 
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$$'                                    \
1078
1160
        halt=$(msg)                                                     \
1079
1161
          $(_sc_search_regexp)
1080
1162
 
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)
 
1165
# and is read-only.
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;                                 \
1087
 
            test -w $$file                                              \
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;                            \
 
1171
              test -w $$p$$file                                         \
 
1172
                || { echo ERROR: $$p$$file is not writable; fail=1; };  \
 
1173
            done;                                                       \
1089
1174
          done;                                                         \
1090
1175
          test "$$fail" && exit 1 || : ;                                \
 
1176
        else :;                                                         \
1091
1177
        fi
1092
1178
 
1093
1179
v_etc_file = $(gnulib_dir)/lib/version-etc.c
1136
1222
                1>&2; exit 1; } || :;                                   \
1137
1223
        fi
1138
1224
 
 
1225
# BRE regex of file contents to identify a test script.
 
1226
_test_script_regex ?= \<init\.sh\>
 
1227
 
 
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)
 
1234
 
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)
1156
1252
 
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)
1165
1261
 
 
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)
 
1270
 
1166
1271
vc-diff-check:
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;         \
1171
1276
          exit 1;                                               \
1181
1286
 
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.
1184
 
gpg_key_ID ?= \
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)
 
1289
gpg_key_ID ?=                                                           \
 
1290
  $$(cd $(srcdir)                                                       \
 
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}')
1188
1294
 
1189
1295
translation_project_ ?= coordinator@translationproject.org
1190
1296
 
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)
1198
 
else
1199
 
  announcement_Cc_ ?= $(translation_project_)
1200
 
  announcement_mail_headers_ ?=                                         \
1201
 
    To: $(PACKAGE_BUGREPORT)                                            \
1202
 
    Cc: $(announcement_Cc_)
1203
 
endif
1204
 
 
 
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)
 
1303
 
 
1304
announcement_Cc_alpha = $(translation_project_)
 
1305
announcement_mail_headers_alpha =               \
 
1306
  To: $(PACKAGE_BUGREPORT)                      \
 
1307
  Cc: $(announcement_Cc_)
 
1308
 
 
1309
announcement_mail_Cc_beta = $(announcement_mail_Cc_alpha)
 
1310
announcement_mail_headers_beta = $(announcement_mail_headers_alpha)
 
1311
 
 
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))
1218
1331
 
 
1332
.PHONY: release-commit
 
1333
release-commit:
 
1334
        $(AM_V_GEN)cd $(srcdir)                         \
 
1335
          && $(_build-aux)/do-release-commit-and-tag    \
 
1336
               -C $(abs_builddir) $(RELEASE)
 
1337
 
1219
1338
## ---------------- ##
1220
1339
## Updating files.  ##
1221
1340
## ---------------- ##
1224
1343
www-gnu = http://www.gnu.org
1225
1344
 
1226
1345
upload_dest_dir_ ?= $(PACKAGE)
 
1346
upload_command =                                                \
 
1347
  $(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS)             \
 
1348
  --to $(gnu_rel_host):$(upload_dest_dir_)                      \
 
1349
  $(rel-files)
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 =====================================
1236
1357
 
 
1358
.PHONY: upload
 
1359
upload:
 
1360
        $(AM_V_GEN)$(upload_command)
 
1361
 
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.'
1242
1367
endef
1243
1368
 
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)                      \
1249
1374
            || exit 1;                                                  \
1279
1404
gl_public_submodule_commit ?= public-submodule-commit
1280
1405
check: $(gl_public_submodule_commit)
1281
1406
 
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)
1285
 
        test $@ = stable                                                \
 
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;};}\
1288
1413
          || :
1289
 
        $(MAKE) vc-diff-check
1290
 
        $(MAKE) news-check
1291
 
        $(MAKE) distcheck
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=$@
 
1420
 
 
1421
release:
 
1422
        $(AM_V_GEN)$(MAKE) $(release-type)
1295
1423
 
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
1301
1429
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);                               \
1308
1435
        fi
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
1314
 
        rm .ci-msg
 
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"'        \
 
1440
          $(srcdir)/NEWS
 
1441
        $(AM_V_at)msg=$$($(emit-commit-log)) || exit 1;         \
 
1442
        cd $(srcdir) && $(VC) commit -m "$$msg" -a
1315
1443
 
1316
1444
# Override this with e.g., -s $(srcdir)/some_other_name.texi
1317
1445
# if the default $(PACKAGE)-derived name doesn't apply.
1319
1447
 
1320
1448
.PHONY: web-manual
1321
1449
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."
 
1458
 
 
1459
.PHONY: web-manual-update
 
1460
web-manual-update:
 
1461
        $(AM_V_GEN)cd $(srcdir) \
 
1462
          && $(_build-aux)/gnu-web-doc-update -C $(abs_builddir)
 
1463
 
1330
1464
 
1331
1465
# Code Coverage
1332
1466
 
1352
1486
 
1353
1487
coverage: init-coverage build-coverage gen-coverage
1354
1488
 
 
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:
 
1499
        gl=gl;                                                          \
 
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;                                      \
 
1504
        fi;                                                             \
 
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;                               \
 
1512
        done
 
1513
 
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
1367
1526
 
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)/$@
1391
1550
 
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.
1398
1557
 
1399
1558
ALL_RECURSIVE_TARGETS += sc_tight_scope
1400
1559
sc_tight_scope: tight-scope.mk
1401
 
        @if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk       \
 
1560
        @fail=0;                                                        \
 
1561
        if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk        \
1402
1562
                > /dev/null                                             \
1403
1563
           && ! grep -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
1404
1564
                > /dev/null 2>&1; then                                  \
1410
1570
                -f $(abs_top_builddir)/$<                               \
1411
1571
              _gl_tight_scope                                           \
1412
1572
                || fail=1;                                              \
1413
 
        fi
1414
 
        @rm -f $<
 
1573
        fi;                                                             \
 
1574
        rm -f $<;                                                       \
 
1575
        exit $$fail
1415
1576
 
1416
1577
tight-scope.mk: $(ME)
1417
1578
        @rm -f $@ $@-t
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 $@
1420
1581
 
1421
1582
ifeq (a,b)
1422
1583
# TS-start
1423
1584
 
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
1436
1597
 
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 ?=
1442
1603
 
1456
1617
# Files in which to search for the one-line style extern declarations.
1457
1618
# $(_gl_TS_dir)-relative.
1458
1619
_gl_TS_headers ?= $(noinst_HEADERS)
 
1620
_gl_TS_other_headers ?= *.h
1459
1621
 
1460
1622
.PHONY: _gl_tight_scope
1461
1623
_gl_tight_scope: $(bin_PROGRAMS)
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                                 \