1 # Make coreutils. -*-Makefile-*-
3 # Copyright (C) 1990-2017 Free Software Foundation, Inc.
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.
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.
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/>.
18 ALL_RECURSIVE_TARGETS =
20 SUBDIRS = po . gnulib-tests
23 build-aux/ChangeLog-2007 \
34 THANKS-to-translators \
38 build-aux/gen-lists-of-programs.sh \
39 build-aux/gen-single-binary.sh \
46 gen_progs_lists = $(top_srcdir)/build-aux/gen-lists-of-programs.sh
47 gen_single_binary = $(top_srcdir)/build-aux/gen-single-binary.sh
49 # Keep these in sync with bootstrap.conf:bootstrap_post_import_hook().
50 # Use '$(top_srcdir)/m4' and '$(srcdir)/src' for the benefit of non-GNU
51 # makes: it is with those directories that 'cu-progs.m4' and 'cu-progs.mk'
52 # appear in our dependencies.
53 $(top_srcdir)/m4/cu-progs.m4: $(gen_progs_lists)
54 $(AM_V_GEN)rm -f $@ $@-t \
55 && $(SHELL) $(gen_progs_lists) --autoconf >$@-t \
56 && chmod a-w $@-t && mv -f $@-t $@
57 $(srcdir)/src/cu-progs.mk: $(gen_progs_lists)
58 $(AM_V_GEN)rm -f $@ $@-t \
59 && $(SHELL) $(gen_progs_lists) --automake >$@-t \
60 && chmod a-w $@-t && mv -f $@-t $@
61 $(srcdir)/src/single-binary.mk: $(gen_single_binary) $(srcdir)/src/local.mk
62 $(AM_V_GEN)rm -f $@ $@-t \
63 && $(SHELL) $(gen_single_binary) $(srcdir)/src/local.mk >$@-t \
64 && chmod a-w $@-t && mv -f $@-t $@
66 ACLOCAL_AMFLAGS = -I m4
68 # Shortcut targets to make it easier to run (very) expensive tests.
70 $(MAKE) check RUN_EXPENSIVE_TESTS=yes
72 $(MAKE) check-expensive RUN_VERY_EXPENSIVE_TESTS=yes
74 # Just prior to distribution, ...
75 # transform the automake-generated rule that runs 'rm -f rm'.
76 # On some systems, that command would fail with a diagnostic like
77 # "rm: cannot unlink 'rm': Text file busy" when '.' appears so early
78 # in the shell's search path that running 'rm' would run the 'rm'
79 # executable in the current directory.
80 # Similarly, adjust the clean-binPROGRAMS rule.
82 s!(rm -f (rm\b|\$$\(bin_PROGRAMS\)$$))!$$1 > /dev/null 2>&1 || /bin/$$1!
84 BUILT_SOURCES = .version
86 $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
88 # Have no read-only files in the tarball to allow easy removal.
89 # Have .tarball-version based versions only in tarball builds.
90 # Have .timestamp based dates only in tarball builds.
91 # The perl substitution is to change some key uses of "rm" to "/bin/rm".
92 # See the rm_subst comment for details.
93 dist-hook: gen-ChangeLog
94 $(AM_V_GEN)chmod -R +rw $(distdir)
95 $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
96 $(AM_V_GEN)date +%s > $(distdir)/.timestamp
97 $(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/Makefile.in
100 .PHONY: gen-ChangeLog
102 $(AM_V_GEN)if test -d .git; then \
103 log_fix="$(srcdir)/build-aux/git-log-fix"; \
104 test -e "$$log_fix" \
105 && amend_git_log="--amend=$$log_fix" \
107 $(top_srcdir)/build-aux/gitlog-to-changelog $$amend_git_log \
108 -- v$(gen_start_ver)~.. > $(distdir)/cl-t && \
109 { printf '\n\nSee the source repo for older entries\n' \
110 >> $(distdir)/cl-t && \
111 rm -f $(distdir)/ChangeLog && \
112 mv $(distdir)/cl-t $(distdir)/ChangeLog; } \
115 ALL_RECURSIVE_TARGETS += distcheck-hook
116 distcheck-hook: check-ls-dircolors
118 $(MAKE) taint-distcheck
120 DISTCLEANFILES = VERSION
121 MAINTAINERCLEANFILES = THANKS-to-translators
122 THANKS-to-translators: po/LINGUAS THANKStt.in
124 cat $(srcdir)/THANKStt.in; \
125 for lang in `cat $(srcdir)/po/LINGUAS`; do \
126 echo http://translationproject.org/team/$$lang.html; \
128 ) > $@-tmp && mv $@-tmp $@
130 # Ensure that the sets of two-letter codes in ls.c and dircolors.c
132 .PHONY: check-ls-dircolors
134 $(AM_V_GEN)dc=$$(sed -n '/static.*ls_codes\[/,/};'/p \
135 $(srcdir)/src/dircolors.c \
136 |sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \
137 |sed -n 's/^"\(..\)"/\1/p'|sort -u); \
138 ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p \
140 |sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \
141 |sed -n 's/^"\(..\)"/\1/p'|sort -u); \
144 # Sort in traditional ASCII order, regardless of the current locale;
145 # otherwise we may get into trouble with distinct strings that the
146 # current locale considers to be equal.
147 ASSORT = LC_ALL=C sort
149 # Extract all lines up to the first one starting with "##".
150 prologue = perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in
152 # FIXME: avoid dependency to build our own 'sort' for 'make dist' ...
153 # when common platforms have a functional case-folding implementation:
154 # $ test 'abácad' = "$(printf '%s\n' 'ab' 'ác' 'ad' \
155 # | LC_ALL=en_US.UTF-8 sort -f \
156 # | tr -d '\n')" && echo GOOD || echo BAD
157 # Note we don't enable case folding (-f) in the sort below, due to bugs
158 # in the I18N patch used in many distros (as of 2015). Also using our
159 # own src/sort here would induce awkward dependencies for `make dist`.
160 THANKS: THANKS.in Makefile.am .mailmap thanks-gen .version
161 $(AM_V_GEN)rm -f $@-t $@; \
164 { perl -ne '/^$$/.../^$$/ and !/^$$/ and s/ +/\0/ and print' \
165 $(srcdir)/THANKS.in; \
166 git log --pretty=format:'%aN%x00%aE' \
168 } | $(srcdir)/thanks-gen \
169 | LC_ALL=en_US.UTF-8 sort -k1,1; \
171 printf ';; %s\n' 'Local Variables:' 'coding: utf-8' End:; \
172 } > $@-t && chmod a-w $@-t && mv $@-t $@
174 # Some of our git hook scripts are supposed to be identical to git's samples.
175 # See if they are still in sync.
176 .PHONY: check-git-hook-script-sync
177 check-git-hook-script-sync:
180 && cd $$t && git init -q && cd .git/hooks \
181 && for i in pre-commit pre-applypatch applypatch-msg; do \
182 diff $(abs_top_srcdir)/scripts/git-hooks/$$i $$i.sample \
188 # If we are building a single-binary, create symlinks or shebangs for
189 # the selected tools when installing.
191 $(AM_V_at)ctrans=$$(printf coreutils | sed -e "$(transform)"); \
192 for p in x $(single_binary_progs); do \
193 test $$p = x && continue; \
194 ptrans=$$(printf '%s' "$$p" | sed -e "$(transform)"); \
195 rm -f $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
196 if test "x$(single_binary_install_type)" = xshebangs; then \
197 printf '#!%s --coreutils-prog-shebang=%s\n' \
198 $(bindir)/$$ctrans$(EXEEXT) $$p \
199 >$(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
200 chmod a+x,a-w $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;\
202 $(LN_S) -s $$ctrans$(EXEEXT) \
203 $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
212 AM_CPPFLAGS = -Ilib -I$(top_srcdir)/lib -Isrc -I$(top_srcdir)/src
214 include $(top_srcdir)/lib/local.mk
215 include $(top_srcdir)/src/local.mk
216 include $(top_srcdir)/doc/local.mk
217 include $(top_srcdir)/man/local.mk
218 include $(top_srcdir)/tests/local.mk