maint: update all copyright year number ranges
[gnulib.git] / Makefile
1 # GNU Makefile for gnulib central.
2 # Copyright (C) 2006, 2009-2012 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 # Required for the use of <(...) below.
12 SHELL=/bin/bash
13
14 # Produce some files that are not stored in the repository.
15 all:
16
17 # Produce the documentation in readable form.
18 info html dvi pdf:
19         cd doc && $(MAKE) $@ && $(MAKE) mostlyclean
20
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))
24
25 # Perform some platform independent checks on the gnulib code.
26 check: $(syntax-check-rules)
27
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
34
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
43
44 sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT:
45         if test -d .git; then                                           \
46           url=http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/22874; \
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
51
52 # Files in m4/ that (exceptionally) may use AC_LIBOBJ.
53 # Do not include their ".m4" suffix.
54 allow_AC_LIBOBJ =       \
55   close                 \
56   dprintf               \
57   dup2                  \
58   faccessat             \
59   fchdir                \
60   fclose                \
61   fcntl                 \
62   fprintf-posix         \
63   open                  \
64   printf-posix-rpl      \
65   snprintf              \
66   sprintf-posix         \
67   stdio_h               \
68   vasnprintf            \
69   vasprintf             \
70   vdprintf              \
71   vfprintf-posix        \
72   vprintf-posix         \
73   vsnprintf             \
74   vsprintf-posix
75
76 allow_AC_LIBOBJ_or := $(shell echo $(allow_AC_LIBOBJ) | tr -s ' ' '|')
77
78 sc_prohibit_AC_LIBOBJ_in_m4:
79         url=http://article.gmane.org/gmane.comp.lib.gnulib.bugs/26995;  \
80         if test -d .git; then                                           \
81           git ls-files m4                                               \
82              | grep -Ev '^m4/($(allow_AC_LIBOBJ_or))\.m4$$'             \
83              | xargs grep '^ *AC_LIBOBJ('                               \
84             && { printf '%s\n' 'Do not use AC_LIBOBJ in m4/*.m4;'       \
85                  "see <$$url>"; exit 1; } || :;                         \
86         else :; fi
87
88 sc_pragma_columns:
89         if test -d .git; then                                           \
90           git ls-files|grep '\.in\.h$$'                                 \
91               | xargs grep -l '^@PRAGMA_SYSTEM_HEADER@'                 \
92               | xargs grep -L '^@PRAGMA_COLUMNS@'                       \
93               | grep .                                                  \
94             && { printf '%s\n'                                          \
95                    'the files listed above use @PRAGMA_SYSTEM_HEADER@'  \
96                    'without also using @PRAGMA_COLUMNS@' 1>&2;          \
97                  exit 1; } || :;                                        \
98         else :; fi
99
100 # Verify that certain (for now, only Jim Meyering and Eric Blake's)
101 # *.c files are consistently cpp indented.
102 sc_cpp_indent_check:
103         ./gnulib-tool --extract-filelist \
104             $$(cd ./modules; grep -ilrE '(meyering|blake)' .) \
105           | sort -u \
106           | grep '\.c$$' \
107           | grep -vE '/(stdio-(read|write)|getloadavg)\.c$$' \
108           | xargs cppi -c
109
110 # Ensure that the list of symbols checked for by the
111 # sc_prohibit_intprops_without_use rule match those in the actual file.
112 # Extract the symbols from the .h file and compare with the list of
113 # symbols extracted from the rule in maint.mk.
114 sc_check_sym_list:
115         i=lib/intprops.h; \
116         diff -u <(perl -lne '/^# *define ([A-Z]\w+)\(/ and print $$1' $$i|fmt) \
117           <(sed -n /^_intprops_name/,/^_intprops_syms_re/p top/maint.mk \
118             |sed '/^_/d;s/^  //;s/      *\\$$//')
119
120 # Ensure that the copyright statements in files and in the module descriptions
121 # are consistent.
122 sc_check_copyright:
123         ./check-copyright
124
125 # Regenerate some files that are stored in the repository.
126 regen: MODULES.html
127
128 # MODULES.html is periodically being generated and copied to the web pages at
129 # :ext:USER@cvs.savannah.gnu.org:/web/gnulib/gnulib/
130 # where it then appears at <http://www.gnu.org/software/gnulib/MODULES.html>.
131 MODULES.html: MODULES.html.sh
132         ./MODULES.html.sh > MODULES.html
133
134 # Run this rule once per year (usually early in January)
135 # to update all FSF copyright year lists here.
136 # We exclude the files listed in srclist.txt (maintained elsewhere)
137 # as well as those in tests/unictype (generated).
138 # Also exclude any file that includes the "GENERATED AUTOMATICALLY" comment,
139 # being careful not to exclude code that merely generates the comment.
140 # Also exclude doc/INSTALL*, since they too are generated.
141 update-copyright:
142         exempt=$$(mktemp);                                              \
143         grep -v '^#' config/srclist.txt|grep -v '^$$'                   \
144           | while read src dst; do                                      \
145               test -f "$$dst" && { echo "$$dst"; continue; };           \
146               test -d "$$dst" || continue;                              \
147               echo "$$dst"/$$(basename "$$src");                        \
148             done > $$exempt;                                            \
149         git ls-files tests/unictype >> $$exempt;                        \
150         git ls-files doc/INSTALL* >> $$exempt;                          \
151         git ls-files | grep -vFf $$exempt                               \
152           | xargs grep -L '^/\*.*GENERATED AUTOMATICALLY'               \
153           | UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79                         \
154             UPDATE_COPYRIGHT_USE_INTERVALS=1                            \
155               xargs build-aux/update-copyright