1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 ## Copyright (C) 1990, 1991, 1993-2008 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 \
35 mv nohup readlink rm rmdir shred stat sync touch unlink \
36 cat cksum comm csplit cut expand fmt fold head join groups md5sum \
37 nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
38 shuf sort split sum tac tail tr tsort unexpand uniq wc \
39 basename date dirname echo env expr factor false \
40 id kill logname pathchk printenv printf pwd \
41 runcon seq sleep tee \
42 test timeout true truncate tty whoami yes \
45 bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
47 noinst_PROGRAMS = setuidgid
65 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
66 wheel-gen.pl extract-magic c99-to-c89.diff
68 CLEANFILES = $(SCRIPTS) su
70 AM_CPPFLAGS = -I$(top_srcdir)/lib
72 noinst_LIBRARIES = libver.a
73 nodist_libver_a_SOURCES = version.c version.h
75 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
76 # include modules defining variables like `optind', so libcoreutils.a
77 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
78 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
79 # replacement functions defined in libcoreutils.a.
80 LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
86 split_LDADD = $(LDADD)
87 timeout_LDADD = $(LDADD)
88 truncate_LDADD = $(LDADD)
90 # for eaccess in lib/euidaccess.c.
91 chcon_LDADD = $(LDADD) $(LIB_SELINUX)
92 cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
93 ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
94 mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
95 mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
96 mknod_LDADD = $(LDADD) $(LIB_SELINUX)
97 mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
98 runcon_LDADD = $(LDADD) $(LIB_SELINUX)
99 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
100 rm_LDADD = $(LDADD) $(LIB_EACCESS)
101 test_LDADD = $(LDADD) $(LIB_EACCESS)
102 # This is for the '[' program. Automake transliterates '[' to '_'.
103 __LDADD = $(LDADD) $(LIB_EACCESS)
105 # for clock_gettime and fdatasync
106 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
107 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
108 id_LDADD = $(LDADD) $(LIB_SELINUX)
109 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
110 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
111 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
112 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
113 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
114 tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
115 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
117 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
118 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
120 # for get_date and gettime
121 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
122 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
124 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
125 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
126 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
128 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
129 seq_LDADD = $(LDADD) $(POW_LIB)
131 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
132 # and the `nanosleep' reference in lib/xnanosleep.c.
133 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
135 # for various GMP functions
136 expr_LDADD = $(LDADD) $(LIB_GMP)
138 # for various GMP functions
139 factor_LDADD = $(LDADD) $(LIB_GMP)
141 sleep_LDADD = $(nanosec_libs)
142 tail_LDADD = $(nanosec_libs)
144 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
145 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
147 su_LDADD = $(LDADD) $(LIB_CRYPT)
149 dir_LDADD += $(LIB_ACL)
150 ls_LDADD += $(LIB_ACL)
151 vdir_LDADD += $(LIB_ACL)
152 cp_LDADD += $(LIB_ACL)
153 mv_LDADD += $(LIB_ACL)
154 ginstall_LDADD += $(LIB_ACL)
156 stat_LDADD = $(LDADD) $(LIB_SELINUX)
158 # Append $(LIBICONV) to each program that uses proper_name_utf8.
159 cat_LDADD += $(LIBICONV)
160 cp_LDADD += $(LIBICONV)
161 df_LDADD += $(LIBICONV)
162 du_LDADD += $(LIBICONV)
163 ptx_LDADD += $(LIBICONV)
164 split_LDADD += $(LIBICONV)
165 timeout_LDADD += $(LIBICONV)
166 truncate_LDADD += $(LIBICONV)
168 $(PROGRAMS): ../lib/libcoreutils.a
170 # Get the release year from ../lib/version-etc.c.
172 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
173 $(top_srcdir)/lib/version-etc.c`
175 all-local: su$(EXEEXT)
177 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
179 setuid_root_mode = a=rx,u+s
182 if test "$(INSTALL_SU)" = yes; then \
184 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
185 $(INSTALL_PROGRAM) $$p $(installed_su); \
186 echo " chown root $(installed_su)"; \
187 chown root $(installed_su); \
188 echo " chmod $(setuid_root_mode) $(installed_su)"; \
189 chmod $(setuid_root_mode) $(installed_su); \
194 install-root: su$(EXEEXT)
197 install-exec-hook: su$(EXEEXT)
198 @if test "$(INSTALL_SU)" = yes; then \
199 TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
202 ## See if we can create a setuid root executable in $(bindir).
203 ## If not, then don't even try to install su.
204 can_create_suid_root_executable=no; \
205 chown root $$TMPFILE > /dev/null 2>&1 \
206 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
207 && can_create_suid_root_executable=yes; \
209 if test $$can_create_suid_root_executable = yes; then \
212 echo "WARNING: insufficient access; not installing su"; \
213 echo "NOTE: to install su, run 'make install-root' as root"; \
214 rm -f $(installed_su); \
220 # Remove su only if it's one we installed.
221 @if test "$(INSTALL_SU)" = yes; then \
222 if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
223 echo " rm -f $(installed_su)"; \
224 rm -f $(installed_su); \
229 copy_sources = copy.c cp-hash.c
231 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
232 # confusion with the `install' target. The install rule transforms `ginstall'
233 # to install before applying any user-specified name transformations.
235 transform = s/ginstall/install/; $(program_transform_name)
236 ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
238 # This is for the '[' program. Automake transliterates '[' to '_'.
239 __SOURCES = lbracket.c
241 cp_SOURCES = cp.c $(copy_sources)
242 dir_SOURCES = ls.c ls-dir.c
243 vdir_SOURCES = ls.c ls-vdir.c
244 id_SOURCES = id.c group-list.c
245 groups_SOURCES = groups.c group-list.c
247 ls_SOURCES = ls.c ls-ls.c
248 chown_SOURCES = chown.c chown-core.c
249 chgrp_SOURCES = chgrp.c chown-core.c
250 kill_SOURCES = kill.c operand2sig.c
251 timeout_SOURCES = timeout.c operand2sig.c
253 mv_SOURCES = mv.c remove.c $(copy_sources)
254 rm_SOURCES = rm.c remove.c
256 mkdir_SOURCES = mkdir.c prog-fprintf.c
257 rmdir_SOURCES = rmdir.c prog-fprintf.c
259 uname_SOURCES = uname.c uname-uname.c
260 arch_SOURCES = uname.c uname-arch.c
262 md5sum_SOURCES = md5sum.c
263 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
264 sha1sum_SOURCES = md5sum.c
265 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
266 sha224sum_SOURCES = md5sum.c
267 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
268 sha256sum_SOURCES = md5sum.c
269 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
270 sha384sum_SOURCES = md5sum.c
271 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
272 sha512sum_SOURCES = md5sum.c
273 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
275 ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
277 editpl = sed -e 's,@''PERL''@,$(PERL),g'
279 BUILT_SOURCES += dircolors.h
280 dircolors.h: dcgen dircolors.hin
282 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
288 BUILT_SOURCES += wheel-size.h
289 wheel-size.h: Makefile.am
291 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
295 BUILT_SOURCES += wheel.h
296 wheel.h: wheel-gen.pl Makefile.am
298 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
302 # false exits nonzero even with --help or --version.
303 # test doesn't support --help or --version.
304 # Tell automake to exempt then from that installcheck test.
305 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
307 BUILT_SOURCES += fs.h
308 fs.h: stat.c extract-magic
310 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
314 BUILT_SOURCES += version.c
317 printf '#include <config.h>\n' > $@t
318 printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
322 BUILT_SOURCES += version.h
325 printf 'extern char const *Version;\n' > $@t
329 DISTCLEANFILES = version.c version.h
330 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
332 # Sort in traditional ASCII order, regardless of the current locale;
333 # otherwise we may get into trouble with distinct strings that the
334 # current locale considers to be equal.
335 ASSORT = LC_ALL=C sort
343 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
344 | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
347 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
352 # Ensure that the list of programs in README matches the list
353 # of programs we can build.
354 check: check-README check-misc check-duplicate-no-install
358 echo $(all_programs) \
359 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
360 | $(ASSORT) -u > $(pm) && \
361 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
362 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
363 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
365 # Ensure that a by-default-not-installed program (listed in
366 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
367 # if that were to happen, it *would* be installed by default.
368 .PHONY: check-duplicate-no-install
369 check-duplicate-no-install: tr
370 test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
372 # Ensure that the list of programs and author names is accurate.
373 au_dotdot = authors-dotdot
374 au_actual = authors-actual
375 .PHONY: check-AUTHORS
376 check-AUTHORS: $(all_programs)
377 rm -f $(au_actual) $(au_dotdot)
378 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
379 | $(ASSORT) -u`; do \
380 test "$$i" = '[' && continue; \
382 if test "$$i" = install; then \
384 elif test "$$i" = test; then \
387 LC_ALL=en_US.UTF-8 ./$$exe --version \
388 | perl -0 -pi -e 's/,\n/, /gm' \
389 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
391 sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
392 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
394 # Make sure we don't define any S_IS* macros in src/*.c files.
395 # Not a big deal, but they're already defined via system.h.
397 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
398 # This is a bit of a kludge, since it prevents use of the string
399 # even in comments, but for now it does the job with no false positives.
402 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
403 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
404 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
406 # Extract the list of authors from each file.
407 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
408 # Sometimes the string is on the same line as the #define...
409 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
410 # Sometimes the string is on the backslash-continued line after the #define.
411 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
412 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
413 ../AUTHORS: $(SOURCES)
417 echo "Here are the names of the programs in this package,"; \
418 echo "each followed by the name(s) of its author(s)."; \
420 for i in $(SOURCES); do \
421 a=`sed -n $(s1) $$i`; \
423 || a=`sed -n $(s2) $$i`; \
424 if test "$$a"; then \
425 prog=`echo $$i|sed 's/\.c$$//'`; \
426 echo "$$prog: $$a"; \
428 done | $(ASSORT) -u ) > $@-t
432 # The following rule is not designed to be portable,
433 # and relies on tools that not everyone has.
435 # Most functions in src/*.c should have static scope.
436 # Any that don't must be marked with `extern', but `main'
437 # and `usage' are exceptions. They're always extern, but
438 # don't need to be marked.
440 # The second nm|grep checks for file-scope variables with `extern' scope.
441 .PHONY: sc_tight_scope
442 sc_tight_scope: $(all_programs)
443 @t=exceptions-$$$$; \
444 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
445 ( printf 'main\nusage\n'; \
446 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
447 | grep -vE '^(extern |--)' | sed 's/ .*//'; \
448 perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' \
450 ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
452 | sed -n 's/.* T //p' \
453 | grep -Ev -f $$t && \
454 { echo 'the above functions should have static scope' 1>&2; \
456 ( printf '^program_name$$\n'; \
457 perl -ne '/^extern .*?\**(\w+);/ and print "^$$1\$$\n"' \
460 | sed -n 's/.* [BD] //p' \
461 | grep -Ev -f $$t && \
462 { echo 'the above variables should have static scope' 1>&2; \
465 # Use the just-built ./ginstall, when not cross-compiling.
466 # Override automake's install-one-at-a-time rule, when possible.
468 @(./ginstall --version) > /dev/null 2>&1 \
469 && install=./ginstall \
470 || install='$(INSTALL_PROGRAM)'; \
471 case '$(program_transform_name):$(EXEEXT)' in \
472 's,x,x,:') cu=cu-;; *) cu= ;; esac; \
473 $(MAKE) $(AM_MAKEFLAGS) binPROGRAMS_INSTALL="$$install" \
474 $${cu}install-binPROGRAMS
476 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
478 # The following rule is used only when --program-transform-name
479 # has not been used and there is no .exe "extension".
480 # Override the automake-generated rule so that we can install
481 # all binaries with a single install command. However, ...
482 # install ginstall and [ separately. "ginstall" because we rename
483 # it to "install", and "[" because using it unquoted will cause a
484 # syntax error with some shells. Be careful to install each of these
485 # exceptions only if it is to be installed (i.e., not excluded via
486 # --enable-no-install-program=PROG_LIST.
488 `echo "$(bin_PROGRAMS)" | sed 's/ *\<ginstall\> */ /;s/ *\[ */ /'`
489 d_bindir = $(DESTDIR)$(bindir)
490 .PHONY: cu-install-binPROGRAMS
491 cu-install-binPROGRAMS: $(bin_PROGRAMS)
493 test -z "$(bindir)" || $(MKDIR_P) "$(d_bindir)"
494 test x = 'x$(bin_PROGRAMS)' && exit || :
495 case '$(bin_PROGRAMS)' in *\[*) \
496 echo "$(binPROGRAMS_INSTALL) '[' '$(d_bindir)/['"; \
497 $(binPROGRAMS_INSTALL) '[' '$(d_bindir)/[';; esac
498 case '$(bin_PROGRAMS)' in *ginstall*) \
499 echo "$(binPROGRAMS_INSTALL) ginstall '$(d_bindir)/install'";\
500 $(binPROGRAMS_INSTALL) ginstall '$(d_bindir)/install';; esac
501 $(binPROGRAMS_INSTALL) $(filtered_PROGS) '$(d_bindir)'