cp,mv,install: improve EACCES targetdir messages
[coreutils.git] / Makefile.am
blob733b32214fc69efd599b506feeb973f23db349b9
1 # Make coreutils.                                       -*-Makefile-*-
3 # Copyright (C) 1990-2022 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 <https://www.gnu.org/licenses/>.
18 ALL_RECURSIVE_TARGETS =
20 SUBDIRS = po . gnulib-tests
22 EXTRA_DIST =                            \
23   .mailmap                              \
24   .prev-version                         \
25   .version                              \
26   .vg-suppressions                      \
27   THANKS.in                             \
28   THANKS-to-translators                 \
29   THANKStt.in                           \
30   bootstrap                             \
31   bootstrap.conf                        \
32   build-aux/gen-lists-of-programs.sh    \
33   build-aux/gen-single-binary.sh        \
34   cfg.mk                                \
35   dist-check.mk                         \
36   maint.mk                              \
37   tests/GNUmakefile                     \
38   thanks-gen
40 gen_progs_lists = $(top_srcdir)/build-aux/gen-lists-of-programs.sh
41 gen_single_binary = $(top_srcdir)/build-aux/gen-single-binary.sh
43 # Keep these in sync with bootstrap.conf:bootstrap_post_import_hook().
44 # Use '$(top_srcdir)/m4' and '$(srcdir)/src' for the benefit of non-GNU
45 # makes: it is with those directories that 'cu-progs.m4' and 'cu-progs.mk'
46 # appear in our dependencies.
47 $(top_srcdir)/m4/cu-progs.m4: $(gen_progs_lists)
48         $(AM_V_GEN)rm -f $@ $@-t \
49           && $(SHELL) $(gen_progs_lists) --autoconf >$@-t \
50           && chmod a-w $@-t && mv -f $@-t $@
51 $(srcdir)/src/cu-progs.mk: $(gen_progs_lists)
52         $(AM_V_GEN)rm -f $@ $@-t \
53           && $(SHELL) $(gen_progs_lists) --automake >$@-t \
54           && chmod a-w $@-t && mv -f $@-t $@
55 $(srcdir)/src/single-binary.mk: $(gen_single_binary) $(srcdir)/src/local.mk
56         $(AM_V_GEN)rm -f $@ $@-t \
57           && $(SHELL) $(gen_single_binary) $(srcdir)/src/local.mk >$@-t \
58           && chmod a-w $@-t && mv -f $@-t $@
60 ACLOCAL_AMFLAGS = -I m4
62 # Shortcut targets to make it easier to run (very) expensive tests.
63 check-expensive:
64         $(MAKE) check RUN_EXPENSIVE_TESTS=yes
65 check-very-expensive:
66         $(MAKE) check-expensive RUN_VERY_EXPENSIVE_TESTS=yes
68 # Just prior to distribution, ...
69 # transform the automake-generated rule that runs 'rm -f rm'.
70 # On some systems, that command would fail with a diagnostic like
71 # "rm: cannot unlink 'rm': Text file busy" when '.' appears so early
72 # in the shell's search path that running 'rm' would run the 'rm'
73 # executable in the current directory.
74 # Similarly, adjust the clean-binPROGRAMS rule.
75 rm_subst = \
76   s!(rm -f (rm\b|\$$\(bin_PROGRAMS\)$$))!$$1 > /dev/null 2>&1 || /bin/$$1!
78 BUILT_SOURCES = .version
79 .version:
80         $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
82 # Have no read-only files in the tarball to allow easy removal.
83 # Have .tarball-version based versions only in tarball builds.
84 # Have .timestamp based dates only in tarball builds.
85 # The perl substitution is to change some key uses of "rm" to "/bin/rm".
86 # See the rm_subst comment for details.
87 # The touch avoids a subtle, spurious "make distcheck" failure.
88 dist-hook: gen-ChangeLog
89         $(AM_V_GEN)chmod -R +rw $(distdir)
90         $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
91         $(AM_V_GEN)date +%s > $(distdir)/.timestamp
92         $(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/Makefile.in
93         $(AM_V_at)touch $(distdir)/doc/constants.texi \
94           $(distdir)/doc/coreutils.info
96 gen_start_ver = 8.27
97 .PHONY: gen-ChangeLog
98 gen-ChangeLog:
99         $(AM_V_GEN)if test -d .git; then                                \
100           log_fix="$(srcdir)/build-aux/git-log-fix";                    \
101           test -e "$$log_fix"                                           \
102             && amend_git_log="--amend=$$log_fix"                        \
103             || amend_git_log=;                                          \
104           $(top_srcdir)/build-aux/gitlog-to-changelog $$amend_git_log   \
105             -- v$(gen_start_ver)~.. > $(distdir)/cl-t &&                \
106             { printf '\n\nSee the source repo for older entries\n'      \
107               >> $(distdir)/cl-t &&                                     \
108               rm -f $(distdir)/ChangeLog &&                             \
109               mv $(distdir)/cl-t $(distdir)/ChangeLog; }                \
110         fi
112 ALL_RECURSIVE_TARGETS += distcheck-hook
113 distcheck-hook: check-ls-dircolors
114         $(MAKE) my-distcheck
115         $(MAKE) taint-distcheck
117 DISTCLEANFILES = VERSION
118 MAINTAINERCLEANFILES = THANKS-to-translators
119 THANKS-to-translators: po/LINGUAS THANKStt.in
120         $(AM_V_GEN)(                                                    \
121           cat $(srcdir)/THANKStt.in;                                    \
122           for lang in `cat $(srcdir)/po/LINGUAS`; do                    \
123             echo https://translationproject.org/team/$$lang.html;       \
124           done;                                                         \
125         ) > $@-tmp && mv $@-tmp $@
127 # Ensure that the sets of two-letter codes in ls.c and dircolors.c
128 # remain in sync.
129 .PHONY: check-ls-dircolors
130 check-ls-dircolors:
131         $(AM_V_GEN)dc=$$(sed -n '/static.*ls_codes\[/,/};'/p    \
132             $(srcdir)/src/dircolors.c                           \
133           |sed -n '/^  *"/p'|tr , '\n'|sed 's/^  *//'           \
134           |sed -n 's/^"\(..\)"/\1/p'|sort -u);                  \
135         ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p        \
136             $(srcdir)/src/ls.c                                  \
137           |sed -n '/^  *"/p'|tr , '\n'|sed 's/^  *//'           \
138           |sed -n 's/^"\(..\)"/\1/p'|sort -u);                  \
139         test "$$dc" = "$$ls"
141 # Sort in traditional ASCII order, regardless of the current locale;
142 # otherwise we may get into trouble with distinct strings that the
143 # current locale considers to be equal.
144 ASSORT = LC_ALL=C sort
146 # Extract all lines up to the first one starting with "##".
147 prologue = perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in
149 # FIXME: avoid dependency to build our own 'sort' for 'make dist' ...
150 # when common platforms have a functional case-folding implementation:
151 #   $ test 'abácad' = "$(printf '%s\n' 'ab' 'ác' 'ad' \
152 #                          | LC_ALL=en_US.UTF-8 sort -f \
153 #                          | tr -d '\n')" && echo GOOD || echo BAD
154 # Note we don't enable case folding (-f) in the sort below, due to bugs
155 # in the I18N patch used in many distros (as of 2015).  Also using our
156 # own src/sort here would induce awkward dependencies for `make dist`.
157 THANKS: THANKS.in Makefile.am .mailmap thanks-gen .version
158         $(AM_V_GEN)rm -f $@-t $@;                                       \
159         {                                                               \
160           $(prologue); echo;                                            \
161           { perl -ne '/^$$/.../^$$/ and !/^$$/ and s/  +/\0/ and print' \
162               $(srcdir)/THANKS.in;                                      \
163             git log --pretty=format:'%aN%x00%aE'                        \
164               | $(ASSORT) -u;                                           \
165           } | $(srcdir)/thanks-gen                                      \
166             | LC_ALL=en_US.UTF-8 sort -k1,1;                            \
167           echo;                                                         \
168           printf ';; %s\n' 'Local Variables:' 'coding: utf-8' End:;     \
169         } > $@-t && chmod a-w $@-t && mv $@-t $@
171 # Some of our git hook scripts are supposed to be identical to git's samples.
172 # See if they are still in sync.
173 .PHONY: check-git-hook-script-sync
174 check-git-hook-script-sync:
175         @fail=0;                                                        \
176         t=$$(mktemp -d)                                                 \
177           && cd $$t && git init -q && cd .git/hooks                     \
178           && for i in pre-commit pre-applypatch applypatch-msg; do      \
179                diff $(abs_top_srcdir)/scripts/git-hooks/$$i $$i.sample  \
180                  || fail=1;                                             \
181              done;                                                      \
182         rm -rf $$t;                                                     \
183         test $$fail = 0
185 # If we are building a single-binary, create symlinks or shebangs for
186 # the selected tools when installing.
187 install-exec-hook:
188         $(AM_V_at)ctrans=$$(printf coreutils | sed -e "$(transform)");  \
189         for p in x $(single_binary_progs); do                           \
190           test $$p = x && continue;                                     \
191           ptrans=$$(printf '%s' "$$p" | sed -e "$(transform)");         \
192           rm -f $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;      \
193           if test "x$(single_binary_install_type)" = xshebangs; then    \
194             printf '#!%s --coreutils-prog-shebang=%s\n'                 \
195               $(bindir)/$$ctrans$(EXEEXT) $$p                           \
196               >$(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;       \
197             chmod a+x,a-w $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;\
198           else                                                          \
199             $(LN_S) -s $$ctrans$(EXEEXT)                                \
200               $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;        \
201           fi                                                            \
202         done
204 noinst_LIBRARIES =
205 MOSTLYCLEANFILES =
206 CLEANFILES =
207 MOSTLYCLEANDIRS =
209 AM_CPPFLAGS = -Ilib -I$(top_srcdir)/lib -Isrc -I$(top_srcdir)/src
211 include $(top_srcdir)/lib/local.mk
212 include $(top_srcdir)/src/local.mk
213 include $(top_srcdir)/doc/local.mk
214 include $(top_srcdir)/man/local.mk
215 include $(top_srcdir)/tests/local.mk