summaryrefslogtreecommitdiff
path: root/Makefile.am
diff options
context:
space:
mode:
authorAlex Deymo <deymo@chromium.org>2014-06-05 19:50:32 -0700
committerPádraig Brady <P@draigBrady.com>2014-07-13 14:23:09 +0100
commit71e2ea773414b2316bbe6b803b9a52c38d3752e8 (patch)
treea535f4cf2c4b8580be95b3c53bf061239aa31e4b /Makefile.am
parent9c128c0e4943421a73fb0cde4b06a2baa751fdeb (diff)
downloadcoreutils-71e2ea773414b2316bbe6b803b9a52c38d3752e8.tar.gz
build: support building all tools in a single binary
Add the --enable-single-binary option to the configure file. When enabled, this option builds a single binary file containing the selected tools. Which tool gets executed depends on the value of argv[0] which can be set implicitly through symlinks to the single program. This setup reduces significantly the size of a complete coreutils install, since code from lib/libcoreutils.a is not duplicated in every one of the more than 100 binaries. Runtime overhead is increased due to more dynamic libraries being loaded, and extra initialization being performed for all utils. Also initially a larger binary is loaded from storage, though this is usually alleviated due to caching and lazy mmaping of unused blocks, and in fact the single binary should have better caching characteristics. Comparing the size of the individual versus single binary on x86_64: $ cd src $ size coreutils $ size -t $(../build-aux/gen-lists-of-programs.sh --list-progs | grep -Ev '(coreutils|libstdbuf)') | tail -n1 text data bss dec hex filename 1097416 5388 88432 1191236 122d44 src/coreutils 4901010 124964 163768 5189742 4f306e (TOTALS) Storage requirements are reduced similarly: $ cd src $ du -h coreutils $ du -ch $(../build-aux/gen-lists-of-programs.sh --list-progs | grep -Ev '(coreutils|libstdbuf)') | tail -n1 1.2M coreutils 5.3M total When installing, the makefile will create either symlinks or shebangs based on the --enable-single-binary setting, for each configured tool. In this way, all the tools are still callable individually, but they are all implemented by the same "coreutils" binary installed on the same directory. * .gitignore: Add new generated files. * Makefile.am: New rules to generate build-aux/gen-single-binary.sh and install symlinks. * NEWS: Mention the new feature. * README: Add "coreutils" to the list of utils. * bootstrap.conf: Regenerate src/single-binary.mk * build-aux/gen-lists-of-programs.sh: New --list-progs option. * build-aux/gen-single-binary.sh: Regenerate * configure.ac: New --enable-single-binary option and other variables. Disallow --enable-single-binary=symlinks with --program-prefix et. al. * man/coreutils.x: Manpage hook. * man/local.mk: Add manpage hook and fix dependencies. * src/coreutils.c: Multicall implementation. * src/local.mk: New rules for the single binary option. * tests/local.mk: Add $single_binary_progs to support require_built_() from init.cfg * tests/misc/env.sh: Avoid the use of symlink to echo. * tests/misc/help-version.sh: Add exception for coreutils. * tests/install/basic-1.sh: Really avoid using ginstall strip functionality if there is an issue with the independent strip command. * src/kill.c: Changes to call exit() in main. * src/readlink.c: Likewise. * src/shuf.c: Likewise. * src/timeout.c: Likewise. * src/truncate.c: Likewise.
Diffstat (limited to 'Makefile.am')
-rw-r--r--Makefile.am24
1 files changed, 24 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index e88dc9c02..fb4af2723 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,7 @@ EXTRA_DIST = \
bootstrap \
bootstrap.conf \
build-aux/gen-lists-of-programs.sh \
+ build-aux/gen-single-binary.sh \
cfg.mk \
dist-check.mk \
maint.mk \
@@ -57,6 +58,7 @@ EXTRA_DIST = \
thanks-gen
gen_progs_lists = $(top_srcdir)/build-aux/gen-lists-of-programs.sh
+gen_single_binary = $(top_srcdir)/build-aux/gen-single-binary.sh
# Keep these in sync with bootstrap.conf:bootstrap_post_import_hook().
# Use '$(top_srcdir)/m4' and '$(srcdir)/src' for the benefit of non-GNU
@@ -70,6 +72,10 @@ $(srcdir)/src/cu-progs.mk: $(gen_progs_lists)
$(AM_V_GEN)rm -f $@ $@-t \
&& $(SHELL) $(gen_progs_lists) --automake >$@-t \
&& chmod a-w $@-t && mv -f $@-t $@
+$(srcdir)/src/single-binary.mk: $(gen_single_binary) $(srcdir)/src/local.mk
+ $(AM_V_GEN)rm -f $@ $@-t \
+ && $(SHELL) $(gen_single_binary) $(srcdir)/src/local.mk >$@-t \
+ && chmod a-w $@-t && mv -f $@-t $@
ACLOCAL_AMFLAGS = -I m4
@@ -180,6 +186,24 @@ check-git-hook-script-sync:
rm -rf $$t; \
test $$fail = 0
+# If we are building a single-binary, create symlinks or shebangs for
+# the selected tools when installing.
+install-exec-hook:
+ $(AM_V_at)ctrans=$$(printf coreutils | sed -e "$(transform)"); \
+ for p in $(single_binary_progs); do \
+ ptrans=$$(printf '%s' "$$p" | sed -e "$(transform)"); \
+ rm -f $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
+ if test "x$(single_binary_install_type)" = xshebangs; then \
+ printf '#!%s --coreutils-prog-shebang=%s\n' \
+ $(bindir)/$$ctrans$(EXEEXT) $$p \
+ >$(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
+ chmod a+x,a-w $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;\
+ else \
+ $(LN_S) -s $$ctrans$(EXEEXT) \
+ $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
+ fi \
+ done
+
noinst_LIBRARIES =
MOSTLYCLEANFILES =
CLEANFILES =