unistd: Fix portability warnings.
[gnulib.git] / Makefile
blob6dee9294557d93aa0cbaa3adf98c7fde0447df3a
1 # GNU Makefile for gnulib central.
2 # Copyright (C) 2006, 2009-2020 Free Software Foundation, Inc.
4 # Copying and distribution of this file, with or without modification,
5 # in any medium, are permitted without royalty provided the copyright
6 # notice and this notice are preserved.
8 # This Makefile requires the use of GNU make. Some targets require
9 # that you have tools like git, makeinfo and cppi installed.
11 # Required for the use of <(...) below.
12 SHELL=bash
14 # Produce some files that are not stored in the repository.
15 all:
17 # Produce the documentation in readable form.
18 info html dvi pdf:
19 cd doc && $(MAKE) $@ && $(MAKE) mostlyclean
21 # Collect the names of rules starting with 'sc_'.
22 syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p'\
23 Makefile))
25 # Perform some platform independent checks on the gnulib code.
26 check: $(syntax-check-rules)
28 sc_prefer_ac_check_funcs_once:
29 @if test -d .git; then \
30 git grep -w -l AC_CHECK_FUNCS modules \
31 && { echo use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS \
32 in modules/ 1>&2; exit 1; } || : \
33 else :; fi
35 sc_prohibit_leading_TABs:
36 @if test -d .git; then \
37 git grep -l '^ * ' lib m4 tests \
38 | grep -Ev '^lib/reg|Makefile|test-update-copyright' \
39 | grep . \
40 && { printf '*** %s\n' 'indent with spaces, not TABs;' \
41 1>&2; exit 1; } || : \
42 else :; fi
44 sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT:
45 @if test -d .git; then \
46 url=https://lists.gnu.org/r/bug-gnulib/2010-09/msg00064.html; \
47 git grep '^[ ]*TESTS_ENVIRONMENT += PATH=' modules \
48 && { printf '%s\n' 'Do not augment PATH via TESTS_ENVIRONMENT;' \
49 " see <$$url>" 1>&2; exit 1; } || : \
50 else :; fi
52 # It's easy to forget the noise-suppressing "@" at the beginning
53 # of each sc_ rule. Check for it both in maint.mk and in this file.
54 sc_prohibit_sc_omitted_at:
55 @if test -d .git; then \
56 git grep -n -A1 '^sc_[[:alnum:]_-]*:' top/maint.mk Makefile \
57 | grep -vE ':sc_|[0-9][-] @|--$$' \
58 | sed 's/-\([0-9][0-9]*\)-/:\1:/' \
59 | grep . \
60 && { printf '*** %s\n' 'oops; missing "@"' \
61 1>&2; exit 1; } || : \
62 else :; fi
64 # Run all maint.mk syntax-check tests on gnulib's sources.
65 sc_maint:
66 @rm -f maint.mk; ln -s top/maint.mk maint.mk
67 $(MAKE) -s srcdir=. gnulib_dir=. _build-aux=build-aux \
68 -f cfg.mk -f maint.mk syntax-check
69 rm -f maint.mk
71 # Files in m4/ that (exceptionally) may use AC_LIBOBJ.
72 # Do not include their ".m4" suffix.
73 allow_AC_LIBOBJ = \
74 close \
75 dprintf \
76 dup2 \
77 faccessat \
78 fchdir \
79 fclose \
80 fcntl \
81 fprintf-posix \
82 open \
83 printf-posix-rpl \
84 snprintf \
85 sprintf-posix \
86 stdio_h \
87 vasnprintf \
88 vasprintf \
89 vdprintf \
90 vfprintf-posix \
91 vprintf-posix \
92 vsnprintf \
93 vsprintf-posix
95 allow_AC_LIBOBJ_or := $(shell echo $(allow_AC_LIBOBJ) | tr -s ' ' '|')
97 sc_prohibit_AC_LIBOBJ_in_m4:
98 @url=https://lists.gnu.org/r/bug-gnulib/2011-06/msg00051.html; \
99 if test -d .git; then \
100 git ls-files m4 \
101 | grep -Ev '^m4/($(allow_AC_LIBOBJ_or))\.m4$$' \
102 | xargs grep '^ *AC_LIBOBJ(' \
103 && { printf '%s\n' 'Do not use AC_LIBOBJ in m4/*.m4;' \
104 "see <$$url>"; exit 1; } || :; \
105 else :; fi
107 sc_pragma_columns:
108 @if test -d .git; then \
109 git ls-files|grep '\.in\.h$$' \
110 | xargs grep -l '^@PRAGMA_SYSTEM_HEADER@' \
111 | xargs grep -L '^@PRAGMA_COLUMNS@' \
112 | grep . \
113 && { printf '%s\n' \
114 'the files listed above use @PRAGMA_SYSTEM_HEADER@' \
115 'without also using @PRAGMA_COLUMNS@' 1>&2; \
116 exit 1; } || :; \
117 else :; fi
119 # Verify that certain (for now, only Jim Meyering and Eric Blake's)
120 # *.c files are consistently cpp indented.
121 sc_cpp_indent_check:
122 @./gnulib-tool --extract-filelist \
123 $$(cd ./modules; grep -ilrE '(meyering|blake)' .) \
124 | sort -u \
125 | grep '\.c$$' \
126 | grep -vE '/(stdio-(read|write)|getloadavg)\.c$$' \
127 | xargs cppi -c
129 # Ensure that the list of symbols checked for by the
130 # sc_prohibit_intprops_without_use rule match those in the actual file.
131 # Extract the symbols from the .h file and compare with the list of
132 # symbols extracted from the rule in maint.mk.
133 sc_check_sym_list:
134 @i=lib/intprops.h; \
135 diff -u <(perl -lne '/^# *define ([A-Z]\w+)\(/ and print $$1' $$i|fmt) \
136 <(sed -n /^_intprops_name/,/^_intprops_syms_re/p top/maint.mk \
137 |sed '/^_/d;s/^ //;s/ *\\$$//')
139 # Ensure that the copyright statements in files and in the module descriptions
140 # are consistent.
141 sc_check_copyright:
142 @./check-copyright
144 # Regenerate some files that are stored in the repository.
145 regen: MODULES.html
147 # MODULES.html is periodically being generated and copied to the web pages at
148 # :ext:USER@cvs.savannah.gnu.org:/web/gnulib/gnulib/
149 # where it then appears at <https://www.gnu.org/software/gnulib/MODULES.html>.
150 MODULES.html: MODULES.html.sh
151 ./MODULES.html.sh > MODULES.html
153 # A perl BEGIN block to set Y to the current year number and W to Y-1.
154 _year_and_prev = BEGIN{@t=localtime(time); $$y=$$t[5]+1900; $$w=$$y-1}
156 # Run this rule once per year (usually early in January)
157 # to update all FSF copyright year lists here.
158 # We exclude the files listed in srclist.txt (maintained elsewhere)
159 # as well as those in tests/unictype (generated).
160 # Also exclude any file that includes the "GENERATED AUTOMATICALLY" comment,
161 # being careful not to exclude code that merely generates the comment.
162 # Also exclude doc/INSTALL*, since they too are generated.
163 # Also adjust template-style files that must start with a single
164 # (the current) year number in some places.
165 # Also adjust version-etc.c and and gendocs.sh.
166 update-copyright:
167 exempt=$$(mktemp); \
168 grep -v '^#' config/srclist.txt|grep -v '^$$' \
169 | while read top src dst options; do \
170 test -f "$$dst" && { echo "$$dst"; continue; }; \
171 test -d "$$dst" || continue; \
172 echo "$$dst"/$$(basename "$$src"); \
173 done > $$exempt; \
174 git ls-files tests/unictype >> $$exempt; \
175 git ls-files doc/INSTALL* >> $$exempt; \
176 git ls-files | grep -vFf $$exempt \
177 | xargs grep -L '^/\*.*GENERATED AUTOMATICALLY' \
178 | UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 \
179 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
180 xargs build-aux/update-copyright
181 perl -pi -e '$(_year_and_prev) s/(copyright.*)\b$$w\b/$$1$$y/i' \
182 lib/version-etc.c doc/gnulib.texi build-aux/gendocs.sh
183 perl -pi -e '$(_year_and_prev) s/ $$w-$$y / $$y /g' \
184 doc/gendocs_template* build-aux/gendocs.sh
185 perl -pi -e \
186 '$(_year_and_prev) s/^(scriptversion=)$$w.*/$$1$$y-01-01.00/i' \
187 build-aux/gendocs.sh