diff options
author | William Manley <will@williammanley.net> | 2016-08-30 20:28:02 +0100 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2016-08-30 20:50:33 +0000 |
commit | 42dab85728385eaf538b36ed56e9db7ff3f96faa (patch) | |
tree | 598899d5862512236233320d41f3e1ec8070cc86 /Makefile-switchroot.am | |
parent | faee3df8ae244896f531ab7ad00c8ea75f148da3 (diff) | |
download | ostree-42dab85728385eaf538b36ed56e9db7ff3f96faa.tar.gz |
ostree-prepare-root: Allow building statically with musl
If the `--with-static-compiler=musl-gcc` configure flag is given.
ostree-prepare-root can be used as init in a system without a populated
/lib. To support this use case we need to link statically as we will be
unable to locate libc.so at run time if it's not installed in /lib.
We support building ostree-prepare-root with a different compiler to the
rest of ostree so we can use musl rather than glibc. This reduces the size
of the executable significantly: from ~700K -> ~30K. We have to use
`_SCRIPTS` here to get autotools to install this as an executable but
without generating rules to make it itself which we have specified
manually.
See https://lists.gnu.org/archive/html/help-gnu-utils/2007-01/msg00007.html
for advice on using autotools in this manner.
Closes: #477
Approved by: cgwalters
Diffstat (limited to 'Makefile-switchroot.am')
-rw-r--r-- | Makefile-switchroot.am | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/Makefile-switchroot.am b/Makefile-switchroot.am index f79553eb..10866bd1 100644 --- a/Makefile-switchroot.am +++ b/Makefile-switchroot.am @@ -17,7 +17,6 @@ if BUILDOPT_SYSTEMD -ostree_boot_PROGRAMS += ostree-prepare-root ostree_boot_PROGRAMS += ostree-remount noinst_LTLIBRARIES += libswitchroot-mountutil.la @@ -28,9 +27,32 @@ libswitchroot_mountutil_la_SOURCES = \ src/switchroot/ostree-mount-util.h \ $(NULL) -ostree_prepare_root_SOURCES = src/switchroot/ostree-prepare-root.c -ostree_prepare_root_LDADD = libswitchroot-mountutil.la +ostree_prepare_root_SOURCES = \ + src/switchroot/ostree-mount-util.c \ + src/switchroot/ostree-mount-util.h \ + src/switchroot/ostree-prepare-root.c \ + $(NULL) + +if BUILDOPT_USE_STATIC_COMPILER +# ostree-prepare-root can be used as init in a system without a populated /lib. +# To support this use case we need to link statically as we will be unable to +# locate libc.so at run time if it's not installed in /lib. +# +# We support building ostree-prepare-root with a different compiler to the rest +# of ostree so we can use musl rather than glibc. This reduces the size of the +# executable significantly: from ~700K -> ~30K. We have to use _SCRIPTS here +# to get autotools to install this as an executable but without generating rules +# to make it itself which we have specified manually. See +# https://lists.gnu.org/archive/html/help-gnu-utils/2007-01/msg00007.html +ostree_boot_SCRIPTS = ostree-prepare-root + +ostree-prepare-root : $(ostree_prepare_root_SOURCES) + $(STATIC_COMPILER) -o $@ -static $(ostree_prepare_root_SOURCES) $(AM_CPPFLAGS) $(AM_CFLAGS) +else +ostree_boot_PROGRAMS += ostree-prepare-root + ostree_prepare_root_CFLAGS = $(AM_CFLAGS) -Isrc/switchroot +endif ostree_remount_SOURCES = src/switchroot/ostree-remount.c ostree_remount_LDADD = libswitchroot-mountutil.la |