summaryrefslogtreecommitdiff
path: root/Makefile
blob: bea6cabf2a416dffcf87e6a2fcf09ce48e8d0b12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# GNU Makefile for gnulib central.
# Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.

# This Makefile requires the use of GNU make.  Some targets require
# that you have tools like git, makeinfo and cppi installed.

# Required for the use of <(...) below.
SHELL=bash

# Produce some files that are not stored in the repository.
all:

# Produce the documentation in readable form.
info html dvi pdf:
	cd doc && $(MAKE) $@ && $(MAKE) mostlyclean

# Collect the names of rules starting with 'sc_'.
syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p'\
			Makefile))

# Perform some platform independent checks on the gnulib code.
check: $(syntax-check-rules)

sc_prefer_ac_check_funcs_once:
	@if test -d .git; then						\
	  git grep -w -l AC_CHECK_FUNCS modules				\
	    && { echo use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS	\
		   in modules/ 1>&2; exit 1; } || :			\
	else :; fi

sc_prohibit_leading_TABs:
	@if test -d .git; then						\
	  git grep -l '^ *	' lib m4 tests				\
	    | grep -Ev '^lib/reg|Makefile|test-update-copyright'	\
	    | grep .							\
	    && { printf '*** %s\n' 'indent with spaces, not TABs;'	\
		 1>&2; exit 1; } || :					\
	else :; fi

sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT:
	@if test -d .git; then						\
	  url=https://lists.gnu.org/r/bug-gnulib/2010-09/msg00064.html; \
	  git grep '^[	 ]*TESTS_ENVIRONMENT += PATH=' modules		\
	    && { printf '%s\n' 'Do not augment PATH via TESTS_ENVIRONMENT;' \
		 "  see <$$url>" 1>&2; exit 1; } || :			\
	else :; fi

# It's easy to forget the noise-suppressing "@" at the beginning
# of each sc_ rule.  Check for it both in maint.mk and in this file.
sc_prohibit_sc_omitted_at:
	@if test -d .git; then						\
	  git grep -n -A1 '^sc_[[:alnum:]_-]*:' top/maint.mk Makefile	\
            | grep -vE ':sc_|[0-9][-]	@|--$$'				\
            | sed 's/-\([0-9][0-9]*\)-/:\1:/'				\
	    | grep .							\
	    && { printf '*** %s\n' 'oops; missing "@"'			\
		 1>&2; exit 1; } || :					\
	else :; fi

# Run all maint.mk syntax-check tests on gnulib's sources.
sc_maint:
	@rm -f maint.mk; ln -s top/maint.mk maint.mk
	$(MAKE) -s srcdir=. gnulib_dir=. _build-aux=build-aux \
            -f cfg.mk -f maint.mk syntax-check
	rm -f maint.mk

# Files in m4/ that (exceptionally) may use AC_LIBOBJ.
# Do not include their ".m4" suffix.
allow_AC_LIBOBJ =	\
  close			\
  dprintf		\
  dup2			\
  faccessat		\
  fchdir		\
  fclose		\
  fcntl			\
  fprintf-posix		\
  open			\
  printf-posix-rpl	\
  snprintf		\
  sprintf-posix		\
  stdio_h		\
  vasnprintf		\
  vasprintf		\
  vdprintf		\
  vfprintf-posix	\
  vprintf-posix		\
  vsnprintf		\
  vsprintf-posix

allow_AC_LIBOBJ_or := $(shell echo $(allow_AC_LIBOBJ) | tr -s ' ' '|')

sc_prohibit_AC_LIBOBJ_in_m4:
	@url=https://lists.gnu.org/r/bug-gnulib/2011-06/msg00051.html; \
	if test -d .git; then						\
	  git ls-files m4						\
	     | grep -Ev '^m4/($(allow_AC_LIBOBJ_or))\.m4$$'		\
	     | xargs grep '^ *AC_LIBOBJ('				\
	    && { printf '%s\n' 'Do not use AC_LIBOBJ in m4/*.m4;'	\
		 "see <$$url>"; exit 1; } || :;				\
	else :; fi

