Makefile: rely on GNU make; derive syntax-check rule names
[gnulib.git] / Makefile
1 # GNU Makefile for gnulib central.
2 # Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
3 #
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.
7
8 # This Makefile requires the use of GNU make.  Some targets require
9 # that you have tools like git, makeinfo and cppi installed.
10
11 # Produce some files that are not stored in the repository.
12 all:
13
14 # Produce the documentation in readable form.
15 info html dvi pdf:
16         cd doc && $(MAKE) $@ && $(MAKE) mostlyclean
17
18 # Collect the names of rules starting with `sc_'.
19 syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p'\
20                         Makefile))
21
22 # Perform some platform independent checks on the gnulib code.
23 check: $(syntax-check-rules)
24
25 sc_prefer_ac_check_funcs_once:
26         if test -d .git; then                                           \
27           git grep -w -l AC_CHECK_FUNCS modules                         \
28             && { echo use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS       \
29                    in modules/ 1>&2; exit 1; } || :                     \
30         else :; fi
31
32 sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT:
33         if test -d .git; then                                           \
34           url=http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/22874; \
35           git grep '^[   ]*TESTS_ENVIRONMENT += PATH=' modules          \
36             && { printf '%s\n' 'Do not augment PATH via TESTS_ENVIRONMENT;' \
37                  "  see <$$url>" 1>&2; exit 1; } || :                   \
38         else :; fi
39
40 sc_pragma_columns:
41         if test -d .git; then                                           \
42           git ls-files|grep '\.in\.h$$'                                 \
43               | xargs grep -l '^@PRAGMA_SYSTEM_HEADER@'                 \
44               | xargs grep -L '^@PRAGMA_COLUMNS@'                       \
45               | grep .                                                  \
46             && { printf '%s\n'                                          \
47                    'the files listed above use @PRAGMA_SYSTEM_HEADER@'  \
48                    'without also using @PRAGMA_COLUMNS@' 1>&2;          \
49                  exit 1; } || :;                                        \
50         else :; fi
51
52 # Verify that certain (for now, only Jim Meyering and Eric Blake's)
53 # *.c files are consistently cpp indented.
54 sc_cpp_indent_check:
55         ./gnulib-tool --extract-filelist \
56             $$(cd ./modules; grep -ilrE '(meyering|blake)' .) \
57           | sort -u \
58           | grep '\.c$$' \
59           | grep -v '/getloadavg\.c$$' \
60           | xargs cppi -c
61
62 # Regenerate some files that are stored in the repository.
63 regen: MODULES.html
64
65 # MODULES.html is periodically being generated and copied to the web pages at
66 # :ext:USER@cvs.savannah.gnu.org:/web/gnulib/gnulib/
67 # where it then appears at <http://www.gnu.org/software/gnulib/MODULES.html>.
68 MODULES.html: MODULES.html.sh
69         ./MODULES.html.sh > MODULES.html
70
71 # Run this rule once per year (usually early in January)
72 # to update all FSF copyright year lists here.
73 # We exclude the files listed in srclist.txt (maintained elsewhere)
74 # as well as those in tests/unictype (generated).
75 # Also exclude any file that includes the "GENERATED AUTOMATICALLY" comment,
76 # being careful not to exclude code that merely generates the comment.
77 # Also exclude doc/INSTALL*, since they too are generated.
78 update-copyright:
79         exempt=$$(mktemp);                                              \
80         grep -v '^#' config/srclist.txt|grep -v '^$$'                   \
81           | while read src dst; do                                      \
82               test -f "$$dst" && { echo "$$dst"; continue; };           \
83               test -d "$$dst" || continue;                              \
84               echo "$$dst"/$$(basename "$$src");                        \
85             done > $$exempt;                                            \
86         git ls-files tests/unictype >> $$exempt;                        \
87         git ls-files doc/INSTALL* >> $$exempt;                          \
88         git ls-files | grep -vFf $$exempt                               \
89           | xargs grep -L '^/\*.*GENERATED AUTOMATICALLY'               \
90           | UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79                         \
91             UPDATE_COPYRIGHT_USE_INTERVALS=1                            \
92               xargs build-aux/update-copyright