1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 ## Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 ## 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2, or (at your option)
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software Foundation,
18 ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 EXTRA_PROGRAMS = chroot df hostid nice pinky stty su uname uptime users who
23 bin_PROGRAMS = [ chgrp chown chmod cp dd dircolors du \
24 ginstall link ln dir vdir ls mkdir \
25 mkfifo mknod mv nohup readlink rm rmdir shred stat sync touch unlink \
26 cat cksum comm csplit cut expand fmt fold head join md5sum \
27 nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
28 shuf sort split sum tac tail tr tsort unexpand uniq wc \
29 basename date dirname echo env expr factor false \
30 hostname id kill logname pathchk printenv printf pwd seq sleep tee \
31 test true tty whoami yes \
33 $(OPTIONAL_BIN_PROGS) $(DF_PROG)
35 noinst_PROGRAMS = setuidgid
49 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
50 groups.sh wheel-gen.pl extract-magic c99-to-c89.diff
52 CLEANFILES = $(SCRIPTS) su
54 AM_CPPFLAGS = -I$(top_srcdir)/lib
56 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
57 # include modules defining variables like `optind', so libcoreutils.a
58 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
59 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
60 # replacement functions defined in libcoreutils.a.
61 LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
63 # for eaccess in lib/euidaccess.c.
64 cp_LDADD = $(LDADD) $(LIB_EACCESS)
65 ginstall_LDADD = $(LDADD) $(LIB_EACCESS)
66 mv_LDADD = $(LDADD) $(LIB_EACCESS)
67 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
68 rm_LDADD = $(LDADD) $(LIB_EACCESS)
69 test_LDADD = $(LDADD) $(LIB_EACCESS)
70 # This is for the '[' program. Automake transliterates '[' to '_'.
71 __LDADD = $(LDADD) $(LIB_EACCESS)
73 # for clock_gettime and fdatasync
74 dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
75 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
76 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
77 pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
78 shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
79 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
80 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
82 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
83 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
85 # for get_date and gettime
86 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
87 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
89 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
90 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
91 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
93 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
94 seq_LDADD = $(LDADD) $(POW_LIB)
96 # If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
97 # and the `nanosleep' reference in lib/xnanosleep.c.
98 nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
100 sleep_LDADD = $(nanosec_libs)
101 tail_LDADD = $(nanosec_libs)
103 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
104 uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
106 su_LDADD = $(LDADD) $(LIB_CRYPT)
108 dir_LDADD += $(LIB_ACL)
109 ls_LDADD += $(LIB_ACL)
110 vdir_LDADD += $(LIB_ACL)
111 cp_LDADD += $(LIB_ACL)
112 mv_LDADD += $(LIB_ACL)
113 ginstall_LDADD += $(LIB_ACL)
115 $(PROGRAMS): ../lib/libcoreutils.a
122 -e 's!@''bindir''@!$(bindir)!' \
123 -e 's/@''GNU_PACKAGE''@/$(GNU_PACKAGE)/' \
124 -e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
125 -e 's/@''VERSION''@/$(VERSION)/' $< > $@-t
129 all-local: su$(EXEEXT)
131 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
133 setuid_root_mode = a=rx,u+s
137 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
138 $(INSTALL_PROGRAM) $$p $(installed_su); \
139 echo " chown root $(installed_su)"; \
140 chown root $(installed_su); \
141 echo " chmod $(setuid_root_mode) $(installed_su)"; \
142 chmod $(setuid_root_mode) $(installed_su)
144 install-root: su$(EXEEXT)
147 install-exec-local: su$(EXEEXT)
148 @TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
151 ## See if we can create a setuid root executable in $(bindir).
152 ## If not, then don't even try to install su.
153 can_create_suid_root_executable=no; \
154 chown root $$TMPFILE > /dev/null 2>&1 \
155 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
156 && can_create_suid_root_executable=yes; \
158 if test $$can_create_suid_root_executable = yes; then \
161 echo "WARNING: insufficient access; not installing su"; \
162 echo "NOTE: to install su, run 'make install-root' as root"; \
166 # Remove su only if it's one we installed.
167 @if grep '$(GNU_PACKAGE)' $(installed_su) > /dev/null 2>&1; then \
168 echo " rm -f $(installed_su)"; \
169 rm -f $(installed_su); \
172 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
173 # confusion with the `install' target. The install rule transforms `ginstall'
174 # to install before applying any user-specified name transformations.
176 transform = s/ginstall/install/; @program_transform_name@
177 ginstall_SOURCES = install.c copy.c cp-hash.c
179 # This is for the '[' program. Automake transliterates '[' to '_'.
180 __SOURCES = lbracket.c
182 cp_SOURCES = cp.c copy.c cp-hash.c
183 dir_SOURCES = ls.c ls-dir.c
184 vdir_SOURCES = ls.c ls-vdir.c
185 ls_SOURCES = ls.c ls-ls.c
186 chown_SOURCES = chown.c chown-core.c
187 chgrp_SOURCES = chgrp.c chown-core.c
189 mv_SOURCES = mv.c copy.c cp-hash.c remove.c
190 rm_SOURCES = rm.c remove.c
192 md5sum_SOURCES = md5sum.c
193 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
194 sha1sum_SOURCES = md5sum.c
195 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
196 sha224sum_SOURCES = md5sum.c
197 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
198 sha256sum_SOURCES = md5sum.c
199 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
200 sha384sum_SOURCES = md5sum.c
201 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
202 sha512sum_SOURCES = md5sum.c
203 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
205 editpl = sed -e 's,@''PERL''@,$(PERL),g'
207 BUILT_SOURCES += dircolors.h
208 dircolors.h: dcgen dircolors.hin
210 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
216 BUILT_SOURCES += wheel-size.h
217 wheel-size.h: Makefile.am
219 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
223 BUILT_SOURCES += wheel.h
224 wheel.h: wheel-gen.pl Makefile.am
226 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
230 # false exits nonzero even with --help or --version.
231 # test doesn't support --help or --version.
232 # Tell automake to exempt then from that installcheck test.
233 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
235 BUILT_SOURCES += fs.h
236 fs.h: stat.c extract-magic
238 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
242 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
244 # Sort in traditional ASCII order, regardless of the current locale;
245 # otherwise we may get into trouble with distinct strings that the
246 # current locale considers to be equal.
247 ASSORT = LC_ALL=C sort
255 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
260 # Ensure that the list of programs in README matches the list
261 # of programs we can build.
262 check: check-README check-misc
266 echo $(all_programs) \
267 | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
268 | $(ASSORT) -u > $(pm) && \
269 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
270 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
271 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
273 # Ensure that the list of programs and author names is accurate.
274 au_dotdot = authors-dotdot
275 au_actual = authors-actual
276 .PHONY: check-AUTHORS
277 check-AUTHORS: $(all_programs)
278 rm -f $(au_actual) $(au_dotdot)
279 for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
280 | $(ASSORT) -u`; do \
281 test "$$i" = '[' && continue; \
283 if test "$$i" = install; then \
285 elif test "$$i" = test; then \
289 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
291 sed -n '/:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
292 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
294 # Make sure we don't define any S_IS* macros in src/*.c files.
295 # Not a big deal, but they're already defined via system.h.
297 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
298 # This is a bit of a kludge, since it prevents use of the string
299 # even in comments, but for now it does the job with no false positives.
302 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
303 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
304 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
306 # Extract the list of authors from each file.
307 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
308 # Sometimes the string is on the same line as the #define...
309 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
310 # Sometimes the string is on the backslash-continued line after the #define.
311 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
312 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
313 ../AUTHORS: $(SOURCES)
317 echo "Here are the names of the programs in this package,"; \
318 echo "each followed by the name(s) of its author(s)."; \
320 for i in $(SOURCES); do \
321 a=`sed -n $(s1) $$i`; \
323 || a=`sed -n $(s2) $$i`; \
324 if test "$$a"; then \
325 prog=`echo $$i|sed 's/\.c$$//'`; \
326 echo "$$prog: $$a"; \
328 done | $(ASSORT) -u ) > $@-t
332 # The following rule is not designed to be portable,
333 # and relies on tools that not everyone has.
335 # Most functions in src/*.c should have static scope.
336 # Any that don't must be marked with `extern', but `main'
337 # and `usage' are exceptions. They're always extern, but
338 # don't need to be marked.
340 # The second nm|grep checks for file-scope variables with `extern' scope.
341 .PHONY: sc_tight_scope
342 sc_tight_scope: $(all_programs)
343 @t=exceptions-$$$$; \
344 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
345 ( printf '^main$$\n^usage$$\n'; \
346 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
347 | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
349 | sed -n 's/.* T //p' \
350 | grep -Ev -f $$t && \
351 { echo 'the above functions should have static scope' 1>&2; \
353 ( printf '^program_name$$\n'; \
354 sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
355 $(noinst_HEADERS) ) > $$t; \
357 | sed -n 's/.* [BD] //p' \
358 | grep -Ev -f $$t && \
359 { echo 'the above variables should have static scope' 1>&2; \