sc_pragma_columns:
	@if test -d .git; then						\
	  git ls-files|grep '\.in\.h$$'					\
	      | xargs grep -l '^@PRAGMA_SYSTEM_HEADER@'			\
	      | xargs grep -L '^@PRAGMA_COLUMNS@'			\
	      | grep .							\
	    && { printf '%s\n'						\
		   'the files listed above use @PRAGMA_SYSTEM_HEADER@'	\
		   'without also using @PRAGMA_COLUMNS@' 1>&2;		\
		 exit 1; } || :;					\
	else :; fi

# Verify that certain (for now, only Jim Meyering and Eric Blake's)
# *.c files are consistently cpp indented.
sc_cpp_indent_check:
	@./gnulib-tool --extract-filelist \
	    $$(cd ./modules; grep -ilrE '(meyering|blake)' .) \
	  | sort -u \
	  | grep '\.c$$' \
	  | grep -vE '/(stdio-(read|write)|getloadavg)\.c$$' \
	  | xargs cppi -c

# Ensure that the list of symbols checked for by the
# sc_prohibit_intprops_without_use rule match those in the actual file.
# Extract the symbols from the .h file and compare with the list of
# symbols extracted from the rule in maint.mk.
sc_check_sym_list:
	@i=lib/intprops.h; \
	diff -u <(perl -lne '/^# *define ([A-Z]\w+)\(/ and print $$1' $$i|fmt) \
	  <(sed -n /^_intprops_name/,/^_intprops_syms_re/p top/maint.mk \
	    |sed '/^_/d;s/^  //;s/	*\\$$//')

# Ensure that the copyright statements in files and in the module descriptions
# are consistent.
sc_check_copyright:
	@./check-copyright

# Regenerate some files that are stored in the repository.
regen: MODULES.html

# MODULES.html is periodically being generated and copied to the web pages at
# :ext:USER@cvs.savannah.gnu.org:/web/gnulib/gnulib/
# where it then appears at <https://www.gnu.org/software/gnulib/MODULES.html>.
MODULES.html: MODULES.html.sh
	./MODULES.html.sh > MODULES.html

# A perl BEGIN block to set Y to the current year number and W to Y-1.
_year_and_prev = BEGIN{@t=localtime(time); $$y=$$t[5]+1900; $$w=$$y-1}

# Run this rule once per year (usually early in January)
# to update all FSF copyright year lists here.
# We exclude the files listed in srclist.txt (maintained elsewhere)
# as well as those in tests/unictype (generated).
# Also exclude any file that includes the "GENERATED AUTOMATICALLY" comment,
# being careful not to exclude code that merely generates the comment.
# Also exclude doc/INSTALL*, since they too are generated.
# Also adjust template-style files that must start with a single
# (the current) year number in some places.
# Also adjust version-etc.c and and gendocs.sh.
update-copyright:
	exempt=$$(mktemp);						\
	grep -v '^#' config/srclist.txt|grep -v '^$$'			\
	  | while read top src dst options; do				\
	      test -f "$$dst" && { echo "$$dst"; continue; };		\
	      test -d "$$dst" || continue;				\
	      echo "$$dst"/$$(basename "$$src");			\
	    done > $$exempt;						\
	git ls-files tests/unictype >> $$exempt;			\
	git ls-files doc/INSTALL* >> $$exempt;				\
	git ls-files | grep -vFf $$exempt				\
	  | xargs grep -L '^/\*.*GENERATED AUTOMATICALLY'		\
	  | UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79				\
	    UPDATE_COPYRIGHT_USE_INTERVALS=1				\
	      xargs build-aux/update-copyright
	perl -pi -e '$(_year_and_prev) s/(copyright.*)\b$$w\b/$$1$$y/i'	\
	  lib/version-etc.c doc/gnulib.texi build-aux/gendocs.sh
	perl -pi -e '$(_year_and_prev) s/ $$w-$$y / $$y /g'		\
	  doc/gendocs_template* build-aux/gendocs.sh
	perl -pi -e							\
          '$(_year_and_prev) s/^(scriptversion=)$$w.*/$$1$$y-01-01.00/i' \
	  build-aux/gendocs.sh