# Make coreutils programs. -*-Makefile-*- # This is included by the top-level Makefile.am. ## Copyright (C) 1990-2012 Free Software Foundation, Inc. ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) # The list of all programs (separated in different variables to express # the how and when they should be installed) is defined in this makefile # fragment, autogenerated by the 'gen-lists-of-programs.sh' auxiliary # script. include $(srcdir)/src/cu-progs.mk EXTRA_PROGRAMS = \ $(no_install__progs) \ $(build_if_possible__progs) \ $(default__progs) # The user can tweak these lists at configure time. bin_PROGRAMS = @bin_PROGRAMS@ pkglibexec_PROGRAMS = @pkglibexec_PROGRAMS@ # Needed by the testsuite. noinst_PROGRAMS = src/setuidgid src/getlimits noinst_HEADERS = \ src/chown-core.h \ src/copy.h \ src/cp-hash.h \ src/dircolors.h \ src/fiemap.h \ src/find-mount-point.h \ src/fs.h \ src/fs-is-local.h \ src/group-list.h \ src/ioblksize.h \ src/ls.h \ src/operand2sig.h \ src/prog-fprintf.h \ src/remove.h \ src/system.h \ src/wheel-size.h \ src/wheel.h \ src/uname.h EXTRA_DIST += \ src/dcgen \ src/dircolors.hin \ src/tac-pipe.c \ src/wheel-gen.pl \ src/extract-magic \ src/c99-to-c89.diff CLEANFILES = $(SCRIPTS) # Also remove these sometimes-built programs. # For example, even when excluded, they're built via 'sc_check-AUTHORS' # or 'dist'. CLEANFILES += $(no_install__progs) AM_CPPFLAGS = -I$(top_srcdir)/lib -Isrc noinst_LIBRARIES = src/libver.a nodist_src_libver_a_SOURCES = src/version.c src/version.h # Tell the linker to omit references to unused shared libraries. AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS) # Extra libraries needed by more than one program. Will be updated later. copy_ldadd = remove_ldadd = # Sometimes, the expansion of $(LIBINTL) includes -lc which may # include modules defining variables like 'optind', so libcoreutils.a # must precede $(LIBINTL) in order to ensure we use GNU getopt. # But libcoreutils.a must also follow $(LIBINTL), since libintl uses # replacement functions defined in libcoreutils.a. LDADD = src/libver.a lib/libcoreutils.a $(LIBINTL) lib/libcoreutils.a # First, list all programs, to make listing per-program libraries easier. # See [ below. src_arch_LDADD = $(LDADD) src_base64_LDADD = $(LDADD) src_basename_LDADD = $(LDADD) src_cat_LDADD = $(LDADD) src_chcon_LDADD = $(LDADD) src_chgrp_LDADD = $(LDADD) src_chmod_LDADD = $(LDADD) src_chown_LDADD = $(LDADD) src_chroot_LDADD = $(LDADD) src_cksum_LDADD = $(LDADD) src_comm_LDADD = $(LDADD) src_nproc_LDADD = $(LDADD) src_cp_LDADD = $(LDADD) src_csplit_LDADD = $(LDADD) src_cut_LDADD = $(LDADD) src_date_LDADD = $(LDADD) src_dd_LDADD = $(LDADD) src_df_LDADD = $(LDADD) # See dir_LDADD below src_dircolors_LDADD = $(LDADD) src_dirname_LDADD = $(LDADD) src_du_LDADD = $(LDADD) src_echo_LDADD = $(LDADD) src_env_LDADD = $(LDADD) src_expand_LDADD = $(LDADD) src_expr_LDADD = $(LDADD) src_factor_LDADD = $(LDADD) src_false_LDADD = $(LDADD) src_fmt_LDADD = $(LDADD) src_fold_LDADD = $(LDADD) src_getlimits_LDADD = $(LDADD) src_ginstall_LDADD = $(LDADD) src_groups_LDADD = $(LDADD) src_head_LDADD = $(LDADD) src_hostid_LDADD = $(LDADD) src_hostname_LDADD = $(LDADD) src_id_LDADD = $(LDADD) src_join_LDADD = $(LDADD) src_kill_LDADD = $(LDADD) src_link_LDADD = $(LDADD) src_ln_LDADD = $(LDADD) src_logname_LDADD = $(LDADD) src_ls_LDADD = $(LDADD) src_md5sum_LDADD = $(LDADD) src_mkdir_LDADD = $(LDADD) src_mkfifo_LDADD = $(LDADD) src_mknod_LDADD = $(LDADD) src_mktemp_LDADD = $(LDADD) src_mv_LDADD = $(LDADD) src_nice_LDADD = $(LDADD) src_nl_LDADD = $(LDADD) src_nohup_LDADD = $(LDADD) src_od_LDADD = $(LDADD) src_paste_LDADD = $(LDADD) src_pathchk_LDADD = $(LDADD) src_pinky_LDADD = $(LDADD) src_pr_LDADD = $(LDADD) src_printenv_LDADD = $(LDADD) src_printf_LDADD = $(LDADD) src_ptx_LDADD = $(LDADD) src_pwd_LDADD = $(LDADD) src_readlink_LDADD = $(LDADD) src_realpath_LDADD = $(LDADD) src_rm_LDADD = $(LDADD) src_rmdir_LDADD = $(LDADD) src_runcon_LDADD = $(LDADD) src_seq_LDADD = $(LDADD) src_setuidgid_LDADD = $(LDADD) src_sha1sum_LDADD = $(LDADD) src_sha224sum_LDADD = $(LDADD) src_sha256sum_LDADD = $(LDADD) src_sha384sum_LDADD = $(LDADD) src_sha512sum_LDADD = $(LDADD) src_shred_LDADD = $(LDADD) src_shuf_LDADD = $(LDADD) src_sleep_LDADD = $(LDADD) src_sort_LDADD = $(LDADD) src_split_LDADD = $(LDADD) src_stat_LDADD = $(LDADD) src_stdbuf_LDADD = $(LDADD) src_stty_LDADD = $(LDADD) src_sum_LDADD = $(LDADD) src_sync_LDADD = $(LDADD) src_tac_LDADD = $(LDADD) src_tail_LDADD = $(LDADD) src_tee_LDADD = $(LDADD) src_test_LDADD = $(LDADD) src_timeout_LDADD = $(LDADD) src_touch_LDADD = $(LDADD) src_tr_LDADD = $(LDADD) src_true_LDADD = $(LDADD) src_truncate_LDADD = $(LDADD) src_tsort_LDADD = $(LDADD) src_tty_LDADD = $(LDADD) src_uname_LDADD = $(LDADD) src_unexpand_LDADD = $(LDADD) src_uniq_LDADD = $(LDADD) src_unlink_LDADD = $(LDADD) src_uptime_LDADD = $(LDADD) src_users_LDADD = $(LDADD) # See vdir_LDADD below src_wc_LDADD = $(LDADD) src_who_LDADD = $(LDADD) src_whoami_LDADD = $(LDADD) src_yes_LDADD = $(LDADD) # Synonyms. Recall that Automake transliterates '[' and '/' to '_'. src___LDADD = $(src_test_LDADD) src_dir_LDADD = $(src_ls_LDADD) src_vdir_LDADD = $(src_ls_LDADD) src_cp_LDADD += $(copy_ldadd) src_ginstall_LDADD += $(copy_ldadd) src_mv_LDADD += $(copy_ldadd) src_mv_LDADD += $(remove_ldadd) src_rm_LDADD += $(remove_ldadd) # for eaccess, euidaccess copy_ldadd += $(LIB_EACCESS) remove_ldadd += $(LIB_EACCESS) src_sort_LDADD += $(LIB_EACCESS) src_test_LDADD += $(LIB_EACCESS) # for selinux use copy_ldadd += $(LIB_SELINUX) src_chcon_LDADD += $(LIB_SELINUX) src_ginstall_LDADD += $(LIB_SELINUX) src_id_LDADD += $(LIB_SELINUX) src_ls_LDADD += $(LIB_SELINUX) src_mkdir_LDADD += $(LIB_SELINUX) src_mkfifo_LDADD += $(LIB_SELINUX) src_mknod_LDADD += $(LIB_SELINUX) src_runcon_LDADD += $(LIB_SELINUX) src_stat_LDADD += $(LIB_SELINUX) # for gettime, settime, utimecmp, utimens copy_ldadd += $(LIB_CLOCK_GETTIME) src_date_LDADD += $(LIB_CLOCK_GETTIME) src_ginstall_LDADD += $(LIB_CLOCK_GETTIME) src_ls_LDADD += $(LIB_CLOCK_GETTIME) src_pr_LDADD += $(LIB_CLOCK_GETTIME) src_timeout_LDADD += $(LIB_TIMER_TIME) src_touch_LDADD += $(LIB_CLOCK_GETTIME) # for gethrxtime src_dd_LDADD += $(LIB_GETHRXTIME) # for cap_get_file src_ls_LDADD += $(LIB_CAP) # for fdatasync src_dd_LDADD += $(LIB_FDATASYNC) src_shred_LDADD += $(LIB_FDATASYNC) # for xnanosleep src_sleep_LDADD += $(LIB_NANOSLEEP) src_sort_LDADD += $(LIB_NANOSLEEP) src_tail_LDADD += $(LIB_NANOSLEEP) # for various GMP functions src_expr_LDADD += $(LIB_GMP) src_factor_LDADD += $(LIB_GMP) # for getloadavg src_uptime_LDADD += $(GETLOADAVG_LIBS) # for various ACL functions copy_ldadd += $(LIB_ACL) src_ls_LDADD += $(LIB_ACL) # for various xattr functions copy_ldadd += $(LIB_XATTR) # for print_unicode_char, proper_name_utf8 src_cat_LDADD += $(LIBICONV) src_cp_LDADD += $(LIBICONV) src_df_LDADD += $(LIBICONV) src_du_LDADD += $(LIBICONV) src_getlimits_LDADD += $(LIBICONV) src_printf_LDADD += $(LIBICONV) src_ptx_LDADD += $(LIBICONV) src_realpath_LDADD += $(LIBICONV) src_split_LDADD += $(LIBICONV) src_stdbuf_LDADD += $(LIBICONV) src_timeout_LDADD += $(LIBICONV) src_truncate_LDADD += $(LIBICONV) # for canon_host src_pinky_LDADD += $(GETADDRINFO_LIB) src_who_LDADD += $(GETADDRINFO_LIB) # for gethostname, uname src_hostname_LDADD += $(GETHOSTNAME_LIB) src_uname_LDADD += $(GETHOSTNAME_LIB) # for strsignal src_kill_LDADD += $(LIBTHREAD) # for pthread src_sort_LDADD += $(LIB_PTHREAD) $(PROGRAMS): lib/libcoreutils.a # Get the release year from lib/version-etc.c. RELEASE_YEAR = \ `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \ $(top_srcdir)/lib/version-etc.c` copy_sources = \ src/copy.c \ src/cp-hash.c \ src/extent-scan.c \ src/extent-scan.h # Use 'ginstall' in the definition of PROGRAMS and in dependencies to avoid # confusion with the 'install' target. The install rule transforms 'ginstall' # to install before applying any user-specified name transformations. transform = s/ginstall/install/; $(program_transform_name) src_ginstall_SOURCES = src/install.c src/prog-fprintf.c $(copy_sources) # This is for the '[' program. Automake transliterates '[' and '/' to '_'. src___SOURCES = src/lbracket.c src_cp_SOURCES = src/cp.c $(copy_sources) src_dir_SOURCES = src/ls.c src/ls-dir.c src_vdir_SOURCES = src/ls.c src/ls-vdir.c src_id_SOURCES = src/id.c src/group-list.c src_groups_SOURCES = src/groups.c src/group-list.c src_ls_SOURCES = src/ls.c src/ls-ls.c src_ln_SOURCES = src/ln.c src/relpath.c src/relpath.h src_chown_SOURCES = src/chown.c src/chown-core.c src_chgrp_SOURCES = src/chgrp.c src/chown-core.c src_kill_SOURCES = src/kill.c src/operand2sig.c src_realpath_SOURCES = src/realpath.c src/relpath.c src/relpath.h src_timeout_SOURCES = src/timeout.c src/operand2sig.c src_mv_SOURCES = src/mv.c src/remove.c $(copy_sources) src_rm_SOURCES = src/rm.c src/remove.c src_mkdir_SOURCES = src/mkdir.c src/prog-fprintf.c src_rmdir_SOURCES = src/rmdir.c src/prog-fprintf.c src_df_SOURCES = src/df.c src/find-mount-point.c src_stat_SOURCES = src/stat.c src/find-mount-point.c src_uname_SOURCES = src/uname.c src/uname-uname.c src_arch_SOURCES = src/uname.c src/uname-arch.c src_md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS) src_sha1sum_SOURCES = src/md5sum.c src_sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS) src_sha224sum_SOURCES = src/md5sum.c src_sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS) src_sha256sum_SOURCES = src/md5sum.c src_sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS) src_sha384sum_SOURCES = src/md5sum.c src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS) src_sha512sum_SOURCES = src/md5sum.c src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS) src_ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS) # Ensure we don't link against libcoreutils.a as that lib is # not compiled with -fPIC which causes issues on 64 bit at least src_libstdbuf_so_LDADD = # Note libstdbuf is only compiled if GCC is available # (as per the check in configure.ac), so these flags should be available. # libtool is probably required to relax this dependency. src_libstdbuf_so_LDFLAGS = -shared src_libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS) BUILT_SOURCES += src/dircolors.h src/dircolors.h: src/dcgen src/dircolors.hin $(AM_V_GEN)rm -f $@ $@-t $(AM_V_at)$(PERL) -w -- $(srcdir)/src/dcgen \ $(srcdir)/src/dircolors.hin > $@-t $(AM_V_at)chmod a-w $@-t $(AM_V_at)mv $@-t $@ wheel_size = 5 BUILT_SOURCES += src/wheel-size.h src/wheel-size.h: Makefile.am $(AM_V_GEN)rm -f $@ $@-t $(AM_V_at)echo '#define WHEEL_SIZE $(wheel_size)' > $@-t $(AM_V_at)chmod a-w $@-t $(AM_V_at)mv $@-t $@ BUILT_SOURCES += src/wheel.h src/wheel.h: src/wheel-gen.pl Makefile.am $(AM_V_GEN)rm -f $@ $@-t $(AM_V_at)$(srcdir)/src/wheel-gen.pl $(wheel_size) > $@-t $(AM_V_at)chmod a-w $@-t $(AM_V_at)mv $@-t $@ # false exits nonzero even with --help or --version. # test doesn't support --help or --version. # Tell automake to exempt then from that installcheck test. AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = src/false src/test # Compare fs.h with the list of file system names/magic-numbers in the # Linux statfs man page. This target prints any new name/number pairs. # Also compare against /usr/include/linux/magic.h .PHONY: src/fs-magic-compare src/fs-magic-compare: src/fs-magic src/fs-kernel-magic src/fs-def join -v1 -t@ src/fs-magic src/fs-def join -v1 -t@ src/fs-kernel-magic src/fs-def CLEANFILES += src/fs-def src/fs-def: src/fs.h grep '^# *define ' src/fs.h | $(ASSORT) > $@-t && mv $@-t $@ # Massage bits of the statfs man page and definitions from # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h. fs_normalize_perl_subst = \ -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \ -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \ -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \ -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \ -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \ -e 's/CIFS_MAGIC_NUMBER/CIFS/;' \ -e 's/(_SUPER)?_MAGIC//;' \ -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \ -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \ -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \ -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \ -e 's/^\s+//;' \ -e 's/^\043define\s+//;' \ -e 's/^_(XIAFS)/$$1/;' \ -e 's/^USBDEVICE/USBDEVFS/;' \ -e 's/NTFS_SB/NTFS/;' \ -e 's/^/\043 define S_MAGIC_/;' \ -e 's,\s*/\* .*? \*/,,;' CLEANFILES += src/fs-magic src/fs-magic: Makefile man statfs \ |perl -ne '/File system types:/.../Nobody kno/ and print' \ |grep 0x | perl -p \ $(fs_normalize_perl_subst) \ | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \ | $(ASSORT) \ > $@-t && mv $@-t $@ CLEANFILES += src/fs-kernel-magic src/fs-kernel-magic: Makefile perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \ | perl -p \ $(fs_normalize_perl_subst) \ | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \ | $(ASSORT) \ > $@-t && mv $@-t $@ BUILT_SOURCES += src/fs-is-local.h src/fs-is-local.h: src/stat.c src/extract-magic $(AM_V_GEN)rm -f $@ $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \ --local $(srcdir)/src/stat.c > $@t $(AM_V_at)chmod a-w $@t $(AM_V_at)mv $@t $@ BUILT_SOURCES += src/fs.h src/fs.h: src/stat.c src/extract-magic $(AM_V_GEN)rm -f $@ $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \ $(srcdir)/src/stat.c > $@t $(AM_V_at)chmod a-w $@t $(AM_V_at)mv $@t $@ BUILT_SOURCES += src/version.c src/version.c: Makefile $(AM_V_GEN)rm -f $@ $(AM_V_at)printf '#include \n' > $@t $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t $(AM_V_at)chmod a-w $@t $(AM_V_at)mv $@t $@ BUILT_SOURCES += src/version.h src/version.h: Makefile $(AM_V_GEN)rm -f $@ $(AM_V_at)printf 'extern char const *Version;\n' > $@t $(AM_V_at)chmod a-w $@t $(AM_V_at)mv $@t $@ DISTCLEANFILES += src/version.c src/version.h MAINTAINERCLEANFILES += $(BUILT_SOURCES) all_programs = \ $(bin_PROGRAMS) \ $(bin_SCRIPTS) \ $(EXTRA_PROGRAMS) built_programs.list: @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \ | sed -e 's,$(EXEEXT)$$,,' -e 's,^src/,,' \ | $(ASSORT) -u | tr '\n' ' ' all_programs.list: @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \ | sed /libstdbuf/d \ | $(ASSORT) -u pm = progs-makefile pr = progs-readme # Ensure that the list of programs in README matches the list # of programs we can build. check-local: check-README check-duplicate-no-install .PHONY: check-README check-README: $(AM_V_GEN)rm -rf $(pr) $(pm) $(AM_V_at)echo $(all_programs) \ | tr -s ' ' '\n' \ | sed -e 's,$(EXEEXT)$$,,' \ -e 's,^src/,,' \ -e 's/^ginstall$$/install/' \ | sed /libstdbuf/d \ | $(ASSORT) -u > $(pm) && \ sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \ | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr) $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm) # Ensure that a by-default-not-installed program (listed in # $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS) # entry, because if that were to happen, it *would* be installed # by default. .PHONY: check-duplicate-no-install check-duplicate-no-install: src/tr $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)' | tr ' ' '\n' | uniq -d`" # Use the just-built 'ginstall', when not cross-compiling. if CROSS_COMPILING cu_install_program = @INSTALL_PROGRAM@ else cu_install_program = src/ginstall endif INSTALL_PROGRAM = $(cu_install_program)