1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 ## Copyright (C) 1990, 1991, 1993-2007 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 2, or (at your option)
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, write to the Free Software Foundation,
17 ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 EXTRA_PROGRAMS = chroot df hostid nice pinky stty su uname uptime users who
22 bin_PROGRAMS = [ chgrp chown chmod cp dd dircolors du \
23 ginstall link ln dir vdir ls mkdir \
24 mkfifo mknod mv nohup readlink rm rmdir shred stat sync touch unlink \
25 cat cksum comm csplit cut expand fmt fold head join md5sum \
26 nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
27 shuf sort split sum tac tail tr tsort unexpand uniq wc \
28 basename date dirname echo env expr factor false \
29 hostname id kill logname pathchk printenv printf pwd seq sleep tee \
30 test true tty whoami yes \
32 $(OPTIONAL_BIN_PROGS) $(DF_PROG)
34 noinst_PROGRAMS = setuidgid
48 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
49 groups.sh wheel-gen.pl extract-magic c99-to-c89.diff
51 CLEANFILES = $(SCRIPTS) su
53 AM_CPPFLAGS = -I$(top_srcdir)/lib
55 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
56 # include modules defining variables like `optind', so libcoreutils.a
57 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
58 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
59 # replacement functions defined in libcoreutils.a.
60 LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
62 # for eaccess in lib/euidaccess.c.
63 cp_LDADD = $(LDADD) $(LIB_EACCESS)
64 ginstall_LDADD = $(LDADD) $(LIB_EACCESS)
65 mv_LDADD = $(LDADD) $(LIB_EACCESS)
66 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
67 rm_LDADD = $(LDADD) $(LIB_EACCESS)
68 test_LDADD = $(LDADD) $(LIB_EACCESS)
69 # This is for the '[' program. Automake transliterates '[' to '_'.
70 __LDADD = $(LDADD) $(LIB_EACCESS)
72 # for clock_gettime and fdatasync
73 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
74 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
75 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
76 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
77 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
78 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
79 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
81 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
82 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
84 # for get_date and gettime
85 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
86 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
88 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
89 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
90 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
92 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
93 seq_LDADD = $(LDADD) $(POW_LIB)
95 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
96 # and the `nanosleep' reference in lib/xnanosleep.c.
97 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
99 sleep_LDADD = $(nanosec_libs)
100 tail_LDADD = $(nanosec_libs)
102 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
103 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
105 su_LDADD = $(LDADD) $(LIB_CRYPT)
107 dir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
108 ls_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
109 vdir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL)
110 cp_LDADD += $(LIB_ACL)
111 mv_LDADD += $(LIB_ACL)
112 ginstall_LDADD += $(LIB_ACL)
114 $(PROGRAMS): ../lib/libcoreutils.a
118 # Get the release year from ../lib/version-etc.c.
120 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
121 $(top_srcdir)/lib/version-etc.c`
126 -e 's!@''bindir''@!$(bindir)!' \
127 -e 's/@''RELEASE_YEAR'@/$(RELEASE_YEAR)/ \
128 -e 's/@''GNU_PACKAGE''@/$(GNU_PACKAGE)/' \
129 -e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
130 -e 's/@''VERSION''@/$(VERSION)/' $< > $@-t
134 all-local: su$(EXEEXT)
136 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
138 setuid_root_mode = a=rx,u+s
142 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
143 $(INSTALL_PROGRAM) $$p $(installed_su); \
144 echo " chown root $(installed_su)"; \
145 chown root $(installed_su); \
146 echo " chmod $(setuid_root_mode) $(installed_su)"; \
147 chmod $(setuid_root_mode) $(installed_su)
149 install-root: su$(EXEEXT)
152 install-exec-local: su$(EXEEXT)
153 @TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
156 ## See if we can create a setuid root executable in $(bindir).
157 ## If not, then don't even try to install su.
158 can_create_suid_root_executable=no; \
159 chown root $$TMPFILE > /dev/null 2>&1 \
160 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
161 && can_create_suid_root_executable=yes; \
163 if test $$can_create_suid_root_executable = yes; then \
166 echo "WARNING: insufficient access; not installing su"; \
167 echo "NOTE: to install su, run 'make install-root' as root"; \
171 # Remove su only if it's one we installed.
172 @if grep '$(GNU_PACKAGE)' $(installed_su) > /dev/null 2>&1; then \
173 echo " rm -f $(installed_su)"; \
174 rm -f $(installed_su); \
177 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
178 # confusion with the `install' target. The install rule transforms `ginstall'
179 # to install before applying any user-specified name transformations.
181 transform = s/ginstall/install/; @program_transform_name@
182 ginstall_SOURCES = install.c copy.c cp-hash.c
184 # This is for the '[' program. Automake transliterates '[' to '_'.
185 __SOURCES = lbracket.c
187 cp_SOURCES = cp.c copy.c cp-hash.c
188 dir_SOURCES = ls.c ls-dir.c
189 vdir_SOURCES = ls.c ls-vdir.c
190 ls_SOURCES = ls.c ls-ls.c
191 chown_SOURCES = chown.c chown-core.c
192 chgrp_SOURCES = chgrp.c chown-core.c
194 mv_SOURCES = mv.c copy.c cp-hash.c remove.c
195 rm_SOURCES = rm.c remove.c
197 md5sum_SOURCES = md5sum.c
198 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
199 sha1sum_SOURCES = md5sum.c
200 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
201 sha224sum_SOURCES = md5sum.c
202 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
203 sha256sum_SOURCES = md5sum.c
204 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
205 sha384sum_SOURCES = md5sum.c
206 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
207 sha512sum_SOURCES = md5sum.c
208 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
210 editpl = sed -e 's,@''PERL''@,$(PERL),g'
212 BUILT_SOURCES += dircolors.h
213 dircolors.h: dcgen dircolors.hin
215 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
221 BUILT_SOURCES += wheel-size.h
222 wheel-size.h: Makefile.am
224 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
228 BUILT_SOURCES += wheel.h
229 wheel.h: wheel-gen.pl Makefile.am
231 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
235 # false exits nonzero even with --help or --version.
236 # test doesn't support --help or --version.
237 # Tell automake to exempt then from that installcheck test.
238 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
240 BUILT_SOURCES += fs.h
241 fs.h: stat.c extract-magic
243 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
247 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
249 # Sort in traditional ASCII order, regardless of the current locale;
250 # otherwise we may get into trouble with distinct strings that the
251 # current locale considers to be equal.
252 ASSORT = LC_ALL=C sort
260 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
265 # Ensure that the list of programs in README matches the list
266 # of programs we can build.
267 check: check-README check-misc
271 echo $(all_programs) \
272 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
273 | $(ASSORT) -u > $(pm) && \
274 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
275 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
276 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
278 # Ensure that the list of programs and author names is accurate.
279 au_dotdot = authors-dotdot
280 au_actual = authors-actual
281 .PHONY: check-AUTHORS
282 check-AUTHORS: $(all_programs)
283 rm -f $(au_actual) $(au_dotdot)
284 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
285 | $(ASSORT) -u`; do \
286 test "$$i" = '[' && continue; \
288 if test "$$i" = install; then \
290 elif test "$$i" = test; then \
294 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
296 sed -n '/:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
297 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
299 # Make sure we don't define any S_IS* macros in src/*.c files.
300 # Not a big deal, but they're already defined via system.h.
302 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
303 # This is a bit of a kludge, since it prevents use of the string
304 # even in comments, but for now it does the job with no false positives.
307 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
308 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
309 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
311 # Extract the list of authors from each file.
312 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
313 # Sometimes the string is on the same line as the #define...
314 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
315 # Sometimes the string is on the backslash-continued line after the #define.
316 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
317 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
318 ../AUTHORS: $(SOURCES)
322 echo "Here are the names of the programs in this package,"; \
323 echo "each followed by the name(s) of its author(s)."; \
325 for i in $(SOURCES); do \
326 a=`sed -n $(s1) $$i`; \
328 || a=`sed -n $(s2) $$i`; \
329 if test "$$a"; then \
330 prog=`echo $$i|sed 's/\.c$$//'`; \
331 echo "$$prog: $$a"; \
333 done | $(ASSORT) -u ) > $@-t
337 # The following rule is not designed to be portable,
338 # and relies on tools that not everyone has.
340 # Most functions in src/*.c should have static scope.
341 # Any that don't must be marked with `extern', but `main'
342 # and `usage' are exceptions. They're always extern, but
343 # don't need to be marked.
345 # The second nm|grep checks for file-scope variables with `extern' scope.
346 .PHONY: sc_tight_scope
347 sc_tight_scope: $(all_programs)
348 @t=exceptions-$$$$; \
349 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
350 ( printf '^main$$\n^usage$$\n'; \
351 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
352 | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
354 | sed -n 's/.* T //p' \
355 | grep -Ev -f $$t && \
356 { echo 'the above functions should have static scope' 1>&2; \
358 ( printf '^program_name$$\n'; \
359 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
360 $(noinst_HEADERS) ) > $$t; \
362 | sed -n 's/.* [BD] //p' \
363 | grep -Ev -f $$t && \
364 { echo 'the above variables should have static scope' 1>&2; \