1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 EXTRA_PROGRAMS = chroot df hostid nice pinky stty su uname uptime users who
6 bin_PROGRAMS = [ chgrp chown chmod cp dd dircolors du \
7 ginstall link ln dir vdir ls mkdir \
8 mkfifo mknod mv nohup readlink rm rmdir shred stat sync touch unlink \
9 cat cksum comm csplit cut expand fmt fold head join md5sum \
10 nl od paste pr ptx sha1sum sort split sum tac tail tr tsort unexpand uniq wc \
11 basename date dirname echo env expr factor false \
12 hostname id kill logname pathchk printenv printf pwd seq sleep tee \
13 test true tty whoami yes \
14 $(OPTIONAL_BIN_PROGS) $(DF_PROG)
16 noinst_PROGRAMS = setuidgid
19 system.h checksum.h copy.h cp-hash.h ls.h dircolors.h remove.h \
22 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
23 groups.sh wheel-gen.pl extract-magic
24 CLEANFILES = $(SCRIPTS) su
26 AM_CPPFLAGS = -I.. -I$(srcdir) -I$(top_srcdir)/lib -I../lib
28 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
29 # include modules defining variables like `optind', so libfetish.a
30 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
31 # But libfetish.a must also follow $(LIBINTL), since libintl uses
32 # replacement functions defined in libfetish.a.
33 LDADD = ../lib/libfetish.a $(LIBINTL) ../lib/libfetish.a
35 # for eaccess in lib/euidaccess.c.
36 cp_LDADD = $(LDADD) $(LIB_EACCESS)
37 ginstall_LDADD = $(LDADD) $(LIB_EACCESS)
38 mv_LDADD = $(LDADD) $(LIB_EACCESS)
39 pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
40 rm_LDADD = $(LDADD) $(LIB_EACCESS)
41 test_LDADD = $(LDADD) $(LIB_EACCESS)
42 # This is for the '[' program. Automake transliterates '[' to '_'.
43 __LDADD = $(LDADD) $(LIB_EACCESS)
45 # for clock_gettime and fdatasync
46 dd_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_FDATASYNC)
47 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
48 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
49 shred_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_FDATASYNC)
50 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
52 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
53 sort_LDADD = $(LDADD) $(POW_LIB)
55 # for get_date and gettime
56 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
57 touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
60 factor_LDADD = $(LDADD) $(SQRT_LIBM)
62 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
63 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
64 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
66 # If necessary, add -lm to resolve use of floor, rint, modf.
67 seq_LDADD = $(LDADD) $(SEQ_LIBM)
69 # If necessary, add -lm to resolve the `pow' reference in lib/strtod.c
70 # or for the fesetround reference in programs using nanosec.c.
72 $(LDADD) $(FESETROUND_LIBM) $(POW_LIB) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP)
74 sleep_LDADD = $(nanosec_libs)
75 tail_LDADD = $(nanosec_libs)
77 uptime_LDADD = $(LDADD) $(GETLOADAVG_LIBS)
79 su_LDADD = $(LDADD) $(LIB_CRYPT)
81 $(PROGRAMS): ../lib/libfetish.a
88 -e 's!@''bindir''@!$(bindir)!' \
89 -e 's/@''GNU_PACKAGE''@/$(GNU_PACKAGE)/' \
90 -e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
91 -e 's/@''VERSION''@/$(VERSION)/' $< > $@-t
95 all-local: su$(EXEEXT)
97 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
99 setuid_root_mode = a=rx,u+s
103 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
104 $(INSTALL_PROGRAM) $$p $(installed_su); \
105 echo " chown root $(installed_su)"; \
106 chown root $(installed_su); \
107 echo " chmod $(setuid_root_mode) $(installed_su)"; \
108 chmod $(setuid_root_mode) $(installed_su)
110 install-root: su$(EXEEXT)
113 install-exec-local: su$(EXEEXT)
114 @TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
117 ## See if we can create a setuid root executable in $(bindir).
118 ## If not, then don't even try to install su.
119 can_create_suid_root_executable=no; \
120 chown root $$TMPFILE > /dev/null 2>&1 \
121 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
122 && can_create_suid_root_executable=yes; \
124 if test $$can_create_suid_root_executable = yes; then \
127 echo "WARNING: insufficient access; not installing su"; \
128 echo "NOTE: to install su, run 'make install-root' as root"; \
132 # Remove su only if it's one we installed.
133 @if grep '$(GNU_PACKAGE)' $(installed_su) > /dev/null 2>&1; then \
134 echo " rm -f $(installed_su)"; \
135 rm -f $(installed_su); \
138 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
139 # confusion with the `install' target. The install rule transforms `ginstall'
140 # to install before applying any user-specified name transformations.
142 transform = s/ginstall/install/; @program_transform_name@
143 ginstall_SOURCES = install.c copy.c cp-hash.c
145 # This is for the '[' program. Automake transliterates '[' to '_'.
146 __SOURCES = lbracket.c
148 cp_SOURCES = cp.c copy.c cp-hash.c
149 dir_SOURCES = ls.c ls-dir.c
150 vdir_SOURCES = ls.c ls-vdir.c
151 ls_SOURCES = ls.c ls-ls.c
152 chown_SOURCES = chown.c chown-core.c
153 chgrp_SOURCES = chgrp.c chown-core.c
155 mv_SOURCES = mv.c copy.c cp-hash.c remove.c
156 rm_SOURCES = rm.c remove.c
158 md5sum_SOURCES = md5sum.c md5.c
159 sha1sum_SOURCES = md5sum.c sha1sum.c
161 editpl = sed -e 's,@''PERL''@,$(PERL),g'
163 localedir = $(datadir)/locale
164 BUILT_SOURCES = localedir.h
165 DISTCLEANFILES = localedir.h
168 echo '#define LOCALEDIR "$(localedir)"' >$@-t
172 BUILT_SOURCES += dircolors.h
173 dircolors.h: dcgen dircolors.hin
175 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
181 BUILT_SOURCES += wheel-size.h
182 wheel-size.h: Makefile.am
184 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
188 BUILT_SOURCES += wheel.h
189 wheel.h: wheel-gen.pl Makefile.am
191 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
195 # false exits nonzero even with --help or --version.
196 # test doesn't support --help or --version.
197 # Tell automake to exempt then from that installcheck test.
198 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
200 BUILT_SOURCES += false.c
205 -e s/success/failure/g \
206 -e 's/(EXIT_SUCCESS)/(EXIT_FAILURE)/g' \
207 $(srcdir)/true.c > $@-t
211 BUILT_SOURCES += fs.h
212 fs.h: stat.c extract-magic
214 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
218 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
220 # Sort in traditional ASCII order, regardless of the current locale;
221 # otherwise we may get into trouble with distinct strings that the
222 # current locale considers to be equal.
223 ASSORT = LC_ALL=C sort
231 @echo $(all_programs) | tr ' ' '\n' | $(ASSORT)
235 # Ensure that the list of programs in README matches the list
236 # of programs we can build.
237 check: check-README check-misc check-AUTHORS
241 echo $(all_programs) \
242 | tr -s ' ' '\n' | $(ASSORT) -u > $(pm) && \
243 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
244 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
245 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
247 # Ensure that the list of programs and author names is accurate.
248 au_dotdot = authors-dotdot
249 au_actual = authors-actual
250 .PHONY: check-AUTHORS
251 check-AUTHORS: $(all_programs)
252 rm -f $(au_actual) $(au_dotdot)
253 for i in `ls $(all_programs) | $(ASSORT) -u`; do \
254 test "$$i" = '[' && continue; \
256 if test "$$i" = install; then \
258 elif test "$$i" = test; then \
262 |sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
264 sed -n '/:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
265 diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
267 # Make sure we don't define any S_IS* macros in src/*.c files.
268 # Not a big deal, but they're already defined via system.h.
270 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
271 # This is a bit of a kludge, since it prevents use of the string
272 # even in comments, but for now it does the job with no false positives.
275 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
276 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
277 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
279 # Extract the list of authors from each file.
280 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
281 # Sometimes the string is on the same line as the #define...
282 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
283 # Sometimes the string is on the backslash-continued line after the #define.
284 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
285 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
286 ../AUTHORS: $(SOURCES)
290 echo "Here are the names of the programs in this package,"; \
291 echo "each followed by the name(s) of its author(s)."; \
293 for i in $(SOURCES); do \
294 a=`sed -n $(s1) $$i`; \
296 || a=`sed -n $(s2) $$i`; \
297 if test "$$a"; then \
298 prog=`echo $$i|sed 's/\.c$$//'`; \
299 echo "$$prog: $$a"; \
301 done | $(ASSORT) -u ) > $@-t
305 # The following rule is not designed to be portable,
306 # and relies on tools that not everyone has.
308 # Most functions in src/*.c should have static scope.
309 # Any that don't must be marked with `extern', but `main'
310 # and `usage' are exceptions. They're always extern, but
311 # don't need to be marked.
313 # The second nm|grep checks for file-scope variables with `extern' scope.
314 sc_tight_scope: $(all_programs)
315 @t=exceptions-$$$$; \
316 trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
317 ( printf '^main$$\n^usage$$\n'; \
318 grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
319 | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
321 | sed -n 's/.* T //p' \
322 | grep -Ev -f $$t && \
323 { echo 'the above functions should have static scope' 1>&2; \
325 printf '^program_name$$\n' > $$t; \
327 | sed -n 's/.* B //p' \
328 | grep -Ev -f $$t && \
329 { echo 'the above variables should have static scope' 1>&2; \