maint: improve update-copyright rule
[platform/upstream/coreutils.git] / Makefile.am
1 # Make coreutils.                                       -*-Makefile-*-
2
3 # Copyright (C) 1990, 1993-2009 Free Software Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 ALL_RECURSIVE_TARGETS =
19
20 SUBDIRS = lib src doc man po tests gnulib-tests
21
22 changelog_etc =                         \
23   ChangeLog-2005                        \
24   ChangeLog-2006                        \
25   ChangeLog-2007                        \
26   ChangeLog-2008                        \
27   build-aux/ChangeLog-2007              \
28   build-aux/update-copyright            \
29   doc/ChangeLog-2007                    \
30   lib/ChangeLog-2007                    \
31   m4/ChangeLog-2007                     \
32   old/fileutils/ChangeLog               \
33   old/fileutils/ChangeLog-1997          \
34   old/fileutils/NEWS                    \
35   old/sh-utils/ChangeLog                \
36   old/sh-utils/ChangeLog.0              \
37   old/sh-utils/NEWS                     \
38   old/textutils/ChangeLog               \
39   old/textutils/NEWS                    \
40   po/ChangeLog-2007
41
42 syntax_check_exceptions =               \
43   .x-sc_GPL_version                     \
44   .x-sc_error_message_uppercase         \
45   .x-sc_file_system                     \
46   .x-sc_obsolete_symbols                \
47   .x-sc_po_check                        \
48   .x-sc_program_name                    \
49   .x-sc_prohibit_atoi_atof              \
50   .x-sc_prohibit_stat_st_blocks         \
51   .x-sc_prohibit_strcmp                 \
52   .x-sc_require_config_h                \
53   .x-sc_require_config_h_first          \
54   .x-sc_space_tab                       \
55   .x-sc_sun_os_names                    \
56   .x-sc_system_h_headers                \
57   .x-sc_trailing_blank                  \
58   .x-sc_unmarked_diagnostics            \
59   .x-sc_useless_cpp_parens
60
61 EXTRA_DIST =                            \
62   $(changelog_etc)                      \
63   $(syntax_check_exceptions)            \
64   .prev-version                         \
65   .version                              \
66   .vg-suppressions                      \
67   THANKS-to-translators                 \
68   THANKStt.in                           \
69   bootstrap                             \
70   bootstrap.conf                        \
71   build-aux/cvsu                        \
72   cfg.mk                                \
73   dist-check.mk                         \
74   gl/modules/getloadavg.diff            \
75   maint.mk
76
77 ALL_RECURSIVE_TARGETS += install-root
78 install-root:
79         cd src && $(MAKE) $@
80
81 ACLOCAL_AMFLAGS = -I m4
82
83 # Some tests always need root privileges, others need them only sometimes.
84 ALL_RECURSIVE_TARGETS += check-root
85 check-root:
86         cd tests && $(MAKE) $@ SUBDIRS=
87
88 # Just prior to distribution, ...
89 # transform the automake-generated rule that runs `rm -f rm'.
90 # On some systems, that command would fail with a diagnostic like
91 # `rm: cannot unlink `rm': Text file busy' when `.' appears so early
92 # in the shell's search path that running `rm' would run the `rm'
93 # executable in the current directory.
94 # Similarly, adjust the clean-binPROGRAMS rule.
95 rm_subst = \
96   s!(rm -f (rm\b|\$$\(bin_PROGRAMS\)$$))!$$1 > /dev/null 2>&1 || /bin/$$1!
97
98 BUILT_SOURCES = .version
99 .version:
100         echo $(VERSION) > $@-t && mv $@-t $@
101
102 # Arrange so that .tarball-version appears only in the distribution
103 # tarball, and never in a checked-out repository.
104 # The perl substitution is to change some key uses of "rm" to "/bin/rm".
105 # See the rm_subst comment for details.
106 dist-hook: gen-ChangeLog
107         echo $(VERSION) > $(distdir)/.tarball-version
108         perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in
109
110 gen_start_date = 2008-02-08
111 .PHONY: gen-ChangeLog
112 gen-ChangeLog:
113         if test -d .git; then                                           \
114           $(top_srcdir)/build-aux/gitlog-to-changelog                   \
115             --since=$(gen_start_date) > $(distdir)/cl-t;                \
116           rm -f $(distdir)/ChangeLog;                                   \
117           mv $(distdir)/cl-t $(distdir)/ChangeLog;                      \
118         fi
119
120 ALL_RECURSIVE_TARGETS += distcheck-hook
121 distcheck-hook: check-ls-dircolors
122         $(MAKE) my-distcheck
123
124 DISTCLEANFILES = VERSION
125 MAINTAINERCLEANFILES = THANKS-to-translators
126 THANKS-to-translators: po/LINGUAS THANKStt.in
127         (                                                               \
128           cat $(srcdir)/THANKStt.in;                                    \
129           for lang in `cat $(srcdir)/po/LINGUAS`; do                    \
130             echo http://translationproject.org/team/$$lang.html;        \
131           done;                                                         \
132         ) > $@-tmp && mv $@-tmp $@
133
134 # Ensure that the sets of two-letter codes in ls.c and dircolors.c
135 # remain in sync.
136 .PHONY: check-ls-dircolors
137 check-ls-dircolors:
138         dc=$$(sed -n '/static.*ls_codes\[/,/};'/p               \
139             $(srcdir)/src/dircolors.c                           \
140           |sed -n '/^  *"/p'|tr , '\n'|sed 's/^  *//'           \
141           |sed -n 's/^"\(..\)"/\1/p'|sort -u);                  \
142         ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p        \
143             $(srcdir)/src/ls.c                                  \
144           |sed -n '/^  *"/p'|tr , '\n'|sed 's/^  *//'           \
145           |sed -n 's/^"\(..\)"/\1/p'|sort -u);                  \
146         test "$$dc" = "$$ls"
147
148 .PHONY: update-copyright
149 update-copyright:
150         if test -d .git; then                                   \
151           git grep -l -w Copyright                              \
152             | grep -v -E '(^|/)(COPYING|ChangeLog)'             \
153             | xargs $(srcdir)/build-aux/$@;                     \
154         fi