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