1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 ## Copyright (C) 1990, 1991, 1993-2007 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 # These are the names of programs that are not installed by default.
19 # This list is *not* intended for programs like who, nice, chroot, etc.,
20 # that are built only when certain requisite system features are detected.
21 # Hence, if you want to install programs from this list anyway, say A and B,
22 # use --enable-install-program=A,B
26 build_if_possible__progs = \
27 chroot df hostid nice pinky stty su uname uptime users who
30 $(no_install__progs) \
31 $(build_if_possible__progs) \
32 [ chcon chgrp chown chmod cp dd dircolors du \
33 ginstall link ln dir vdir ls mkdir \
34 mkfifo mknod mv nohup readlink rm rmdir shred stat sync touch unlink \
35 cat cksum comm csplit cut expand fmt fold head join md5sum \
36 nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
37 shuf sort split sum tac tail tr tsort unexpand uniq wc \
38 basename date dirname echo env expr factor false \
39 id kill logname pathchk printenv printf pwd \
40 runcon seq sleep tee \
41 test true tty whoami yes \
45 bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
47 noinst_PROGRAMS = setuidgid
62 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
63 groups.sh wheel-gen.pl extract-magic c99-to-c89.diff
65 CLEANFILES = $(SCRIPTS) su
67 AM_CPPFLAGS = -I$(top_srcdir)/lib
69 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
70 # include modules defining variables like `optind', so libcoreutils.a
71 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
72 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
73 # replacement functions defined in libcoreutils.a.
74 LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
76 # for eaccess in lib/euidaccess.c.
77 chcon_LDADD = $(LDADD) $(LIB_SELINUX)
78 cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
79 ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
80 mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
81 mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
82 mknod_LDADD = $(LDADD) $(LIB_SELINUX)
83 mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
84 runcon_LDADD = $(LDADD) $(LIB_SELINUX)
85 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
86 rm_LDADD = $(LDADD) $(LIB_EACCESS)
87 test_LDADD = $(LDADD) $(LIB_EACCESS)
88 # This is for the '[' program. Automake transliterates '[' to '_'.
89 __LDADD = $(LDADD) $(LIB_EACCESS)
91 # for clock_gettime and fdatasync
92 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
93 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
94 id_LDADD = $(LDADD) $(LIB_SELINUX)
95 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
96 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
97 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
98 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
99 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
101 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
102 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
104 # for get_date and gettime
105 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
106 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
108 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
109 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
110 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
112 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
113 seq_LDADD = $(LDADD) $(POW_LIB)
115 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
116 # and the `nanosleep' reference in lib/xnanosleep.c.
117 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
119 sleep_LDADD = $(nanosec_libs)
120 tail_LDADD = $(nanosec_libs)
122 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
123 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
125 su_LDADD = $(LDADD) $(LIB_CRYPT)
127 dir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
128 ls_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
129 vdir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
130 cp_LDADD += $(LIB_ACL)
131 mv_LDADD += $(LIB_ACL)
132 ginstall_LDADD += $(LIB_ACL)
134 stat_LDADD = $(LDADD) $(LIB_SELINUX)
136 $(PROGRAMS): ../lib/libcoreutils.a
140 # Get the release year from ../lib/version-etc.c.
142 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
143 $(top_srcdir)/lib/version-etc.c`
148 -e 's!@''bindir''@!$(bindir)!' \
149 -e 's/@''RELEASE_YEAR'@/$(RELEASE_YEAR)/ \
150 -e 's/@''PACKAGE_NAME''@/$(PACKAGE_NAME)/' \
151 -e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
152 -e 's/@''VERSION''@/$(VERSION)/' $< > $@-t
156 all-local: su$(EXEEXT)
158 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
160 setuid_root_mode = a=rx,u+s
163 if test "$(INSTALL_SU)" = yes; then \
165 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
166 $(INSTALL_PROGRAM) $$p $(installed_su); \
167 echo " chown root $(installed_su)"; \
168 chown root $(installed_su); \
169 echo " chmod $(setuid_root_mode) $(installed_su)"; \
170 chmod $(setuid_root_mode) $(installed_su) \
175 install-root: su$(EXEEXT)
178 install-exec-local: su$(EXEEXT)
179 @TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
182 ## See if we can create a setuid root executable in $(bindir).
183 ## If not, then don't even try to install su.
184 can_create_suid_root_executable=no; \
185 chown root $$TMPFILE > /dev/null 2>&1 \
186 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
187 && can_create_suid_root_executable=yes; \
189 if test $$can_create_suid_root_executable = yes; then \
192 echo "WARNING: insufficient access; not installing su"; \
193 echo "NOTE: to install su, run 'make install-root' as root"; \
197 # Remove su only if it's one we installed.
198 @if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
199 echo " rm -f $(installed_su)"; \
200 rm -f $(installed_su); \
203 copy_sources = copy.c cp-hash.c
205 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
206 # confusion with the `install' target. The install rule transforms `ginstall'
207 # to install before applying any user-specified name transformations.
209 transform = s/ginstall/install/; @program_transform_name@
210 ginstall_SOURCES = install.c $(copy_sources)
212 # This is for the '[' program. Automake transliterates '[' to '_'.
213 __SOURCES = lbracket.c
215 cp_SOURCES = cp.c $(copy_sources)
216 dir_SOURCES = ls.c ls-dir.c
217 vdir_SOURCES = ls.c ls-vdir.c
219 ls_SOURCES = ls.c ls-ls.c
220 chown_SOURCES = chown.c chown-core.c
221 chgrp_SOURCES = chgrp.c chown-core.c
223 mv_SOURCES = mv.c remove.c $(copy_sources)
224 rm_SOURCES = rm.c remove.c
226 uname_SOURCES = uname.c uname-uname.c
227 arch_SOURCES = uname.c uname-arch.c
229 md5sum_SOURCES = md5sum.c
230 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
231 sha1sum_SOURCES = md5sum.c
232 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
233 sha224sum_SOURCES = md5sum.c
234 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
235 sha256sum_SOURCES = md5sum.c
236 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
237 sha384sum_SOURCES = md5sum.c
238 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
239 sha512sum_SOURCES = md5sum.c
240 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
242 editpl = sed -e 's,@''PERL''@,$(PERL),g'
244 BUILT_SOURCES += dircolors.h
245 dircolors.h: dcgen dircolors.hin
247 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
253 BUILT_SOURCES += wheel-size.h
254 wheel-size.h: Makefile.am
256 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
260 BUILT_SOURCES += wheel.h
261 wheel.h: wheel-gen.pl Makefile.am
263 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
267 # false exits nonzero even with --help or --version.
268 # test doesn't support --help or --version.
269 # Tell automake to exempt then from that installcheck test.
270 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
272 BUILT_SOURCES += fs.h
273 fs.h: stat.c extract-magic
275 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
279 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
281 # Sort in traditional ASCII order, regardless of the current locale;
282 # otherwise we may get into trouble with distinct strings that the
283 # current locale considers to be equal.
284 ASSORT = LC_ALL=C sort
292 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
293 | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u
296 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
301 # Ensure that the list of programs in README matches the list
302 # of programs we can build.
303 check: check-README check-misc check-duplicate-no-install
307 echo $(all_programs) \
308 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
309 | $(ASSORT) -u > $(pm) && \
310 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
311 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
312 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
314 # Ensure that a by-default-not-installed program (listed in
315 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
316 # if that were to happen, it *would* be installed by default.
317 .PHONY: check-duplicate-no-install
318 check-duplicate-no-install: tr
319 test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
321 # Ensure that the list of programs and author names is accurate.
322 au_dotdot = authors-dotdot
323 au_actual = authors-actual
324 .PHONY: check-AUTHORS
325 check-AUTHORS: $(all_programs)
326 rm -f $(au_actual) $(au_dotdot)
327 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
328 | $(ASSORT) -u`; do \
329 test "$$i" = '[' && continue; \
331 if test "$$i" = install; then \
333 elif test "$$i" = test; then \
337 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
339 sed -n '/:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
340 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
342 # Make sure we don't define any S_IS* macros in src/*.c files.
343 # Not a big deal, but they're already defined via system.h.
345 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
346 # This is a bit of a kludge, since it prevents use of the string
347 # even in comments, but for now it does the job with no false positives.
350 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
351 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
352 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
354 # Extract the list of authors from each file.
355 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
356 # Sometimes the string is on the same line as the #define...
357 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
358 # Sometimes the string is on the backslash-continued line after the #define.
359 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
360 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
361 ../AUTHORS: $(SOURCES)
365 echo "Here are the names of the programs in this package,"; \
366 echo "each followed by the name(s) of its author(s)."; \
368 for i in $(SOURCES); do \
369 a=`sed -n $(s1) $$i`; \
371 || a=`sed -n $(s2) $$i`; \
372 if test "$$a"; then \
373 prog=`echo $$i|sed 's/\.c$$//'`; \
374 echo "$$prog: $$a"; \
376 done | $(ASSORT) -u ) > $@-t
380 # The following rule is not designed to be portable,
381 # and relies on tools that not everyone has.
383 # Most functions in src/*.c should have static scope.
384 # Any that don't must be marked with `extern', but `main'
385 # and `usage' are exceptions. They're always extern, but
386 # don't need to be marked.
388 # The second nm|grep checks for file-scope variables with `extern' scope.
389 .PHONY: sc_tight_scope
390 sc_tight_scope: $(all_programs)
391 @t=exceptions-$$$$; \
392 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
393 ( printf '^main$$\n^usage$$\n'; \
394 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
395 | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
397 | sed -n 's/.* T //p' \
398 | grep -Ev -f $$t && \
399 { echo 'the above functions should have static scope' 1>&2; \
401 ( printf '^program_name$$\n'; \
402 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
403 $(noinst_HEADERS) ) > $$t; \
405 | sed -n 's/.* [BD] //p' \
406 | grep -Ev -f $$t && \
407 { echo 'the above variables should have static scope' 1>&2; \