Reinstate GNUmakefile patch, but with workaround for automake.
[platform/upstream/coreutils.git] / Makefile.am
1 # Make coreutils.                                       -*-Makefile-*-
2
3 # Copyright (C) 1990, 1993-2008 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 SUBDIRS = lib src doc man po tests gnulib-tests
19 EXTRA_DIST = Makefile.cfg Makefile.maint GNUmakefile \
20   .prev-version THANKS-to-translators THANKStt.in \
21   .version \
22   .vg-suppressions \
23   .x-po-check \
24   .x-sc_GPL_version \
25   .x-sc_file_system .x-sc_obsolete_symbols \
26   .x-sc_prohibit_atoi_atof \
27   .x-sc_prohibit_strcmp \
28   .x-sc_require_config_h \
29   .x-sc_space_tab .x-sc_sun_os_names \
30   .x-sc_trailing_blank \
31   .x-sc_unmarked_diagnostics \
32   .x-sc_useless_cpp_parens \
33   ChangeLog-2005 \
34   ChangeLog-2006 \
35   ChangeLog-2007 \
36   ChangeLog-2008 \
37   bootstrap \
38   bootstrap.conf \
39   build-aux/cvsu \
40   build-aux/git-version-gen \
41   build-aux/vc-list-files \
42   gl/modules/getloadavg.diff \
43   m4/ChangeLog \
44   old/fileutils/ChangeLog \
45   old/fileutils/ChangeLog-1997 \
46   old/fileutils/NEWS \
47   old/sh-utils/ChangeLog \
48   old/sh-utils/ChangeLog.0 \
49   old/sh-utils/NEWS \
50   old/textutils/ChangeLog \
51   old/textutils/NEWS
52
53 install-root:
54         cd src && $(MAKE) $@
55
56 ACLOCAL_AMFLAGS = -I m4
57
58 # Some tests always need root privileges, others need them only sometimes.
59 check-root:
60         cd tests && $(MAKE) $@
61
62 # Just prior to distribution, ...
63 # transform the automake-generated rule that runs `rm -f rm'.
64 # On some systems, that command would fail with a diagnostic like
65 # `rm: cannot unlink `rm': Text file busy' when `.' appears so early
66 # in the shell's search path that running `rm' would run the `rm'
67 # executable in the current directory.
68 # Similarly, adjust the clean-binPROGRAMS rule.
69 rm_subst = \
70   s!(rm -f (rm\b|\$$\(bin_PROGRAMS\)$$))!$$1 > /dev/null 2>&1 || /bin/$$1!
71
72 BUILT_SOURCES = .version
73 .version:
74         echo $(VERSION) > $@-t && mv $@-t $@
75
76 # Arrange so that .tarball-version appears only in the distribution
77 # tarball, and never in a checked-out repository.
78 # The perl substitution is to change some key uses of "rm" to "/bin/rm".
79 # See the rm_subst comment for details.
80 dist-hook: gen-ChangeLog
81         echo $(VERSION) > $(distdir)/.tarball-version
82         perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in
83
84 gen_start_date = 2008-02-08
85 .PHONY: gen-ChangeLog
86 gen-ChangeLog:
87         if test -d .git; then                                           \
88           $(top_srcdir)/build-aux/gitlog-to-changelog                   \
89             --since=$(gen_start_date) > $(distdir)/cl-t;                \
90           rm -f $(distdir)/ChangeLog;                                   \
91           mv $(distdir)/cl-t $(distdir)/ChangeLog;                      \
92         fi
93
94 distcheck-hook: check-ls-dircolors
95         $(MAKE) my-distcheck
96
97 # Arrange to remove the symlink to GNUmakefile in VPATH builds.
98 # TODO remove this once automake vs. AC_CONFIG_LINKS issue is fixed.
99 distclean-local:
100         if test x"$(VPATH)" != x ; then rm -f GNUmakefile ; fi
101
102 DISTCLEANFILES = VERSION
103 MAINTAINERCLEANFILES = THANKS-to-translators
104 THANKS-to-translators: po/LINGUAS THANKStt.in
105         (                                                               \
106           cat $(srcdir)/THANKStt.in;                                    \
107           for lang in `cat $(srcdir)/po/LINGUAS`; do                            \
108             echo http://www.iro.umontreal.ca/contrib/po/HTML/team-$$lang.html; \
109           done;                                                         \
110         ) > $@-tmp && mv $@-tmp $@
111
112 # Ensure that the sets of two-letter codes in ls.c and dircolors.c
113 # remain in sync.
114 .PHONY: check-ls-dircolors
115 check-ls-dircolors:
116         dc=$$(sed -n '/static.*ls_codes\[/,/};'/p               \
117             $(srcdir)/src/dircolors.c                           \
118           |sed -n '/^  *"/p'|tr , '\n'|sed 's/^  *//'           \
119           |sed -n 's/^"\(..\)"/\1/p'|sort -u);                  \
120         ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p        \
121             $(srcdir)/src/ls.c                                  \
122           |sed -n '/^  *"/p'|tr , '\n'|sed 's/^  *//'           \
123           |sed -n 's/^"\(..\)"/\1/p'|sort -u);                  \
124         test "$$dc" = "$$ls"