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 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
73 # include modules defining variables like `optind', so libcoreutils.a
74 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
75 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
76 # replacement functions defined in libcoreutils.a.
77 LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
83 split_LDADD = $(LDADD)
84 timeout_LDADD = $(LDADD)
85 truncate_LDADD = $(LDADD)
87 # for eaccess in lib/euidaccess.c.
88 chcon_LDADD = $(LDADD) $(LIB_SELINUX)
89 cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
90 ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
91 mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
92 mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
93 mknod_LDADD = $(LDADD) $(LIB_SELINUX)
94 mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
95 runcon_LDADD = $(LDADD) $(LIB_SELINUX)
96 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
97 rm_LDADD = $(LDADD) $(LIB_EACCESS)
98 test_LDADD = $(LDADD) $(LIB_EACCESS)
99 # This is for the '[' program. Automake transliterates '[' to '_'.
100 __LDADD = $(LDADD) $(LIB_EACCESS)
102 # for clock_gettime and fdatasync
103 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
104 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
105 id_LDADD = $(LDADD) $(LIB_SELINUX)
106 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
107 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
108 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
109 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
110 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
111 tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
112 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
114 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
115 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
117 # for get_date and gettime
118 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
119 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
121 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
122 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
123 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
125 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
126 seq_LDADD = $(LDADD) $(POW_LIB)
128 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
129 # and the `nanosleep' reference in lib/xnanosleep.c.
130 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
132 sleep_LDADD = $(nanosec_libs)
133 tail_LDADD = $(nanosec_libs)
135 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
136 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
138 su_LDADD = $(LDADD) $(LIB_CRYPT)
140 dir_LDADD += $(LIB_ACL)
141 ls_LDADD += $(LIB_ACL)
142 vdir_LDADD += $(LIB_ACL)
143 cp_LDADD += $(LIB_ACL)
144 mv_LDADD += $(LIB_ACL)
145 ginstall_LDADD += $(LIB_ACL)
147 stat_LDADD = $(LDADD) $(LIB_SELINUX)
149 # Append $(LIBICONV) to each program that uses proper_name_utf8.
150 cat_LDADD += $(LIBICONV)
151 cp_LDADD += $(LIBICONV)
152 df_LDADD += $(LIBICONV)
153 du_LDADD += $(LIBICONV)
154 ptx_LDADD += $(LIBICONV)
155 split_LDADD += $(LIBICONV)
156 timeout_LDADD += $(LIBICONV)
157 truncate_LDADD += $(LIBICONV)
159 $(PROGRAMS): ../lib/libcoreutils.a
161 # Get the release year from ../lib/version-etc.c.
163 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
164 $(top_srcdir)/lib/version-etc.c`
166 all-local: su$(EXEEXT)
168 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
170 setuid_root_mode = a=rx,u+s
173 if test "$(INSTALL_SU)" = yes; then \
175 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
176 $(INSTALL_PROGRAM) $$p $(installed_su); \
177 echo " chown root $(installed_su)"; \
178 chown root $(installed_su); \
179 echo " chmod $(setuid_root_mode) $(installed_su)"; \
180 chmod $(setuid_root_mode) $(installed_su); \
185 install-root: su$(EXEEXT)
188 install-exec-hook: su$(EXEEXT)
189 @if test "$(INSTALL_SU)" = yes; then \
190 TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
193 ## See if we can create a setuid root executable in $(bindir).
194 ## If not, then don't even try to install su.
195 can_create_suid_root_executable=no; \
196 chown root $$TMPFILE > /dev/null 2>&1 \
197 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
198 && can_create_suid_root_executable=yes; \
200 if test $$can_create_suid_root_executable = yes; then \
203 echo "WARNING: insufficient access; not installing su"; \
204 echo "NOTE: to install su, run 'make install-root' as root"; \
205 rm -f $(installed_su); \
211 # Remove su only if it's one we installed.
212 @if test "$(INSTALL_SU)" = yes; then \
213 if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
214 echo " rm -f $(installed_su)"; \
215 rm -f $(installed_su); \
220 copy_sources = copy.c cp-hash.c
222 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
223 # confusion with the `install' target. The install rule transforms `ginstall'
224 # to install before applying any user-specified name transformations.
226 transform = s/ginstall/install/; $(program_transform_name)
227 ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
229 # This is for the '[' program. Automake transliterates '[' to '_'.
230 __SOURCES = lbracket.c
232 cp_SOURCES = cp.c $(copy_sources)
233 dir_SOURCES = ls.c ls-dir.c
234 vdir_SOURCES = ls.c ls-vdir.c
235 id_SOURCES = id.c group-list.c
236 groups_SOURCES = groups.c group-list.c
238 ls_SOURCES = ls.c ls-ls.c
239 chown_SOURCES = chown.c chown-core.c
240 chgrp_SOURCES = chgrp.c chown-core.c
241 kill_SOURCES = kill.c operand2sig.c
242 timeout_SOURCES = timeout.c operand2sig.c
244 mv_SOURCES = mv.c remove.c $(copy_sources)
245 rm_SOURCES = rm.c remove.c
247 mkdir_SOURCES = mkdir.c prog-fprintf.c
248 rmdir_SOURCES = rmdir.c prog-fprintf.c
250 uname_SOURCES = uname.c uname-uname.c
251 arch_SOURCES = uname.c uname-arch.c
253 md5sum_SOURCES = md5sum.c
254 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
255 sha1sum_SOURCES = md5sum.c
256 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
257 sha224sum_SOURCES = md5sum.c
258 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
259 sha256sum_SOURCES = md5sum.c
260 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
261 sha384sum_SOURCES = md5sum.c
262 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
263 sha512sum_SOURCES = md5sum.c
264 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
266 ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
268 editpl = sed -e 's,@''PERL''@,$(PERL),g'
270 BUILT_SOURCES += dircolors.h
271 dircolors.h: dcgen dircolors.hin
273 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
279 BUILT_SOURCES += wheel-size.h
280 wheel-size.h: Makefile.am
282 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
286 BUILT_SOURCES += wheel.h
287 wheel.h: wheel-gen.pl Makefile.am
289 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
293 # false exits nonzero even with --help or --version.
294 # test doesn't support --help or --version.
295 # Tell automake to exempt then from that installcheck test.
296 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
298 BUILT_SOURCES += fs.h
299 fs.h: stat.c extract-magic
301 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
305 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
307 # Sort in traditional ASCII order, regardless of the current locale;
308 # otherwise we may get into trouble with distinct strings that the
309 # current locale considers to be equal.
310 ASSORT = LC_ALL=C sort
318 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
319 | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
322 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
327 # Ensure that the list of programs in README matches the list
328 # of programs we can build.
329 check: check-README check-misc check-duplicate-no-install
333 echo $(all_programs) \
334 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
335 | $(ASSORT) -u > $(pm) && \
336 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
337 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
338 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
340 # Ensure that a by-default-not-installed program (listed in
341 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
342 # if that were to happen, it *would* be installed by default.
343 .PHONY: check-duplicate-no-install
344 check-duplicate-no-install: tr
345 test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
347 # Ensure that the list of programs and author names is accurate.
348 au_dotdot = authors-dotdot
349 au_actual = authors-actual
350 .PHONY: check-AUTHORS
351 check-AUTHORS: $(all_programs)
352 rm -f $(au_actual) $(au_dotdot)
353 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
354 | $(ASSORT) -u`; do \
355 test "$$i" = '[' && continue; \
357 if test "$$i" = install; then \
359 elif test "$$i" = test; then \
362 LC_ALL=en_US.UTF-8 ./$$exe --version \
363 | perl -0 -pi -e 's/,\n/, /gm' \
364 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
366 sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
367 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
369 # Make sure we don't define any S_IS* macros in src/*.c files.
370 # Not a big deal, but they're already defined via system.h.
372 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
373 # This is a bit of a kludge, since it prevents use of the string
374 # even in comments, but for now it does the job with no false positives.
377 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
378 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
379 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
381 # Extract the list of authors from each file.
382 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
383 # Sometimes the string is on the same line as the #define...
384 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
385 # Sometimes the string is on the backslash-continued line after the #define.
386 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
387 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
388 ../AUTHORS: $(SOURCES)
392 echo "Here are the names of the programs in this package,"; \
393 echo "each followed by the name(s) of its author(s)."; \
395 for i in $(SOURCES); do \
396 a=`sed -n $(s1) $$i`; \
398 || a=`sed -n $(s2) $$i`; \
399 if test "$$a"; then \
400 prog=`echo $$i|sed 's/\.c$$//'`; \
401 echo "$$prog: $$a"; \
403 done | $(ASSORT) -u ) > $@-t
407 # The following rule is not designed to be portable,
408 # and relies on tools that not everyone has.
410 # Most functions in src/*.c should have static scope.
411 # Any that don't must be marked with `extern', but `main'
412 # and `usage' are exceptions. They're always extern, but
413 # don't need to be marked.
415 # The second nm|grep checks for file-scope variables with `extern' scope.
416 .PHONY: sc_tight_scope
417 sc_tight_scope: $(all_programs)
418 @t=exceptions-$$$$; \
419 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
420 ( printf 'main\nusage\n'; \
421 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
422 | grep -vE '^(extern |--)' | sed 's/ .*//'; \
423 perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' \
425 ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
427 | sed -n 's/.* T //p' \
428 | grep -Ev -f $$t && \
429 { echo 'the above functions should have static scope' 1>&2; \
431 ( printf '^program_name$$\n'; \
432 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
433 $(noinst_HEADERS) ) > $$t; \
435 | sed -n 's/.* [BD] //p' \
436 | grep -Ev -f $$t && \
437 { echo 'the above variables should have static scope' 1>&2; \
440 .PHONY: cu-install-binPROGRAMS
442 @case '$(program_transform_name):$(EXEEXT)' in \
443 's,x,x,:') cu=cu-;; *) cu= ;; esac; \
444 $(MAKE) $(AM_MAKEFLAGS) binPROGRAMS_INSTALL=./ginstall \
445 $${cu}install-binPROGRAMS
447 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
449 # The following rule is used only when --program-transform-name
450 # has not been used and there is no .exe "extension".
451 # Override the automake-generated rule so that we can install
452 # all binaries with a single install command. However, ...
453 # install ginstall and [ separately. "ginstall" because we rename
454 # it to "install", and "[" because using it unquoted will cause a
455 # syntax error with some shells. Be careful to install each of these
456 # exceptions only if it is to be installed (i.e., not excluded via
457 # --enable-no-install-program=PROG_LIST.
459 `echo "$(bin_PROGRAMS)" | sed 's/ *\<ginstall\> */ /;s/ *\[ */ /'`
460 d_bindir = $(DESTDIR)$(bindir)
461 cu-install-binPROGRAMS: $(bin_PROGRAMS)
463 test -z "$(bindir)" || $(MKDIR_P) "$(d_bindir)"
464 test x = 'x$(bin_PROGRAMS)' && exit || :
465 case '$(bin_PROGRAMS)' in *\[*) \
466 echo "$(binPROGRAMS_INSTALL) '[' '$(d_bindir)/['"; \
467 $(binPROGRAMS_INSTALL) '[' '$(d_bindir)/[';; esac
468 case '$(bin_PROGRAMS)' in *ginstall*) \
469 echo "$(binPROGRAMS_INSTALL) ginstall '$(d_bindir)/install'";\
470 $(binPROGRAMS_INSTALL) ginstall '$(d_bindir)/install';; esac
471 $(binPROGRAMS_INSTALL) $(filtered_PROGS) '$(d_bindir)'