summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-09-01 01:46:40 +0200
committerJim Meyering <meyering@redhat.com>2012-09-01 21:25:13 +0200
commit5e60e0d37e541d9f2311c7b60da61ba66a69f9e4 (patch)
treefc028f51dc5a7444e679630b8b60ac47cc5b3abc
parent4f2e62ba9fd482375fdc085de71a5c947741d140 (diff)
downloadcoreutils-5e60e0d37e541d9f2311c7b60da61ba66a69f9e4.tar.xz
build: don't use recursive make to build the 'src' subdirectory
* Makefile.am (SUBDIRS): Remove 'src'. Ensure '.' is listed before 'tests' and 'gnulib-tests'. (dist-hook): Adjust: we must now tweak the top-level Makefile.in in $(distdir), not the one in the 'src/' subdir (which is gone). (include): The '$(top_srcdir)/src/local.mk' file. * build-aux/gen-lists-of-programs.sh: Adjust the generation of the automake input fragment. * tests/Makefile.am (.built-programs): Adjust. * cfg.mk (all_programs): Remove this convenience rule; it's no longer needed, now that we can rely directly on the contents of $(all_programs). (sc_option_desc_uppercase, check-programs-vs-x:): Adjust lists of prerequisites accordingly. (all-progs-but-lbracket): Simplify definition accordingly. * configure.ac ($OPTIONAL_BIN_PROGS): Adjust definition. ($OPTIONAL_PKGLIB_PROGS): Likewise. ($NO_INSTALL_PROGS_DEFAULT): Tweak definition, for consistency. (AC_CONFIG_FILES): Remove 'src/Makefile'. * src/Makefile.am: Rename ... * src/local.mk: ... like this, with a lot of adjustments. In addition ... (all_programs): ... remove this now-unneeded convenience target.
-rw-r--r--Makefile.am5
-rwxr-xr-xbuild-aux/gen-lists-of-programs.sh7
-rw-r--r--cfg.mk13
-rw-r--r--configure.ac16
-rw-r--r--src/Makefile.am560
-rw-r--r--src/local.mk567
-rw-r--r--tests/Makefile.am6
7 files changed, 592 insertions, 582 deletions
diff --git a/Makefile.am b/Makefile.am
index f3d6eda57..6a56f6832 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,7 @@
ALL_RECURSIVE_TARGETS =
-SUBDIRS = lib src po tests gnulib-tests
+SUBDIRS = lib po . tests gnulib-tests
changelog_etc = \
ChangeLog-2005 \
@@ -92,7 +92,7 @@ BUILT_SOURCES = .version
# See the rm_subst comment for details.
dist-hook: gen-ChangeLog
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
- $(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in
+ $(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/Makefile.in
gen_start_date = 2008-02-08
.PHONY: gen-ChangeLog
@@ -170,5 +170,6 @@ check-git-hook-script-sync:
rm -rf $$t; \
test $$fail = 0
+include $(top_srcdir)/src/local.mk
include $(top_srcdir)/doc/local.mk
include $(top_srcdir)/man/local.mk
diff --git a/build-aux/gen-lists-of-programs.sh b/build-aux/gen-lists-of-programs.sh
index 2db0745bc..c0b1fedc9 100755
--- a/build-aux/gen-lists-of-programs.sh
+++ b/build-aux/gen-lists-of-programs.sh
@@ -164,17 +164,18 @@ END
;;
1,--automake|1,--for-automake)
echo "## $msg"
+ progsdir=src
echo no_install__progs =
for p in $disabled_by_default_progs; do
- echo no_install__progs += $p
+ echo no_install__progs += $progsdir/$p
done
echo build_if_possible__progs =
for p in $build_if_possible_progs; do
- echo build_if_possible__progs += $p
+ echo build_if_possible__progs += $progsdir/$p
done
echo default__progs =
for p in $normal_progs; do
- echo default__progs += $p
+ echo default__progs += $progsdir/$p
done
;;
*)
diff --git a/cfg.mk b/cfg.mk
index 1dbfe4241..b56e329d6 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -166,12 +166,6 @@ sc_long_lines:
sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
-# TODO: remove once the build system in 'src/' is merged with the
-# top-level one.
-.PHONY: all_programs
-all_programs:
- @cd ./src && $(MAKE) -s $@
-
# Option descriptions should not start with a capital letter.
# One could grep source directly as follows:
# grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
@@ -183,7 +177,7 @@ sc_option_desc_uppercase:
&& { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
sc_option_desc_uppercase: $(dist_man1_MANS) \
$(patsubst %,man/%.1,$(NO_INSTALL_PROGS_DEFAULT)) \
- all_programs
+ $(all_programs)
# Ensure all man/*.[1x] files are present.
ALL_RECURSIVE_TARGETS += sc_man_file_correlation
@@ -208,13 +202,12 @@ check-x-vs-1:
# Writing a portable rule to generate a manpage like '[.1' would be
# a nightmare.
-all-progs-but-lbracket = $(filter-out [, $(shell \
- (cd ./src && MAKEFLAGS= ${MAKE} -s all_programs.list)))
+all-progs-but-lbracket = $(filter-out [,$(all_programs))
# Ensure that for each .x file in the 'man/' subdirectory, there is a
# corresponding coreutils program.
.PHONY: check-programs-vs-x
-check-programs-vs-x: all_programs
+check-programs-vs-x: $(all_programs)
@status=0; \
for p in dummy $(all-progs-but-lbracket); do \
test $$p = dummy && continue; \
diff --git a/configure.ac b/configure.ac
index de0dea86b..f169a44a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -438,14 +438,23 @@ MAN=`
test x$p = x'@<:@' && continue
echo "man/$p.1"
done`
+
+NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
+OPTIONAL_PKGLIB_PROGS=`
+ for p in $optional_pkglib_progs; do echo src/$p; done`
+# Since this is AC_SUBST'd, Automake won't be able to perform rewrite
+# with $(EXEEXT) appending on it, so we have to do it ourselves.
+OPTIONAL_BIN_PROGS=`
+ for p in $optional_bin_progs; do echo "src/$p\$(EXEEXT)"; done`
+
# Normalize whitespace.
MAN=`echo $MAN`
+NO_INSTALL_PROGS_DEFAULT=`echo $NO_INSTALL_PROGS_DEFAULT`
+OPTIONAL_BIN_PROGS=`echo $OPTIONAL_BIN_PROGS`
+OPTIONAL_PKGLIB_PROGS=`echo $OPTIONAL_PKGLIB_PROGS`
-NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
-OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
AC_SUBST([OPTIONAL_BIN_PROGS])
-OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
AC_SUBST([OPTIONAL_PKGLIB_PROGS])
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
@@ -464,7 +473,6 @@ AC_CONFIG_FILES(
Makefile
lib/Makefile
po/Makefile.in
- src/Makefile
tests/Makefile
gnulib-tests/Makefile
)
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 3b0ef6593..000000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,560 +0,0 @@
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-
-## 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 <http://www.gnu.org/licenses/>.
-
-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)/cu-progs.mk
-
-EXTRA_PROGRAMS = \
- $(no_install__progs) \
- $(build_if_possible__progs) \
- $(default__progs)
-
-bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
-
-noinst_PROGRAMS = setuidgid getlimits
-
-pkglibexec_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
-
-noinst_HEADERS = \
- chown-core.h \
- copy.h \
- cp-hash.h \
- dircolors.h \
- fiemap.h \
- find-mount-point.h \
- fs.h \
- fs-is-local.h \
- group-list.h \
- ioblksize.h \
- ls.h \
- operand2sig.h \
- prog-fprintf.h \
- remove.h \
- system.h \
- wheel-size.h \
- wheel.h \
- uname.h
-
-EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
- wheel-gen.pl extract-magic c99-to-c89.diff
-BUILT_SOURCES =
-CLEANFILES = $(SCRIPTS)
-
-# Also remove these sometimes-built programs.
-# For example, even when excluded, they're built via _sc_check-AUTHORS.
-CLEANFILES += $(no_install__progs)
-
-AM_CPPFLAGS = -I$(top_srcdir)/lib
-
-noinst_LIBRARIES = libver.a
-nodist_libver_a_SOURCES = version.c 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 = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
-
-# First, list all programs, to make listing per-program libraries easier.
-# See [ below.
-arch_LDADD = $(LDADD)
-base64_LDADD = $(LDADD)
-basename_LDADD = $(LDADD)
-cat_LDADD = $(LDADD)
-chcon_LDADD = $(LDADD)
-chgrp_LDADD = $(LDADD)
-chmod_LDADD = $(LDADD)
-chown_LDADD = $(LDADD)
-chroot_LDADD = $(LDADD)
-cksum_LDADD = $(LDADD)
-comm_LDADD = $(LDADD)
-nproc_LDADD = $(LDADD)
-cp_LDADD = $(LDADD)
-csplit_LDADD = $(LDADD)
-cut_LDADD = $(LDADD)
-date_LDADD = $(LDADD)
-dd_LDADD = $(LDADD)
-df_LDADD = $(LDADD)
-# See dir_LDADD below
-dircolors_LDADD = $(LDADD)
-dirname_LDADD = $(LDADD)
-du_LDADD = $(LDADD)
-echo_LDADD = $(LDADD)
-env_LDADD = $(LDADD)
-expand_LDADD = $(LDADD)
-expr_LDADD = $(LDADD)
-factor_LDADD = $(LDADD)
-false_LDADD = $(LDADD)
-fmt_LDADD = $(LDADD)
-fold_LDADD = $(LDADD)
-getlimits_LDADD = $(LDADD)
-ginstall_LDADD = $(LDADD)
-groups_LDADD = $(LDADD)
-head_LDADD = $(LDADD)
-hostid_LDADD = $(LDADD)
-hostname_LDADD = $(LDADD)
-id_LDADD = $(LDADD)
-join_LDADD = $(LDADD)
-kill_LDADD = $(LDADD)
-link_LDADD = $(LDADD)
-ln_LDADD = $(LDADD)
-logname_LDADD = $(LDADD)
-ls_LDADD = $(LDADD)
-md5sum_LDADD = $(LDADD)
-mkdir_LDADD = $(LDADD)
-mkfifo_LDADD = $(LDADD)
-mknod_LDADD = $(LDADD)
-mktemp_LDADD = $(LDADD)
-mv_LDADD = $(LDADD)
-nice_LDADD = $(LDADD)
-nl_LDADD = $(LDADD)
-nohup_LDADD = $(LDADD)
-od_LDADD = $(LDADD)
-paste_LDADD = $(LDADD)
-pathchk_LDADD = $(LDADD)
-pinky_LDADD = $(LDADD)
-pr_LDADD = $(LDADD)
-printenv_LDADD = $(LDADD)
-printf_LDADD = $(LDADD)
-ptx_LDADD = $(LDADD)
-pwd_LDADD = $(LDADD)
-readlink_LDADD = $(LDADD)
-realpath_LDADD = $(LDADD)
-rm_LDADD = $(LDADD)
-rmdir_LDADD = $(LDADD)
-runcon_LDADD = $(LDADD)
-seq_LDADD = $(LDADD)
-setuidgid_LDADD = $(LDADD)
-sha1sum_LDADD = $(LDADD)
-sha224sum_LDADD = $(LDADD)
-sha256sum_LDADD = $(LDADD)
-sha384sum_LDADD = $(LDADD)
-sha512sum_LDADD = $(LDADD)
-shred_LDADD = $(LDADD)
-shuf_LDADD = $(LDADD)
-sleep_LDADD = $(LDADD)
-sort_LDADD = $(LDADD)
-split_LDADD = $(LDADD)
-stat_LDADD = $(LDADD)
-stdbuf_LDADD = $(LDADD)
-stty_LDADD = $(LDADD)
-sum_LDADD = $(LDADD)
-sync_LDADD = $(LDADD)
-tac_LDADD = $(LDADD)
-tail_LDADD = $(LDADD)
-tee_LDADD = $(LDADD)
-test_LDADD = $(LDADD)
-timeout_LDADD = $(LDADD)
-touch_LDADD = $(LDADD)
-tr_LDADD = $(LDADD)
-true_LDADD = $(LDADD)
-truncate_LDADD = $(LDADD)
-tsort_LDADD = $(LDADD)
-tty_LDADD = $(LDADD)
-uname_LDADD = $(LDADD)
-unexpand_LDADD = $(LDADD)
-uniq_LDADD = $(LDADD)
-unlink_LDADD = $(LDADD)
-uptime_LDADD = $(LDADD)
-users_LDADD = $(LDADD)
-# See vdir_LDADD below
-wc_LDADD = $(LDADD)
-who_LDADD = $(LDADD)
-whoami_LDADD = $(LDADD)
-yes_LDADD = $(LDADD)
-
-# Synonyms. Recall that Automake transliterates '[' to '_'.
-__LDADD = $(test_LDADD)
-dir_LDADD = $(ls_LDADD)
-vdir_LDADD = $(ls_LDADD)
-
-cp_LDADD += $(copy_ldadd)
-ginstall_LDADD += $(copy_ldadd)
-mv_LDADD += $(copy_ldadd)
-
-mv_LDADD += $(remove_ldadd)
-rm_LDADD += $(remove_ldadd)
-
-# for eaccess, euidaccess
-copy_ldadd += $(LIB_EACCESS)
-remove_ldadd += $(LIB_EACCESS)
-sort_LDADD += $(LIB_EACCESS)
-test_LDADD += $(LIB_EACCESS)
-
-# for selinux use
-copy_ldadd += $(LIB_SELINUX)
-chcon_LDADD += $(LIB_SELINUX)
-ginstall_LDADD += $(LIB_SELINUX)
-id_LDADD += $(LIB_SELINUX)
-ls_LDADD += $(LIB_SELINUX)
-mkdir_LDADD += $(LIB_SELINUX)
-mkfifo_LDADD += $(LIB_SELINUX)
-mknod_LDADD += $(LIB_SELINUX)
-runcon_LDADD += $(LIB_SELINUX)
-stat_LDADD += $(LIB_SELINUX)
-
-# for gettime, settime, utimecmp, utimens
-copy_ldadd += $(LIB_CLOCK_GETTIME)
-date_LDADD += $(LIB_CLOCK_GETTIME)
-ginstall_LDADD += $(LIB_CLOCK_GETTIME)
-ls_LDADD += $(LIB_CLOCK_GETTIME)
-pr_LDADD += $(LIB_CLOCK_GETTIME)
-timeout_LDADD += $(LIB_TIMER_TIME)
-touch_LDADD += $(LIB_CLOCK_GETTIME)
-
-# for gethrxtime
-dd_LDADD += $(LIB_GETHRXTIME)
-
-# for cap_get_file
-ls_LDADD += $(LIB_CAP)
-
-# for fdatasync
-dd_LDADD += $(LIB_FDATASYNC)
-shred_LDADD += $(LIB_FDATASYNC)
-
-# for xnanosleep
-sleep_LDADD += $(LIB_NANOSLEEP)
-sort_LDADD += $(LIB_NANOSLEEP)
-tail_LDADD += $(LIB_NANOSLEEP)
-
-# for various GMP functions
-expr_LDADD += $(LIB_GMP)
-factor_LDADD += $(LIB_GMP)
-
-# for getloadavg
-uptime_LDADD += $(GETLOADAVG_LIBS)
-
-# for various ACL functions
-copy_ldadd += $(LIB_ACL)
-ls_LDADD += $(LIB_ACL)
-
-# for various xattr functions
-copy_ldadd += $(LIB_XATTR)
-
-# for print_unicode_char, proper_name_utf8
-cat_LDADD += $(LIBICONV)
-cp_LDADD += $(LIBICONV)
-df_LDADD += $(LIBICONV)
-du_LDADD += $(LIBICONV)
-getlimits_LDADD += $(LIBICONV)
-printf_LDADD += $(LIBICONV)
-ptx_LDADD += $(LIBICONV)
-realpath_LDADD += $(LIBICONV)
-split_LDADD += $(LIBICONV)
-stdbuf_LDADD += $(LIBICONV)
-timeout_LDADD += $(LIBICONV)
-truncate_LDADD += $(LIBICONV)
-
-# for canon_host
-pinky_LDADD += $(GETADDRINFO_LIB)
-who_LDADD += $(GETADDRINFO_LIB)
-
-# for gethostname, uname
-hostname_LDADD += $(GETHOSTNAME_LIB)
-uname_LDADD += $(GETHOSTNAME_LIB)
-
-# for strsignal
-kill_LDADD += $(LIBTHREAD)
-
-# for pthread
-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 = copy.c cp-hash.c extent-scan.c 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)
-ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
-
-# This is for the '[' program. Automake transliterates '[' to '_'.
-__SOURCES = lbracket.c
-
-cp_SOURCES = cp.c $(copy_sources)
-dir_SOURCES = ls.c ls-dir.c
-vdir_SOURCES = ls.c ls-vdir.c
-id_SOURCES = id.c group-list.c
-groups_SOURCES = groups.c group-list.c
-ls_SOURCES = ls.c ls-ls.c
-ln_SOURCES = ln.c relpath.c relpath.h
-chown_SOURCES = chown.c chown-core.c
-chgrp_SOURCES = chgrp.c chown-core.c
-kill_SOURCES = kill.c operand2sig.c
-realpath_SOURCES = realpath.c relpath.c relpath.h
-timeout_SOURCES = timeout.c operand2sig.c
-
-mv_SOURCES = mv.c remove.c $(copy_sources)
-rm_SOURCES = rm.c remove.c
-
-mkdir_SOURCES = mkdir.c prog-fprintf.c
-rmdir_SOURCES = rmdir.c prog-fprintf.c
-
-df_SOURCES = df.c find-mount-point.c
-stat_SOURCES = stat.c find-mount-point.c
-
-uname_SOURCES = uname.c uname-uname.c
-arch_SOURCES = uname.c uname-arch.c
-
-md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
-sha1sum_SOURCES = md5sum.c
-sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
-sha224sum_SOURCES = md5sum.c
-sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
-sha256sum_SOURCES = md5sum.c
-sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
-sha384sum_SOURCES = md5sum.c
-sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
-sha512sum_SOURCES = md5sum.c
-sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
-
-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
-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.
-libstdbuf_so_LDFLAGS = -shared
-libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
-
-BUILT_SOURCES += dircolors.h
-dircolors.h: dcgen dircolors.hin
- $(AM_V_GEN)rm -f $@ $@-t
- $(AM_V_at)$(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
- $(AM_V_at)chmod a-w $@-t
- $(AM_V_at)mv $@-t $@
-
-wheel_size = 5
-
-BUILT_SOURCES += wheel-size.h
-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 += wheel.h
-wheel.h: wheel-gen.pl Makefile.am
- $(AM_V_GEN)rm -f $@ $@-t
- $(AM_V_at)$(srcdir)/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 = false 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: fs-magic-compare
-fs-magic-compare: fs-magic fs-kernel-magic fs-def
- join -v1 -t@ fs-magic fs-def
- join -v1 -t@ fs-kernel-magic fs-def
-
-CLEANFILES += fs-def
-fs-def: fs.h
- grep '^# *define ' 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 += fs-magic
-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 += fs-kernel-magic
-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 += fs-is-local.h
-fs-is-local.h: stat.c extract-magic
- $(AM_V_GEN)rm -f $@
- $(AM_V_at)$(PERL) $(srcdir)/extract-magic --local $(srcdir)/stat.c \
- > $@t
- $(AM_V_at)chmod a-w $@t
- $(AM_V_at)mv $@t $@
-
-BUILT_SOURCES += fs.h
-fs.h: stat.c extract-magic
- $(AM_V_GEN)rm -f $@
- $(AM_V_at)$(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
- $(AM_V_at)chmod a-w $@t
- $(AM_V_at)mv $@t $@
-
-BUILT_SOURCES += version.c
-version.c: Makefile
- $(AM_V_GEN)rm -f $@
- $(AM_V_at)printf '#include <config.h>\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 += version.h
-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 = version.c version.h
-MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-
-# Sort in traditional ASCII order, regardless of the current locale;
-# otherwise we may get into trouble with distinct strings that the
-# current locale considers to be equal.
-ASSORT = LC_ALL=C sort
-
-all_programs = \
- $(bin_PROGRAMS) \
- $(bin_SCRIPTS) \
- $(EXTRA_PROGRAMS)
-
-built_programs.list:
- @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
- | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
-
-all_programs.list:
- @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
- | sed /libstdbuf/d \
- | $(ASSORT) -u
-
-# This is required because we have broken inter-directory dependencies:
-# in order to generate all man pages, even those for which we don't
-# install a binary, require that all programs be built at distribution time.
-dist-hook: $(all_programs)
-
-# Ensure that all programs are built so we can for example
-# subsequently syntax check all man pages.
-.PHONY: all_programs
-all_programs: $(all_programs)
-
-pm = progs-makefile
-pr = progs-readme
-# Ensure that the list of programs in README matches the list
-# of programs we can build.
-check: 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)$$,,;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: tr
- $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
-
-# Ensure that the list of programs and author names is accurate.
-# We need a UTF8 locale. If a lack of locale support or a missing
-# translation inhibits printing of UTF-8 names, just skip this test.
-au_dotdot = authors-dotdot
-au_actual = authors-actual
-.PHONY: _sc_check-AUTHORS
-_sc_check-AUTHORS: $(all_programs)
- @locale=en_US.UTF-8; \
- LC_ALL=$$locale ./cat --version \
- | grep ' Torbjorn ' > /dev/null \
- && { echo "$@: skipping this check"; exit 0; }; \
- rm -f $(au_actual) $(au_dotdot); \
- for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
- | sed /libstdbuf/d \
- | $(ASSORT) -u`; do \
- test "$$i" = '[' && continue; \
- exe=$$i; \
- if test "$$i" = install; then \
- exe=ginstall; \
- elif test "$$i" = test; then \
- exe='['; \
- fi; \
- LC_ALL=$$locale ./$$exe --version \
- | perl -0 -pi -e 's/,\n/, /gm' \
- | sed -n -e '/Written by /{ s//'"$$i"': /;' \
- -e 's/,* and /, /; s/\.$$//; p; }'; \
- done > $(au_actual) && \
- sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
- diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
-
-# Use the just-built ./ginstall, when not cross-compiling.
-if CROSS_COMPILING
-cu_install_program = @INSTALL_PROGRAM@
-else
-cu_install_program = ./ginstall
-endif
-INSTALL_PROGRAM = $(cu_install_program)
diff --git a/src/local.mk b/src/local.mk
new file mode 100644
index 000000000..45a6268e2
--- /dev/null
+++ b/src/local.mk
@@ -0,0 +1,567 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+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)
+
+bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
+
+noinst_PROGRAMS = src/setuidgid src/getlimits
+
+pkglibexec_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
+
+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.
+CLEANFILES += $(no_install__progs)
+
+AM_CPPFLAGS = -I$(top_srcdir)/lib
+
+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 <config.h>\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
+
+# This is required because we have broken inter-directory dependencies:
+# in order to generate all man pages, even those for which we don't
+# install a binary, require that all programs be built at distribution time.
+dist-hook: $(all_programs)
+
+pm = progs-makefile
+pr = progs-readme
+# Ensure that the list of programs in README matches the list
+# of programs we can build.
+check: 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`"
+
+# Ensure that the list of programs and author names is accurate.
+# We need a UTF8 locale. If a lack of locale support or a missing
+# translation inhibits printing of UTF-8 names, just skip this test.
+au_dotdot = authors-dotdot
+au_actual = authors-actual
+.PHONY: _sc_check-AUTHORS
+_sc_check-AUTHORS: $(all_programs)
+ @locale=en_US.UTF-8; \
+ LC_ALL=$$locale ./cat --version \
+ | grep ' Torbjorn ' > /dev/null \
+ && { echo "$@: skipping this check"; exit 0; }; \
+ rm -f $(au_actual) $(au_dotdot); \
+ for i in `ls $(all_programs) \
+ | sed -e 's,^src/,,' -e 's,$(EXEEXT)$$,,' \
+ | sed /libstdbuf/d \
+ | $(ASSORT) -u`; do \
+ test "$$i" = '[' && continue; \
+ exe=$$i; \
+ if test "$$i" = install; then \
+ exe=ginstall; \
+ elif test "$$i" = test; then \
+ exe='['; \
+ fi; \
+ LC_ALL=$$locale ./$$exe --version \
+ | perl -0 -pi -e 's/,\n/, /gm' \
+ | sed -n -e '/Written by /{ s//'"$$i"': /;' \
+ -e 's/,* and /, /; s/\.$$//; p; }'; \
+ done > $(au_actual) && \
+ sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
+ diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
+
+# 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)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d8dee57fe..54f1e08f8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,10 +40,10 @@ check: vc_exe_in_TESTS
CLEANFILES =
CLEANFILES += .built-programs
check_DATA = .built-programs
-.built-programs: $(top_srcdir)/src/Makefile.am
- $(AM_V_GEN)(cd $(top_builddir)/src \
+.built-programs: $(top_srcdir)/Makefile.am
+ $(AM_V_GEN)(cd $(top_builddir) \
&& MAKEFLAGS= $(MAKE) -s built_programs.list) \
- > $@-t && mv $@-t $@
+ | sed s,^src/,, > $@-t && mv $@-t $@
TEST_EXTENSIONS = .sh .pl .xpl