1 # Make coreutils programs. -*-Makefile-*-
2 # This is included by the top-level Makefile.am.
4 ## Copyright (C) 1990-2012 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 3 of the License, or
9 ## (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
19 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
21 # The list of all programs (separated in different variables to express
22 # the how and when they should be installed) is defined in this makefile
23 # fragment, autogenerated by the 'gen-lists-of-programs.sh' auxiliary
25 include $(srcdir)/src/cu-progs.mk
28 $(no_install__progs) \
29 $(build_if_possible__progs) \
32 bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
34 noinst_PROGRAMS = src/setuidgid src/getlimits
36 pkglibexec_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
44 src/find-mount-point.h \
66 CLEANFILES = $(SCRIPTS)
68 # Also remove these sometimes-built programs.
69 # For example, even when excluded, they're built via 'sc_check-AUTHORS'
71 CLEANFILES += $(no_install__progs)
73 AM_CPPFLAGS = -I$(top_srcdir)/lib
75 noinst_LIBRARIES = src/libver.a
76 nodist_src_libver_a_SOURCES = src/version.c src/version.h
78 # Tell the linker to omit references to unused shared libraries.
79 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
81 # Extra libraries needed by more than one program. Will be updated later.
85 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
86 # include modules defining variables like 'optind', so libcoreutils.a
87 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
88 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
89 # replacement functions defined in libcoreutils.a.
90 LDADD = src/libver.a lib/libcoreutils.a $(LIBINTL) lib/libcoreutils.a
92 # First, list all programs, to make listing per-program libraries easier.
94 src_arch_LDADD = $(LDADD)
95 src_base64_LDADD = $(LDADD)
96 src_basename_LDADD = $(LDADD)
97 src_cat_LDADD = $(LDADD)
98 src_chcon_LDADD = $(LDADD)
99 src_chgrp_LDADD = $(LDADD)
100 src_chmod_LDADD = $(LDADD)
101 src_chown_LDADD = $(LDADD)
102 src_chroot_LDADD = $(LDADD)
103 src_cksum_LDADD = $(LDADD)
104 src_comm_LDADD = $(LDADD)
105 src_nproc_LDADD = $(LDADD)
106 src_cp_LDADD = $(LDADD)
107 src_csplit_LDADD = $(LDADD)
108 src_cut_LDADD = $(LDADD)
109 src_date_LDADD = $(LDADD)
110 src_dd_LDADD = $(LDADD)
111 src_df_LDADD = $(LDADD)
112 # See dir_LDADD below
113 src_dircolors_LDADD = $(LDADD)
114 src_dirname_LDADD = $(LDADD)
115 src_du_LDADD = $(LDADD)
116 src_echo_LDADD = $(LDADD)
117 src_env_LDADD = $(LDADD)
118 src_expand_LDADD = $(LDADD)
119 src_expr_LDADD = $(LDADD)
120 src_factor_LDADD = $(LDADD)
121 src_false_LDADD = $(LDADD)
122 src_fmt_LDADD = $(LDADD)
123 src_fold_LDADD = $(LDADD)
124 src_getlimits_LDADD = $(LDADD)
125 src_ginstall_LDADD = $(LDADD)
126 src_groups_LDADD = $(LDADD)
127 src_head_LDADD = $(LDADD)
128 src_hostid_LDADD = $(LDADD)
129 src_hostname_LDADD = $(LDADD)
130 src_id_LDADD = $(LDADD)
131 src_join_LDADD = $(LDADD)
132 src_kill_LDADD = $(LDADD)
133 src_link_LDADD = $(LDADD)
134 src_ln_LDADD = $(LDADD)
135 src_logname_LDADD = $(LDADD)
136 src_ls_LDADD = $(LDADD)
137 src_md5sum_LDADD = $(LDADD)
138 src_mkdir_LDADD = $(LDADD)
139 src_mkfifo_LDADD = $(LDADD)
140 src_mknod_LDADD = $(LDADD)
141 src_mktemp_LDADD = $(LDADD)
142 src_mv_LDADD = $(LDADD)
143 src_nice_LDADD = $(LDADD)
144 src_nl_LDADD = $(LDADD)
145 src_nohup_LDADD = $(LDADD)
146 src_od_LDADD = $(LDADD)
147 src_paste_LDADD = $(LDADD)
148 src_pathchk_LDADD = $(LDADD)
149 src_pinky_LDADD = $(LDADD)
150 src_pr_LDADD = $(LDADD)
151 src_printenv_LDADD = $(LDADD)
152 src_printf_LDADD = $(LDADD)
153 src_ptx_LDADD = $(LDADD)
154 src_pwd_LDADD = $(LDADD)
155 src_readlink_LDADD = $(LDADD)
156 src_realpath_LDADD = $(LDADD)
157 src_rm_LDADD = $(LDADD)
158 src_rmdir_LDADD = $(LDADD)
159 src_runcon_LDADD = $(LDADD)
160 src_seq_LDADD = $(LDADD)
161 src_setuidgid_LDADD = $(LDADD)
162 src_sha1sum_LDADD = $(LDADD)
163 src_sha224sum_LDADD = $(LDADD)
164 src_sha256sum_LDADD = $(LDADD)
165 src_sha384sum_LDADD = $(LDADD)
166 src_sha512sum_LDADD = $(LDADD)
167 src_shred_LDADD = $(LDADD)
168 src_shuf_LDADD = $(LDADD)
169 src_sleep_LDADD = $(LDADD)
170 src_sort_LDADD = $(LDADD)
171 src_split_LDADD = $(LDADD)
172 src_stat_LDADD = $(LDADD)
173 src_stdbuf_LDADD = $(LDADD)
174 src_stty_LDADD = $(LDADD)
175 src_sum_LDADD = $(LDADD)
176 src_sync_LDADD = $(LDADD)
177 src_tac_LDADD = $(LDADD)
178 src_tail_LDADD = $(LDADD)
179 src_tee_LDADD = $(LDADD)
180 src_test_LDADD = $(LDADD)
181 src_timeout_LDADD = $(LDADD)
182 src_touch_LDADD = $(LDADD)
183 src_tr_LDADD = $(LDADD)
184 src_true_LDADD = $(LDADD)
185 src_truncate_LDADD = $(LDADD)
186 src_tsort_LDADD = $(LDADD)
187 src_tty_LDADD = $(LDADD)
188 src_uname_LDADD = $(LDADD)
189 src_unexpand_LDADD = $(LDADD)
190 src_uniq_LDADD = $(LDADD)
191 src_unlink_LDADD = $(LDADD)
192 src_uptime_LDADD = $(LDADD)
193 src_users_LDADD = $(LDADD)
194 # See vdir_LDADD below
195 src_wc_LDADD = $(LDADD)
196 src_who_LDADD = $(LDADD)
197 src_whoami_LDADD = $(LDADD)
198 src_yes_LDADD = $(LDADD)
200 # Synonyms. Recall that Automake transliterates '[' and '/' to '_'.
201 src___LDADD = $(src_test_LDADD)
202 src_dir_LDADD = $(src_ls_LDADD)
203 src_vdir_LDADD = $(src_ls_LDADD)
205 src_cp_LDADD += $(copy_ldadd)
206 src_ginstall_LDADD += $(copy_ldadd)
207 src_mv_LDADD += $(copy_ldadd)
209 src_mv_LDADD += $(remove_ldadd)
210 src_rm_LDADD += $(remove_ldadd)
212 # for eaccess, euidaccess
213 copy_ldadd += $(LIB_EACCESS)
214 remove_ldadd += $(LIB_EACCESS)
215 src_sort_LDADD += $(LIB_EACCESS)
216 src_test_LDADD += $(LIB_EACCESS)
219 copy_ldadd += $(LIB_SELINUX)
220 src_chcon_LDADD += $(LIB_SELINUX)
221 src_ginstall_LDADD += $(LIB_SELINUX)
222 src_id_LDADD += $(LIB_SELINUX)
223 src_ls_LDADD += $(LIB_SELINUX)
224 src_mkdir_LDADD += $(LIB_SELINUX)
225 src_mkfifo_LDADD += $(LIB_SELINUX)
226 src_mknod_LDADD += $(LIB_SELINUX)
227 src_runcon_LDADD += $(LIB_SELINUX)
228 src_stat_LDADD += $(LIB_SELINUX)
230 # for gettime, settime, utimecmp, utimens
231 copy_ldadd += $(LIB_CLOCK_GETTIME)
232 src_date_LDADD += $(LIB_CLOCK_GETTIME)
233 src_ginstall_LDADD += $(LIB_CLOCK_GETTIME)
234 src_ls_LDADD += $(LIB_CLOCK_GETTIME)
235 src_pr_LDADD += $(LIB_CLOCK_GETTIME)
236 src_timeout_LDADD += $(LIB_TIMER_TIME)
237 src_touch_LDADD += $(LIB_CLOCK_GETTIME)
240 src_dd_LDADD += $(LIB_GETHRXTIME)
243 src_ls_LDADD += $(LIB_CAP)
246 src_dd_LDADD += $(LIB_FDATASYNC)
247 src_shred_LDADD += $(LIB_FDATASYNC)
250 src_sleep_LDADD += $(LIB_NANOSLEEP)
251 src_sort_LDADD += $(LIB_NANOSLEEP)
252 src_tail_LDADD += $(LIB_NANOSLEEP)
254 # for various GMP functions
255 src_expr_LDADD += $(LIB_GMP)
256 src_factor_LDADD += $(LIB_GMP)
259 src_uptime_LDADD += $(GETLOADAVG_LIBS)
261 # for various ACL functions
262 copy_ldadd += $(LIB_ACL)
263 src_ls_LDADD += $(LIB_ACL)
265 # for various xattr functions
266 copy_ldadd += $(LIB_XATTR)
268 # for print_unicode_char, proper_name_utf8
269 src_cat_LDADD += $(LIBICONV)
270 src_cp_LDADD += $(LIBICONV)
271 src_df_LDADD += $(LIBICONV)
272 src_du_LDADD += $(LIBICONV)
273 src_getlimits_LDADD += $(LIBICONV)
274 src_printf_LDADD += $(LIBICONV)
275 src_ptx_LDADD += $(LIBICONV)
276 src_realpath_LDADD += $(LIBICONV)
277 src_split_LDADD += $(LIBICONV)
278 src_stdbuf_LDADD += $(LIBICONV)
279 src_timeout_LDADD += $(LIBICONV)
280 src_truncate_LDADD += $(LIBICONV)
283 src_pinky_LDADD += $(GETADDRINFO_LIB)
284 src_who_LDADD += $(GETADDRINFO_LIB)
286 # for gethostname, uname
287 src_hostname_LDADD += $(GETHOSTNAME_LIB)
288 src_uname_LDADD += $(GETHOSTNAME_LIB)
291 src_kill_LDADD += $(LIBTHREAD)
294 src_sort_LDADD += $(LIB_PTHREAD)
296 $(PROGRAMS): lib/libcoreutils.a
298 # Get the release year from lib/version-etc.c.
300 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
301 $(top_srcdir)/lib/version-etc.c`
309 # Use 'ginstall' in the definition of PROGRAMS and in dependencies to avoid
310 # confusion with the 'install' target. The install rule transforms 'ginstall'
311 # to install before applying any user-specified name transformations.
313 transform = s/ginstall/install/; $(program_transform_name)
314 src_ginstall_SOURCES = src/install.c src/prog-fprintf.c $(copy_sources)
316 # This is for the '[' program. Automake transliterates '[' and '/' to '_'.
317 src___SOURCES = src/lbracket.c
319 src_cp_SOURCES = src/cp.c $(copy_sources)
320 src_dir_SOURCES = src/ls.c src/ls-dir.c
321 src_vdir_SOURCES = src/ls.c src/ls-vdir.c
322 src_id_SOURCES = src/id.c src/group-list.c
323 src_groups_SOURCES = src/groups.c src/group-list.c
324 src_ls_SOURCES = src/ls.c src/ls-ls.c
325 src_ln_SOURCES = src/ln.c src/relpath.c src/relpath.h
326 src_chown_SOURCES = src/chown.c src/chown-core.c
327 src_chgrp_SOURCES = src/chgrp.c src/chown-core.c
328 src_kill_SOURCES = src/kill.c src/operand2sig.c
329 src_realpath_SOURCES = src/realpath.c src/relpath.c src/relpath.h
330 src_timeout_SOURCES = src/timeout.c src/operand2sig.c
332 src_mv_SOURCES = src/mv.c src/remove.c $(copy_sources)
333 src_rm_SOURCES = src/rm.c src/remove.c
335 src_mkdir_SOURCES = src/mkdir.c src/prog-fprintf.c
336 src_rmdir_SOURCES = src/rmdir.c src/prog-fprintf.c
338 src_df_SOURCES = src/df.c src/find-mount-point.c
339 src_stat_SOURCES = src/stat.c src/find-mount-point.c
341 src_uname_SOURCES = src/uname.c src/uname-uname.c
342 src_arch_SOURCES = src/uname.c src/uname-arch.c
344 src_md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
345 src_sha1sum_SOURCES = src/md5sum.c
346 src_sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
347 src_sha224sum_SOURCES = src/md5sum.c
348 src_sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
349 src_sha256sum_SOURCES = src/md5sum.c
350 src_sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
351 src_sha384sum_SOURCES = src/md5sum.c
352 src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
353 src_sha512sum_SOURCES = src/md5sum.c
354 src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
356 src_ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
358 # Ensure we don't link against libcoreutils.a as that lib is
359 # not compiled with -fPIC which causes issues on 64 bit at least
360 src_libstdbuf_so_LDADD =
362 # Note libstdbuf is only compiled if GCC is available
363 # (as per the check in configure.ac), so these flags should be available.
364 # libtool is probably required to relax this dependency.
365 src_libstdbuf_so_LDFLAGS = -shared
366 src_libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
368 BUILT_SOURCES += src/dircolors.h
369 src/dircolors.h: src/dcgen src/dircolors.hin
370 $(AM_V_GEN)rm -f $@ $@-t
371 $(AM_V_at)$(PERL) -w -- $(srcdir)/src/dcgen \
372 $(srcdir)/src/dircolors.hin > $@-t
373 $(AM_V_at)chmod a-w $@-t
378 BUILT_SOURCES += src/wheel-size.h
379 src/wheel-size.h: Makefile.am
380 $(AM_V_GEN)rm -f $@ $@-t
381 $(AM_V_at)echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
382 $(AM_V_at)chmod a-w $@-t
385 BUILT_SOURCES += src/wheel.h
386 src/wheel.h: src/wheel-gen.pl Makefile.am
387 $(AM_V_GEN)rm -f $@ $@-t
388 $(AM_V_at)$(srcdir)/src/wheel-gen.pl $(wheel_size) > $@-t
389 $(AM_V_at)chmod a-w $@-t
392 # false exits nonzero even with --help or --version.
393 # test doesn't support --help or --version.
394 # Tell automake to exempt then from that installcheck test.
395 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = src/false src/test
397 # Compare fs.h with the list of file system names/magic-numbers in the
398 # Linux statfs man page. This target prints any new name/number pairs.
399 # Also compare against /usr/include/linux/magic.h
400 .PHONY: src/fs-magic-compare
401 src/fs-magic-compare: src/fs-magic src/fs-kernel-magic src/fs-def
402 join -v1 -t@ src/fs-magic src/fs-def
403 join -v1 -t@ src/fs-kernel-magic src/fs-def
405 CLEANFILES += src/fs-def
407 grep '^# *define ' src/fs.h | $(ASSORT) > $@-t && mv $@-t $@
409 # Massage bits of the statfs man page and definitions from
410 # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
411 fs_normalize_perl_subst = \
412 -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
413 -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
414 -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
415 -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
416 -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
417 -e 's/CIFS_MAGIC_NUMBER/CIFS/;' \
418 -e 's/(_SUPER)?_MAGIC//;' \
419 -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
420 -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
421 -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
422 -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
424 -e 's/^\043define\s+//;' \
425 -e 's/^_(XIAFS)/$$1/;' \
426 -e 's/^USBDEVICE/USBDEVFS/;' \
427 -e 's/NTFS_SB/NTFS/;' \
428 -e 's/^/\043 define S_MAGIC_/;' \
429 -e 's,\s*/\* .*? \*/,,;'
431 CLEANFILES += src/fs-magic
432 src/fs-magic: Makefile
434 |perl -ne '/File system types:/.../Nobody kno/ and print' \
436 $(fs_normalize_perl_subst) \
437 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
441 CLEANFILES += src/fs-kernel-magic
442 src/fs-kernel-magic: Makefile
443 perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \
445 $(fs_normalize_perl_subst) \
446 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
450 BUILT_SOURCES += src/fs-is-local.h
451 src/fs-is-local.h: src/stat.c src/extract-magic
453 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
454 --local $(srcdir)/src/stat.c > $@t
455 $(AM_V_at)chmod a-w $@t
458 BUILT_SOURCES += src/fs.h
459 src/fs.h: src/stat.c src/extract-magic
461 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
462 $(srcdir)/src/stat.c > $@t
463 $(AM_V_at)chmod a-w $@t
466 BUILT_SOURCES += src/version.c
467 src/version.c: Makefile
469 $(AM_V_at)printf '#include <config.h>\n' > $@t
470 $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
471 $(AM_V_at)chmod a-w $@t
474 BUILT_SOURCES += src/version.h
475 src/version.h: Makefile
477 $(AM_V_at)printf 'extern char const *Version;\n' > $@t
478 $(AM_V_at)chmod a-w $@t
481 DISTCLEANFILES += src/version.c src/version.h
482 MAINTAINERCLEANFILES += $(BUILT_SOURCES)
490 @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
491 | sed -e 's,$(EXEEXT)$$,,' -e 's,^src/,,' \
492 | $(ASSORT) -u | tr '\n' ' '
495 @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
501 # Ensure that the list of programs in README matches the list
502 # of programs we can build.
503 check: check-README check-duplicate-no-install
506 $(AM_V_GEN)rm -rf $(pr) $(pm)
507 $(AM_V_at)echo $(all_programs) \
509 | sed -e 's,$(EXEEXT)$$,,' \
511 -e 's/^ginstall$$/install/' \
513 | $(ASSORT) -u > $(pm) && \
514 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
515 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
516 $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
518 # Ensure that a by-default-not-installed program (listed in
519 # $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS)
520 # entry, because if that were to happen, it *would* be installed
522 .PHONY: check-duplicate-no-install
523 check-duplicate-no-install: src/tr
524 $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)' | tr ' ' '\n' | uniq -d`"
526 # Use the just-built 'ginstall', when not cross-compiling.
528 cu_install_program = @INSTALL_PROGRAM@
530 cu_install_program = src/ginstall
532 INSTALL_PROGRAM = $(cu_install_program)