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)
85 # for eaccess in lib/euidaccess.c.
86 chcon_LDADD = $(LDADD) $(LIB_SELINUX)
87 cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
88 ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
89 mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
90 mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
91 mknod_LDADD = $(LDADD) $(LIB_SELINUX)
92 mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
93 runcon_LDADD = $(LDADD) $(LIB_SELINUX)
94 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
95 rm_LDADD = $(LDADD) $(LIB_EACCESS)
96 test_LDADD = $(LDADD) $(LIB_EACCESS)
97 # This is for the '[' program. Automake transliterates '[' to '_'.
98 __LDADD = $(LDADD) $(LIB_EACCESS)
100 # for clock_gettime and fdatasync
101 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
102 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
103 id_LDADD = $(LDADD) $(LIB_SELINUX)
104 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
105 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
106 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
107 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
108 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
109 tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
110 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
112 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
113 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
115 # for get_date and gettime
116 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
117 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
119 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
120 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
121 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
123 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
124 seq_LDADD = $(LDADD) $(POW_LIB)
126 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
127 # and the `nanosleep' reference in lib/xnanosleep.c.
128 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
130 sleep_LDADD = $(nanosec_libs)
131 tail_LDADD = $(nanosec_libs)
133 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
134 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
136 su_LDADD = $(LDADD) $(LIB_CRYPT)
138 dir_LDADD += $(LIB_ACL)
139 ls_LDADD += $(LIB_ACL)
140 vdir_LDADD += $(LIB_ACL)
141 cp_LDADD += $(LIB_ACL)
142 mv_LDADD += $(LIB_ACL)
143 ginstall_LDADD += $(LIB_ACL)
145 stat_LDADD = $(LDADD) $(LIB_SELINUX)
147 # Append $(LIBICONV) to each program that uses proper_name_utf8.
148 cat_LDADD += $(LIBICONV)
149 cp_LDADD += $(LIBICONV)
150 df_LDADD += $(LIBICONV)
151 du_LDADD += $(LIBICONV)
152 ptx_LDADD += $(LIBICONV)
153 split_LDADD += $(LIBICONV)
155 $(PROGRAMS): ../lib/libcoreutils.a
157 # Get the release year from ../lib/version-etc.c.
159 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
160 $(top_srcdir)/lib/version-etc.c`
162 all-local: su$(EXEEXT)
164 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
166 setuid_root_mode = a=rx,u+s
169 if test "$(INSTALL_SU)" = yes; then \
171 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
172 $(INSTALL_PROGRAM) $$p $(installed_su); \
173 echo " chown root $(installed_su)"; \
174 chown root $(installed_su); \
175 echo " chmod $(setuid_root_mode) $(installed_su)"; \
176 chmod $(setuid_root_mode) $(installed_su); \
181 install-root: su$(EXEEXT)
184 install-exec-hook: su$(EXEEXT)
185 @if test "$(INSTALL_SU)" = yes; then \
186 TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
189 ## See if we can create a setuid root executable in $(bindir).
190 ## If not, then don't even try to install su.
191 can_create_suid_root_executable=no; \
192 chown root $$TMPFILE > /dev/null 2>&1 \
193 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
194 && can_create_suid_root_executable=yes; \
196 if test $$can_create_suid_root_executable = yes; then \
199 echo "WARNING: insufficient access; not installing su"; \
200 echo "NOTE: to install su, run 'make install-root' as root"; \
201 rm -f $(installed_su); \
207 # Remove su only if it's one we installed.
208 @if test "$(INSTALL_SU)" = yes; then \
209 if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
210 echo " rm -f $(installed_su)"; \
211 rm -f $(installed_su); \
216 copy_sources = copy.c cp-hash.c
218 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
219 # confusion with the `install' target. The install rule transforms `ginstall'
220 # to install before applying any user-specified name transformations.
222 transform = s/ginstall/install/; $(program_transform_name)
223 ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
225 # This is for the '[' program. Automake transliterates '[' to '_'.
226 __SOURCES = lbracket.c
228 cp_SOURCES = cp.c $(copy_sources)
229 dir_SOURCES = ls.c ls-dir.c
230 vdir_SOURCES = ls.c ls-vdir.c
231 id_SOURCES = id.c group-list.c
232 groups_SOURCES = groups.c group-list.c
234 ls_SOURCES = ls.c ls-ls.c
235 chown_SOURCES = chown.c chown-core.c
236 chgrp_SOURCES = chgrp.c chown-core.c
237 kill_SOURCES = kill.c operand2sig.c
238 timeout_SOURCES = timeout.c operand2sig.c
240 mv_SOURCES = mv.c remove.c $(copy_sources)
241 rm_SOURCES = rm.c remove.c
243 mkdir_SOURCES = mkdir.c prog-fprintf.c
244 rmdir_SOURCES = rmdir.c prog-fprintf.c
246 uname_SOURCES = uname.c uname-uname.c
247 arch_SOURCES = uname.c uname-arch.c
249 md5sum_SOURCES = md5sum.c
250 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
251 sha1sum_SOURCES = md5sum.c
252 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
253 sha224sum_SOURCES = md5sum.c
254 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
255 sha256sum_SOURCES = md5sum.c
256 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
257 sha384sum_SOURCES = md5sum.c
258 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
259 sha512sum_SOURCES = md5sum.c
260 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
262 ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
264 editpl = sed -e 's,@''PERL''@,$(PERL),g'
266 BUILT_SOURCES += dircolors.h
267 dircolors.h: dcgen dircolors.hin
269 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
275 BUILT_SOURCES += wheel-size.h
276 wheel-size.h: Makefile.am
278 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
282 BUILT_SOURCES += wheel.h
283 wheel.h: wheel-gen.pl Makefile.am
285 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
289 # false exits nonzero even with --help or --version.
290 # test doesn't support --help or --version.
291 # Tell automake to exempt then from that installcheck test.
292 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
294 BUILT_SOURCES += fs.h
295 fs.h: stat.c extract-magic
297 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
301 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
303 # Sort in traditional ASCII order, regardless of the current locale;
304 # otherwise we may get into trouble with distinct strings that the
305 # current locale considers to be equal.
306 ASSORT = LC_ALL=C sort
314 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
315 | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
318 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
323 # Ensure that the list of programs in README matches the list
324 # of programs we can build.
325 check: check-README check-misc check-duplicate-no-install
329 echo $(all_programs) \
330 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
331 | $(ASSORT) -u > $(pm) && \
332 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
333 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
334 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
336 # Ensure that a by-default-not-installed program (listed in
337 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
338 # if that were to happen, it *would* be installed by default.
339 .PHONY: check-duplicate-no-install
340 check-duplicate-no-install: tr
341 test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
343 # Ensure that the list of programs and author names is accurate.
344 au_dotdot = authors-dotdot
345 au_actual = authors-actual
346 .PHONY: check-AUTHORS
347 check-AUTHORS: $(all_programs)
348 rm -f $(au_actual) $(au_dotdot)
349 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
350 | $(ASSORT) -u`; do \
351 test "$$i" = '[' && continue; \
353 if test "$$i" = install; then \
355 elif test "$$i" = test; then \
358 LC_ALL=en_US.UTF-8 ./$$exe --version \
359 | perl -0 -pi -e 's/,\n/, /gm' \
360 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
362 sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
363 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
365 # Make sure we don't define any S_IS* macros in src/*.c files.
366 # Not a big deal, but they're already defined via system.h.
368 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
369 # This is a bit of a kludge, since it prevents use of the string
370 # even in comments, but for now it does the job with no false positives.
373 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
374 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
375 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
377 # Extract the list of authors from each file.
378 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
379 # Sometimes the string is on the same line as the #define...
380 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
381 # Sometimes the string is on the backslash-continued line after the #define.
382 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
383 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
384 ../AUTHORS: $(SOURCES)
388 echo "Here are the names of the programs in this package,"; \
389 echo "each followed by the name(s) of its author(s)."; \
391 for i in $(SOURCES); do \
392 a=`sed -n $(s1) $$i`; \
394 || a=`sed -n $(s2) $$i`; \
395 if test "$$a"; then \
396 prog=`echo $$i|sed 's/\.c$$//'`; \
397 echo "$$prog: $$a"; \
399 done | $(ASSORT) -u ) > $@-t
403 # The following rule is not designed to be portable,
404 # and relies on tools that not everyone has.
406 # Most functions in src/*.c should have static scope.
407 # Any that don't must be marked with `extern', but `main'
408 # and `usage' are exceptions. They're always extern, but
409 # don't need to be marked.
411 # The second nm|grep checks for file-scope variables with `extern' scope.
412 .PHONY: sc_tight_scope
413 sc_tight_scope: $(all_programs)
414 @t=exceptions-$$$$; \
415 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
416 ( printf 'main\nusage\n'; \
417 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
418 | grep -vE '^(extern |--)' | sed 's/ .*//'; \
419 perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' \
421 ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
423 | sed -n 's/.* T //p' \
424 | grep -Ev -f $$t && \
425 { echo 'the above functions should have static scope' 1>&2; \
427 ( printf '^program_name$$\n'; \
428 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
429 $(noinst_HEADERS) ) > $$t; \
431 | sed -n 's/.* [BD] //p' \
432 | grep -Ev -f $$t && \
433 { echo 'the above variables should have static scope' 1>&2; \
436 .PHONY: cu-install-binPROGRAMS
438 @case '$(program_transform_name):$(EXEEXT)' in \
439 's,x,x,:') cu=cu-;; *) cu= ;; esac; \
440 $(MAKE) $(AM_MAKEFLAGS) binPROGRAMS_INSTALL=./ginstall \
441 $${cu}install-binPROGRAMS
443 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
445 # The following rule is used only when --program-transform-name
446 # has not been used and there is no .exe "extension".
447 # Override the automake-generated rule so that we can install
448 # all binaries with a single install command. However, ...
449 # install ginstall and [ separately. "ginstall" because we rename
450 # it to "install", and "[" because using it unquoted will cause a
451 # syntax error with some shells. Be careful to install each of these
452 # exceptions only if it is to be installed (i.e., not excluded via
453 # --enable-no-install-program=PROG_LIST.
455 `echo "$(bin_PROGRAMS)" | sed 's/ *\<ginstall\> */ /;s/ *\[ */ /'`
456 d_bindir = $(DESTDIR)$(bindir)
457 cu-install-binPROGRAMS: $(bin_PROGRAMS)
459 test -z "$(bindir)" || $(MKDIR_P) "$(d_bindir)"
460 test x = 'x$(bin_PROGRAMS)' && exit || :
461 case '$(bin_PROGRAMS)' in *\[*) \
462 echo "$(binPROGRAMS_INSTALL) '[' '$(d_bindir)/['"; \
463 $(binPROGRAMS_INSTALL) '[' '$(d_bindir)/[';; esac
464 case '$(bin_PROGRAMS)' in *ginstall*) \
465 echo "$(binPROGRAMS_INSTALL) ginstall '$(d_bindir)/install'";\
466 $(binPROGRAMS_INSTALL) ginstall '$(d_bindir)/install';; esac
467 $(binPROGRAMS_INSTALL) $(filtered_PROGS) '$(d_bindir)'