1 # GNU Makefile for gnulib central.
2 # Copyright (C) 2006, 2009-2024 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.
14 # Produce some files that are not stored in the repository.
17 # Produce the documentation in readable form.
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'\
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; } ||
: \
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' \
40 && { printf
'*** %s\n' 'indent with spaces, not TABs;' \
41 1>&2; exit
1; } ||
: \
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; } ||
: \
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:/' \
60 && { printf
'*** %s\n' 'oops; missing "@"' \
61 1>&2; exit
1; } ||
: \
64 # Run all maint.mk syntax-check tests on gnulib's sources.
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
71 # Files in m4/ that (exceptionally) may use AC_LIBOBJ.
72 # Do not include their ".m4" suffix.
97 allow_AC_LIBOBJ_or
:= $(shell echo
$(allow_AC_LIBOBJ
) | tr
-s
' ' '|')
99 sc_prohibit_AC_LIBOBJ_in_m4
:
100 @url
=https
://lists.gnu.org
/r
/bug-gnulib
/2011-06/msg00051.html
; \
101 if
test -d .git
; then \
103 | grep
-Ev
'^m4/($(allow_AC_LIBOBJ_or))\.m4$$' \
104 | xargs grep
'^ *AC_LIBOBJ(' \
105 && { printf
'%s\n' 'Do not use AC_LIBOBJ in m4/*.m4;' \
106 "see <$$url>"; exit
1; } ||
:; \
110 @if
test -d .git
; then \
111 git ls-files|grep
'\.in\.h$$' \
112 | xargs grep
-l
'^@PRAGMA_SYSTEM_HEADER@' \
113 | xargs grep
-L
'^@PRAGMA_COLUMNS@' \
116 'the files listed above use @PRAGMA_SYSTEM_HEADER@' \
117 'without also using @PRAGMA_COLUMNS@' 1>&2; \
121 # Verify that certain (for now, only Jim Meyering and Eric Blake's)
122 # *.c files are consistently cpp indented.
124 @.
/gnulib-tool
--extract-filelist \
125 $$(cd .
/modules
; grep
-ilrE
'(meyering|blake)' .
) \
128 | grep
-vE
'/(stdio-(read|write)|getloadavg)\.c$$' \
131 # Ensure that the list of symbols checked for by the
132 # sc_prohibit_intprops_without_use rule match those in the actual file.
133 # Extract the symbols from the .h file and compare with the list of
134 # symbols extracted from the rule in maint.mk.
137 diff
-u
<(perl
-lne
'/^# *define ([A-Z]\w+)\(/ and print $$1' $$i|fmt
) \
138 <(sed
-n
/^_intprops_name
/,/^_intprops_syms_re
/p top
/maint.mk \
139 |sed
'/^_/d;s/^ //;s/ *\\$$//')
142 # List of C macros defined through AH_VERBATIM in m4/extern-inline.m4:
146 _GL_INLINE_HEADER_BEGIN \
147 _GL_INLINE_HEADER_END
148 # List of C macros defined through AH_VERBATIM in m4/gnulib-common.m4:
152 _GL_ATTRIBUTE_ALLOC_SIZE \
153 _GL_ATTRIBUTE_ALWAYS_INLINE \
154 _GL_ATTRIBUTE_ARTIFICIAL \
156 _GL_ATTRIBUTE_CONST \
157 _GL_ATTRIBUTE_DEALLOC \
158 _GL_ATTRIBUTE_DEPRECATED \
159 _GL_ATTRIBUTE_ERROR \
160 _GL_ATTRIBUTE_WARNING \
161 _GL_ATTRIBUTE_EXTERNALLY_VISIBLE \
162 _GL_ATTRIBUTE_FALLTHROUGH \
163 _GL_ATTRIBUTE_FORMAT \
165 _GL_ATTRIBUTE_MALLOC \
166 _GL_ATTRIBUTE_MAY_ALIAS \
167 _GL_ATTRIBUTE_MAYBE_UNUSED \
169 _GL_ATTRIBUTE_NODISCARD \
170 _GL_ATTRIBUTE_NOINLINE \
171 _GL_ATTRIBUTE_NONNULL \
172 _GL_ATTRIBUTE_NONSTRING \
173 _GL_ATTRIBUTE_NOTHROW \
174 _GL_ATTRIBUTE_PACKED \
176 _GL_ATTRIBUTE_RETURNS_NONNULL \
177 _GL_ATTRIBUTE_SENTINEL \
178 _GL_ATTRIBUTE_UNUSED \
180 _GL_BEGIN_C_LINKAGE \
184 # List of C macros defined through AH_VERBATIM in m4/nullptr.m4:
187 # List of C macros defined through AH_VERBATIM in m4/posixcheck.m4:
190 # List of C macros defined through AH_VERBATIM in m4/sh-filename.m4:
193 # List of C macros defined through AH_VERBATIM in m4/stdalign.m4:
197 # List of C macros defined through AH_VERBATIM in m4/stdarg.m4:
200 # List of C macros defined through AH_VERBATIM in m4/threads_h.m4:
203 # List of C macros defined through AH_VERBATIM (only the most important ones):
205 $(config_h_MACROS1
) $(config_h_MACROS2
) $(config_h_MACROS3
) \
206 $(config_h_MACROS4
) $(config_h_MACROS5
) $(config_h_MACROS6
) \
207 $(config_h_MACROS7
) $(config_h_MACROS8
)
209 # Ensure that .h files that use macros from config.h contain a reminder to
210 # include <config.h>.
211 sc_check_config_h_reminder
:
213 for file in
`grep -l -F -w -f <(for macro in $(config_h_MACROS); do echo $$macro; done) lib/*.h lib/*/*.h`; do \
214 : "Filter out .h files that are not public header files of their respective module."; \
215 include_pattern
='[<"]'`echo $$file | sed -e 's,^lib/,,' -e 's,[.]in[.]h,.h,' -e 's,_,[/_],g' -e 's,[.],[.],g'`'[>"]' ; \
216 if .
/gnulib-tool
--extract-include-directive
`./gnulib-tool --find $$file` | grep
"$$include_pattern" >/dev
/null
; then \
217 grep
'# *error "Please include config[.]h first[.]"' $$file >/dev
/null \
218 ||
{ echo
-n
"File $$file lacks a config.h reminder. Needed for:"; \
219 for macro in
$(config_h_MACROS
); do \
220 if grep
-F
-w
$$macro $$file >/dev
/null
; then echo
-n
" $$macro"; fi
; \
222 if grep
-F HAVE_RAW_DECL_
$$file >/dev
/null
; then echo
-n
" HAVE_RAW_DECL_*"; fi
; \
231 # Ensure that .h files that invoke _GL_INLINE_HEADER_BEGIN also invoke
232 # _GL_INLINE_HEADER_END. Otherwise, some GCC diagnostics remain turned off
233 # for the rest of the compilation unit.
234 sc_check_GL_INLINE_HEADER_use
:
236 for file in
`grep -l -F -w _GL_INLINE_HEADER_BEGIN lib/*.h lib/*/*.h`; do \
237 grep
-l
-F
-w _GL_INLINE_HEADER_END
$$file >/dev
/null \
238 ||
{ echo
"File $$file lacks an invocation of _GL_INLINE_HEADER_END."; \
244 # Ensure that the copyright statements in files and in the module descriptions
249 # Regenerate some files that are stored in the repository.
250 regen
: build-aux
/bootstrap MODULES.html
252 # build-aux/bootstrap needs to be regenerated from top/bootstrap*.
253 build-aux
/bootstrap
: top
/gen-bootstrap.sed top
/bootstrap top
/bootstrap-funclib.sh
254 sed
-f top
/gen-bootstrap.sed
< top
/bootstrap
> build-aux
/bootstrap-tmp
255 chmod a
+x build-aux
/bootstrap-tmp
256 mv build-aux
/bootstrap-tmp build-aux
/bootstrap
258 # MODULES.html is periodically being generated and copied to the web pages at
259 # :ext:USER@cvs.savannah.gnu.org:/web/gnulib/gnulib/
260 # where it then appears at <https://www.gnu.org/software/gnulib/MODULES.html>.
261 MODULES.html
: MODULES.html.sh
262 .
/MODULES.html.sh
> MODULES.html
264 # A perl BEGIN block to set Y to the current year number and W to Y-1.
265 _year_and_prev
= BEGIN
{@t
=localtime
(time
); $$y=$$t[5]+1900; $$w=$$y-1}
267 # Which TZ setting to use when updating copyright.
270 # Run this rule once per year (usually early in January)
271 # to update all FSF copyright year lists here.
272 # We exclude the files listed in srclist.txt (maintained elsewhere)
273 # as well as those in tests/unictype (generated).
274 # Also exclude any file that includes the "GENERATED AUTOMATICALLY" comment,
275 # being careful not to exclude code that merely generates the comment.
276 # Also exclude doc/INSTALL*, since they too are generated.
277 # Also adjust template-style files that must start with a single
278 # (the current) year number in some places.
279 # Also adjust version-etc.c and gendocs.sh.
281 export TZ
='$(COPYRIGHT_TZ)'; \
283 grep
-v
'^#' config
/srclist.txt|grep
-v
'^$$' \
284 | while read top src dst options
; do \
285 test -f
"$$dst" && { echo
"$$dst"; continue
; }; \
286 test -d
"$$dst" || continue
; \
287 echo
"$$dst"/$$(basename "$$src"); \
289 git ls-files doc
/INSTALL
* >> $$exempt; \
290 for file in
$$(git ls-files
); do \
291 test ! -h
$$file || echo
$$file; \
293 git ls-files | grep
-vFf
$$exempt \
294 | xargs grep
-L
'^/\*.*GENERATED AUTOMATICALLY' \
295 | UPDATE_COPYRIGHT_MAX_LINE_LENGTH
=79 \
296 UPDATE_COPYRIGHT_USE_INTERVALS
=1 \
297 xargs build-aux
/update-copyright
298 export TZ
='$(COPYRIGHT_TZ)'; \
299 perl
-pi
-e
'$(_year_and_prev) s/(copyright.*)\b$$w\b/$$1$$y/i' \
300 lib
/version-etc.c doc
/gnulib.texi build-aux
/gendocs.sh
301 export TZ
='$(COPYRIGHT_TZ)'; \
302 perl
-pi
-e
'$(_year_and_prev) s/ $$w-$$y / $$y /g' \
303 doc
/gendocs_template
* build-aux
/gendocs.sh
304 export TZ
='$(COPYRIGHT_TZ)'; \
306 '$(_year_and_prev) s/^(scriptversion=)$$w.*/$$1$$y-01-01.00/i' \