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 true tty whoami yes \
45 bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
47 noinst_PROGRAMS = setuidgid
64 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
65 wheel-gen.pl extract-magic c99-to-c89.diff
67 CLEANFILES = $(SCRIPTS) su
69 AM_CPPFLAGS = -I$(top_srcdir)/lib
71 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
72 # include modules defining variables like `optind', so libcoreutils.a
73 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
74 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
75 # replacement functions defined in libcoreutils.a.
76 LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
78 # for eaccess in lib/euidaccess.c.
79 chcon_LDADD = $(LDADD) $(LIB_SELINUX)
80 cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
81 ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
82 mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
83 mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
84 mknod_LDADD = $(LDADD) $(LIB_SELINUX)
85 mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
86 runcon_LDADD = $(LDADD) $(LIB_SELINUX)
87 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
88 rm_LDADD = $(LDADD) $(LIB_EACCESS)
89 test_LDADD = $(LDADD) $(LIB_EACCESS)
90 # This is for the '[' program. Automake transliterates '[' to '_'.
91 __LDADD = $(LDADD) $(LIB_EACCESS)
93 # for clock_gettime and fdatasync
94 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
95 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
96 id_LDADD = $(LDADD) $(LIB_SELINUX)
97 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
98 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
99 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
100 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
101 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
102 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
104 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
105 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
107 # for get_date and gettime
108 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
109 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
111 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
112 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
113 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
115 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
116 seq_LDADD = $(LDADD) $(POW_LIB)
118 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
119 # and the `nanosleep' reference in lib/xnanosleep.c.
120 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
122 sleep_LDADD = $(nanosec_libs)
123 tail_LDADD = $(nanosec_libs)
125 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
126 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
128 su_LDADD = $(LDADD) $(LIB_CRYPT)
130 dir_LDADD += $(LIB_ACL)
131 ls_LDADD += $(LIB_ACL)
132 vdir_LDADD += $(LIB_ACL)
133 cp_LDADD += $(LIB_ACL)
134 mv_LDADD += $(LIB_ACL)
135 ginstall_LDADD += $(LIB_ACL)
137 stat_LDADD = $(LDADD) $(LIB_SELINUX)
139 $(PROGRAMS): ../lib/libcoreutils.a
141 # Get the release year from ../lib/version-etc.c.
143 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
144 $(top_srcdir)/lib/version-etc.c`
146 all-local: su$(EXEEXT)
148 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
150 setuid_root_mode = a=rx,u+s
153 if test "$(INSTALL_SU)" = yes; then \
155 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
156 $(INSTALL_PROGRAM) $$p $(installed_su); \
157 echo " chown root $(installed_su)"; \
158 chown root $(installed_su); \
159 echo " chmod $(setuid_root_mode) $(installed_su)"; \
160 chmod $(setuid_root_mode) $(installed_su); \
165 install-root: su$(EXEEXT)
168 install-exec-hook: su$(EXEEXT)
169 @if test "$(INSTALL_SU)" = yes; then \
170 TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
173 ## See if we can create a setuid root executable in $(bindir).
174 ## If not, then don't even try to install su.
175 can_create_suid_root_executable=no; \
176 chown root $$TMPFILE > /dev/null 2>&1 \
177 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
178 && can_create_suid_root_executable=yes; \
180 if test $$can_create_suid_root_executable = yes; then \
183 echo "WARNING: insufficient access; not installing su"; \
184 echo "NOTE: to install su, run 'make install-root' as root"; \
185 rm -f $(installed_su); \
191 # Remove su only if it's one we installed.
192 @if test "$(INSTALL_SU)" = yes; then \
193 if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
194 echo " rm -f $(installed_su)"; \
195 rm -f $(installed_su); \
200 copy_sources = copy.c cp-hash.c
202 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
203 # confusion with the `install' target. The install rule transforms `ginstall'
204 # to install before applying any user-specified name transformations.
206 transform = s/ginstall/install/; @program_transform_name@
207 ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
209 # This is for the '[' program. Automake transliterates '[' to '_'.
210 __SOURCES = lbracket.c
212 cp_SOURCES = cp.c $(copy_sources)
213 dir_SOURCES = ls.c ls-dir.c
214 vdir_SOURCES = ls.c ls-vdir.c
215 id_SOURCES = id.c group-list.c
216 groups_SOURCES = groups.c group-list.c
218 ls_SOURCES = ls.c ls-ls.c
219 chown_SOURCES = chown.c chown-core.c
220 chgrp_SOURCES = chgrp.c chown-core.c
222 mv_SOURCES = mv.c remove.c $(copy_sources)
223 rm_SOURCES = rm.c remove.c
225 mkdir_SOURCES = mkdir.c prog-fprintf.c
226 rmdir_SOURCES = rmdir.c prog-fprintf.c
228 uname_SOURCES = uname.c uname-uname.c
229 arch_SOURCES = uname.c uname-arch.c
231 md5sum_SOURCES = md5sum.c
232 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
233 sha1sum_SOURCES = md5sum.c
234 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
235 sha224sum_SOURCES = md5sum.c
236 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
237 sha256sum_SOURCES = md5sum.c
238 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
239 sha384sum_SOURCES = md5sum.c
240 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
241 sha512sum_SOURCES = md5sum.c
242 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
244 editpl = sed -e 's,@''PERL''@,$(PERL),g'
246 BUILT_SOURCES += dircolors.h
247 dircolors.h: dcgen dircolors.hin
249 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
255 BUILT_SOURCES += wheel-size.h
256 wheel-size.h: Makefile.am
258 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
262 BUILT_SOURCES += wheel.h
263 wheel.h: wheel-gen.pl Makefile.am
265 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
269 # false exits nonzero even with --help or --version.
270 # test doesn't support --help or --version.
271 # Tell automake to exempt then from that installcheck test.
272 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
274 BUILT_SOURCES += fs.h
275 fs.h: stat.c extract-magic
277 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
281 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
283 # Sort in traditional ASCII order, regardless of the current locale;
284 # otherwise we may get into trouble with distinct strings that the
285 # current locale considers to be equal.
286 ASSORT = LC_ALL=C sort
294 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
295 | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
298 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
303 # Ensure that the list of programs in README matches the list
304 # of programs we can build.
305 check: check-README check-misc check-duplicate-no-install
309 echo $(all_programs) \
310 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
311 | $(ASSORT) -u > $(pm) && \
312 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
313 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
314 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
316 # Ensure that a by-default-not-installed program (listed in
317 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
318 # if that were to happen, it *would* be installed by default.
319 .PHONY: check-duplicate-no-install
320 check-duplicate-no-install: tr
321 test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
323 # Ensure that the list of programs and author names is accurate.
324 au_dotdot = authors-dotdot
325 au_actual = authors-actual
326 .PHONY: check-AUTHORS
327 check-AUTHORS: $(all_programs)
328 rm -f $(au_actual) $(au_dotdot)
329 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
330 | $(ASSORT) -u`; do \
331 test "$$i" = '[' && continue; \
333 if test "$$i" = install; then \
335 elif test "$$i" = test; then \
339 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
341 sed -n '/:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
342 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
344 # Make sure we don't define any S_IS* macros in src/*.c files.
345 # Not a big deal, but they're already defined via system.h.
347 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
348 # This is a bit of a kludge, since it prevents use of the string
349 # even in comments, but for now it does the job with no false positives.
352 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
353 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
354 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
356 # Extract the list of authors from each file.
357 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
358 # Sometimes the string is on the same line as the #define...
359 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
360 # Sometimes the string is on the backslash-continued line after the #define.
361 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
362 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
363 ../AUTHORS: $(SOURCES)
367 echo "Here are the names of the programs in this package,"; \
368 echo "each followed by the name(s) of its author(s)."; \
370 for i in $(SOURCES); do \
371 a=`sed -n $(s1) $$i`; \
373 || a=`sed -n $(s2) $$i`; \
374 if test "$$a"; then \
375 prog=`echo $$i|sed 's/\.c$$//'`; \
376 echo "$$prog: $$a"; \
378 done | $(ASSORT) -u ) > $@-t
382 # The following rule is not designed to be portable,
383 # and relies on tools that not everyone has.
385 # Most functions in src/*.c should have static scope.
386 # Any that don't must be marked with `extern', but `main'
387 # and `usage' are exceptions. They're always extern, but
388 # don't need to be marked.
390 # The second nm|grep checks for file-scope variables with `extern' scope.
391 .PHONY: sc_tight_scope
392 sc_tight_scope: $(all_programs)
393 @t=exceptions-$$$$; \
394 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
395 ( printf 'main\nusage\n'; \
396 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
397 | grep -vE '^(extern |--)' | sed 's/ .*//'; \
398 perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' \
400 ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
402 | sed -n 's/.* T //p' \
403 | grep -Ev -f $$t && \
404 { echo 'the above functions should have static scope' 1>&2; \
406 ( printf '^program_name$$\n'; \
407 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
408 $(noinst_HEADERS) ) > $$t; \
410 | sed -n 's/.* [BD] //p' \
411 | grep -Ev -f $$t && \
412 { echo 'the above variables should have static scope' 1>&2; \