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 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
36 ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
37 shred_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
38 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
40 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
41 sort_LDADD = $(LDADD) $(POW_LIB)
44 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
47 factor_LDADD = $(LDADD) $(SQRT_LIBM)
49 # If necessary, add -lm to resolve use of pow in lib/strtod.c.
50 # If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
51 printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
53 # If necessary, add -lm to resolve use of floor, rint, modf.
54 seq_LDADD = $(LDADD) $(SEQ_LIBM)
56 # If necessary, add -lm to resolve the `pow' reference in lib/strtod.c
57 # or for the fesetround reference in programs using nanosec.c.
59 $(LDADD) $(FESETROUND_LIBM) $(POW_LIB) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP)
61 sleep_LDADD = $(nanosec_libs)
62 tail_LDADD = $(nanosec_libs)
64 uptime_LDADD = $(LDADD) $(GETLOADAVG_LIBS)
66 su_LDADD = $(LDADD) $(LIB_CRYPT)
68 $(PROGRAMS): ../lib/libfetish.a
77 -e 's!@''bindir''@!$(bindir)!' \
78 -e 's/@''GNU_PACKAGE''@/$(GNU_PACKAGE)/' \
79 -e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
80 -e 's/@''VERSION''@/$(VERSION)/' $< > $@-t
84 all-local: su$(EXEEXT)
86 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
88 setuid_root_mode = a=rx,u+s
92 echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
93 $(INSTALL_PROGRAM) $$p $(installed_su); \
94 echo " chown root $(installed_su)"; \
95 chown root $(installed_su); \
96 echo " chmod $(setuid_root_mode) $(installed_su)"; \
97 chmod $(setuid_root_mode) $(installed_su)
99 install-root: su$(EXEEXT)
102 install-exec-local: su$(EXEEXT)
103 @TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
106 ## See if we can create a setuid root executable in $(bindir).
107 ## If not, then don't even try to install su.
108 can_create_suid_root_executable=no; \
109 chown root $$TMPFILE > /dev/null 2>&1 \
110 && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
111 && can_create_suid_root_executable=yes; \
113 if test $$can_create_suid_root_executable = yes; then \
116 echo "WARNING: insufficient access; not installing su"; \
117 echo "NOTE: to install su, run 'make install-root' as root"; \
121 # Remove su only if it's one we installed.
122 @if grep '$(GNU_PACKAGE)' $(installed_su) > /dev/null 2>&1; then \
123 echo " rm -f $(installed_su)"; \
124 rm -f $(installed_su); \
127 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
128 # confusion with the `install' target. The install rule transforms `ginstall'
129 # to install before applying any user-specified name transformations.
131 transform = s/ginstall/install/; @program_transform_name@
132 ginstall_SOURCES = install.c copy.c cp-hash.c
134 # This is for the '[' program. Automake transliterates '[' to '_'.
135 __SOURCES = lbracket.c
137 cp_SOURCES = cp.c copy.c cp-hash.c
138 dir_SOURCES = ls.c ls-dir.c
139 vdir_SOURCES = ls.c ls-vdir.c
140 ls_SOURCES = ls.c ls-ls.c
141 chown_SOURCES = chown.c chown-core.c
142 chgrp_SOURCES = chgrp.c chown-core.c
144 mv_SOURCES = mv.c copy.c cp-hash.c remove.c
145 rm_SOURCES = rm.c remove.c
147 md5sum_SOURCES = md5sum.c md5.c
148 sha1sum_SOURCES = md5sum.c sha1sum.c
150 editpl = sed -e 's,@''PERL''@,$(PERL),g'
152 localedir = $(datadir)/locale
153 BUILT_SOURCES = localedir.h
154 DISTCLEANFILES = localedir.h
155 localedir.h: Makefile
157 echo '#define LOCALEDIR "$(localedir)"' >$@-t
159 cmp $@-t $@ > /dev/null 2>&1 && rm -f $@-t || { rm -f $@; mv $@-t $@; }
161 BUILT_SOURCES += dircolors.h
162 dircolors.h: dcgen dircolors.hin
164 $(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
170 BUILT_SOURCES += wheel-size.h
171 wheel-size.h: Makefile.am
173 echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
177 BUILT_SOURCES += wheel.h
178 wheel.h: wheel-gen.pl Makefile.am
180 $(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
184 # false exits nonzero even with --help or --version.
185 # test doesn't support --help or --version.
186 # Tell automake to exempt then from that installcheck test.
187 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
189 BUILT_SOURCES += false.c
194 -e s/success/failure/g \
195 -e 's/(EXIT_SUCCESS)/(EXIT_FAILURE)/g' \
196 $(srcdir)/true.c > $@-t
200 BUILT_SOURCES += fs.h
201 fs.h: stat.c extract-magic
203 $(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
207 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
214 # Sort in traditional ASCII order, regardless of the current locale;
215 # otherwise we may get into trouble with distinct strings that the
216 # current locale considers to be equal.
217 ASSORT = LC_ALL=C sort
221 # Ensure that the list of programs in README matches the list
222 # of programs we can build.
223 check: check-README check-misc
227 echo $(all_programs) \
228 | tr -s ' ' '\n' | $(ASSORT) -u > $(pm) && \
229 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
230 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
231 diff $(pm) $(pr) && rm -rf $(pr) $(pm)
233 # Make sure we don't define any S_IS* macros in src/*.c files.
234 # Not a big deal, but they're already defined via system.h.
236 # Also make sure we don't use st_blocks. Use ST_NBLOCKS instead.
237 # This is a bit of a kludge, since it prevents use of the string
238 # even in comments, but for now it does the job with no false positives.
241 cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
242 cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
243 cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
245 # Extract the list of authors from each file.
246 sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
247 # Sometimes the string is on the same line as the #define...
248 s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
249 # Sometimes the string is on the backslash-continued line after the #define.
250 s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
251 # FIXME: handle *.sh; and use $(all_programs), not $(SOURCES)
252 ../AUTHORS: $(SOURCES)
256 echo "Here are the names of the programs in this package,"; \
257 echo "each followed by the name(s) of its author(s)."; \
259 for i in $(SOURCES); do \
260 a=`sed -n $(s1) $$i`; \
262 || a=`sed -n $(s2) $$i`; \
263 if test "$$a"; then \
264 prog=`echo $$i|sed 's/\.c$$//'`; \
265 echo "$$prog: $$a"; \
267 done | $(ASSORT) -u ) > $@-t