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 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 \
46 bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
48 noinst_PROGRAMS = setuidgid
63 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
64 groups.sh wheel-gen.pl extract-magic c99-to-c89.diff
66 CLEANFILES = $(SCRIPTS) su
68 AM_CPPFLAGS = -I$(top_srcdir)/lib
70 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
71 # include modules defining variables like `optind', so libcoreutils.a
72 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
73 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
74 # replacement functions defined in libcoreutils.a.
75 LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
77 # for eaccess in lib/euidaccess.c.
78 chcon_LDADD = $(LDADD) $(LIB_SELINUX)
79 cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
80 ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
81 mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
82 mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
83 mknod_LDADD = $(LDADD) $(LIB_SELINUX)
84 mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
85 runcon_LDADD = $(LDADD) $(LIB_SELINUX)
86 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
87 rm_LDADD = $(LDADD) $(LIB_EACCESS)
88 test_LDADD = $(LDADD) $(LIB_EACCESS)
89 # This is for the '[' program. Automake transliterates '[' to '_'.
90 __LDADD = $(LDADD) $(LIB_EACCESS)
92 # for clock_gettime and fdatasync
93 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
94 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
95 id_LDADD = $(LDADD) $(LIB_SELINUX)
96 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
97 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
98 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
99 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
100 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
101 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
103 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
104 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
106 # for get_date and gettime
107 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
108 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
110 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
111 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
112 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
114 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
115 seq_LDADD = $(LDADD) $(POW_LIB)
117 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
118 # and the `nanosleep' reference in lib/xnanosleep.c.
119 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
121 sleep_LDADD = $(nanosec_libs)
122 tail_LDADD = $(nanosec_libs)
124 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
125 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
127 su_LDADD = $(LDADD) $(LIB_CRYPT)
129 dir_LDADD += $(LIB_ACL)
130 ls_LDADD += $(LIB_ACL)
131 vdir_LDADD += $(LIB_ACL)
132 cp_LDADD += $(LIB_ACL)
133 mv_LDADD += $(LIB_ACL)
134 ginstall_LDADD += $(LIB_ACL)
136 stat_LDADD = $(LDADD) $(LIB_SELINUX)
138 $(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`
145 # This depends on 'Makefile', so that version changes
146 #(reflected in Makefile's VERSION definition)
147 # are reflected into groups --version also between releases.
148 groups: groups.sh Makefile
151 -e 's!@''bindir''@!$(bindir)!' \
152 -e 's/@''RELEASE_YEAR'@/$(RELEASE_YEAR)/ \
153 -e 's/@''PACKAGE_NAME''@/$(PACKAGE_NAME)/' \
154 -e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
155 -e 's/@''VERSION''@/$(VERSION)/' $(srcdir)/groups.sh > $@-t
159 all-local: su$(EXEEXT)
161 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
163 setuid_root_mode = a=rx,u+s
166 if test "$(INSTALL_SU)" = yes; then \
168 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
169 $(INSTALL_PROGRAM) $$p $(installed_su); \
170 echo " chown root $(installed_su)"; \
171 chown root $(installed_su); \
172 echo " chmod $(setuid_root_mode) $(installed_su)"; \
173 chmod $(setuid_root_mode) $(installed_su); \
178 install-root: su$(EXEEXT)
181 install-exec-hook: su$(EXEEXT)
182 @if test "$(INSTALL_SU)" = yes; then \
183 TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
186 ## See if we can create a setuid root executable in $(bindir).
187 ## If not, then don't even try to install su.
188 can_create_suid_root_executable=no; \
189 chown root $$TMPFILE > /dev/null 2>&1 \
190 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
191 && can_create_suid_root_executable=yes; \
193 if test $$can_create_suid_root_executable = yes; then \
196 echo "WARNING: insufficient access; not installing su"; \
197 echo "NOTE: to install su, run 'make install-root' as root"; \
198 rm -f $(installed_su); \
204 # Remove su only if it's one we installed.
205 @if test "$(INSTALL_SU)" = yes; then \
206 if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
207 echo " rm -f $(installed_su)"; \
208 rm -f $(installed_su); \
213 copy_sources = copy.c cp-hash.c
215 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
216 # confusion with the `install' target. The install rule transforms `ginstall'
217 # to install before applying any user-specified name transformations.
219 transform = s/ginstall/install/; @program_transform_name@
220 ginstall_SOURCES = install.c $(copy_sources)
222 # This is for the '[' program. Automake transliterates '[' to '_'.
223 __SOURCES = lbracket.c
225 cp_SOURCES = cp.c $(copy_sources)
226 dir_SOURCES = ls.c ls-dir.c
227 vdir_SOURCES = ls.c ls-vdir.c
229 ls_SOURCES = ls.c ls-ls.c
230 chown_SOURCES = chown.c chown-core.c
231 chgrp_SOURCES = chgrp.c chown-core.c
233 mv_SOURCES = mv.c remove.c $(copy_sources)
234 rm_SOURCES = rm.c remove.c
236 uname_SOURCES = uname.c uname-uname.c
237 arch_SOURCES = uname.c uname-arch.c
239 md5sum_SOURCES = md5sum.c
240 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
241 sha1sum_SOURCES = md5sum.c
242 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
243 sha224sum_SOURCES = md5sum.c
244 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
245 sha256sum_SOURCES = md5sum.c
246 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
247 sha384sum_SOURCES = md5sum.c
248 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
249 sha512sum_SOURCES = md5sum.c
250 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
252 editpl = sed -e 's,@''PERL''@,$(PERL),g'
254 BUILT_SOURCES += dircolors.h
255 dircolors.h: dcgen dircolors.hin
257 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
263 BUILT_SOURCES += wheel-size.h
264 wheel-size.h: Makefile.am
266 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
270 BUILT_SOURCES += wheel.h
271 wheel.h: wheel-gen.pl Makefile.am
273 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
277 # false exits nonzero even with --help or --version.
278 # test doesn't support --help or --version.
279 # Tell automake to exempt then from that installcheck test.
280 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
282 BUILT_SOURCES += fs.h
283 fs.h: stat.c extract-magic
285 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
289 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
291 # Sort in traditional ASCII order, regardless of the current locale;
292 # otherwise we may get into trouble with distinct strings that the
293 # current locale considers to be equal.
294 ASSORT = LC_ALL=C sort
302 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
303 | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u
306 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
311 # Ensure that the list of programs in README matches the list
312 # of programs we can build.
313 check: check-README check-misc check-duplicate-no-install
317 echo $(all_programs) \
318 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
319 | $(ASSORT) -u > $(pm) && \
320 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
321 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
322 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
324 # Ensure that a by-default-not-installed program (listed in
325 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
326 # if that were to happen, it *would* be installed by default.
327 .PHONY: check-duplicate-no-install
328 check-duplicate-no-install: tr
329 test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
331 # Ensure that the list of programs and author names is accurate.
332 au_dotdot = authors-dotdot
333 au_actual = authors-actual
334 .PHONY: check-AUTHORS
335 check-AUTHORS: $(all_programs)
336 rm -f $(au_actual) $(au_dotdot)
337 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
338 | $(ASSORT) -u`; do \
339 test "$$i" = '[' && continue; \
341 if test "$$i" = install; then \
343 elif test "$$i" = test; then \
347 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
349 sed -n '/:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
350 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
352 # Make sure we don't define any S_IS* macros in src/*.c files.
353 # Not a big deal, but they're already defined via system.h.
355 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
356 # This is a bit of a kludge, since it prevents use of the string
357 # even in comments, but for now it does the job with no false positives.
360 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
361 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
362 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
364 # Extract the list of authors from each file.
365 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
366 # Sometimes the string is on the same line as the #define...
367 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
368 # Sometimes the string is on the backslash-continued line after the #define.
369 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
370 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
371 ../AUTHORS: $(SOURCES)
375 echo "Here are the names of the programs in this package,"; \
376 echo "each followed by the name(s) of its author(s)."; \
378 for i in $(SOURCES); do \
379 a=`sed -n $(s1) $$i`; \
381 || a=`sed -n $(s2) $$i`; \
382 if test "$$a"; then \
383 prog=`echo $$i|sed 's/\.c$$//'`; \
384 echo "$$prog: $$a"; \
386 done | $(ASSORT) -u ) > $@-t
390 # The following rule is not designed to be portable,
391 # and relies on tools that not everyone has.
393 # Most functions in src/*.c should have static scope.
394 # Any that don't must be marked with `extern', but `main'
395 # and `usage' are exceptions. They're always extern, but
396 # don't need to be marked.
398 # The second nm|grep checks for file-scope variables with `extern' scope.
399 .PHONY: sc_tight_scope
400 sc_tight_scope: $(all_programs)
401 @t=exceptions-$$$$; \
402 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
403 ( printf '^main$$\n^usage$$\n'; \
404 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
405 | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
407 | sed -n 's/.* T //p' \
408 | grep -Ev -f $$t && \
409 { echo 'the above functions should have static scope' 1>&2; \
411 ( printf '^program_name$$\n'; \
412 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
413 $(noinst_HEADERS) ) > $$t; \
415 | sed -n 's/.* [BD] //p' \
416 | grep -Ev -f $$t && \
417 { echo 'the above variables should have static scope' 1>&2; \