rpm-ostree/Makefile-rpm-ostree.am
Colin Walters 8f71dcfafe build-sys: Statically link binary against shlib code
Having our binary depend on the shared library, which in
turn depends on the binary (at runtime) is messy.
Instead, statically compile the shlib code into our binary.
This duplicates the text a bit, but it's not a lot of code.

The goal is to more easily in the future to e.g. move the
shared library out into a separate git repository entirely
that runs on a separate lifecycle - that would still build
using Automake for example while the main git repository
switches to purely cargo.

Another motivation is avoiding linker issues I had with other
patches due to this semi-cyclical dependency.
2021-02-09 03:37:31 -05:00

160 lines
6.2 KiB
Plaintext

# Copyright (C) 2013 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
noinst_LTLIBRARIES += librpmostreeinternals.la
librpmostreeinternals_la_SOURCES = \
src/app/libmain.cxx \
src/app/rpmostree-builtins.h \
src/app/rpmostree-db-builtins.h \
src/app/rpmostree-compose-builtins.h \
src/app/rpmostree-builtin-upgrade.cxx \
src/app/rpmostree-builtin-rollback.cxx \
src/app/rpmostree-builtin-deploy.cxx \
src/app/rpmostree-builtin-reload.cxx \
src/app/rpmostree-builtin-rebase.cxx \
src/app/rpmostree-builtin-cancel.cxx \
src/app/rpmostree-builtin-cleanup.cxx \
src/app/rpmostree-builtin-cliwrap.cxx \
src/app/rpmostree-builtin-initramfs.cxx \
src/app/rpmostree-builtin-initramfs-etc.cxx \
src/app/rpmostree-builtin-livefs.cxx \
src/app/rpmostree-builtin-usroverlay.cxx \
src/app/rpmostree-builtin-override.cxx \
src/app/rpmostree-builtin-refresh-md.cxx \
src/app/rpmostree-builtin-reset.cxx \
src/app/rpmostree-pkg-builtins.cxx \
src/app/rpmostree-builtin-status.cxx \
src/app/rpmostree-builtin-ex.cxx \
src/app/rpmostree-builtin-testutils.cxx \
src/app/rpmostree-builtin-shlib-backend.cxx \
src/app/rpmostree-builtin-db.cxx \
src/app/rpmostree-builtin-start-daemon.cxx \
src/app/rpmostree-builtin-finalize-deployment.cxx \
src/app/rpmostree-db-builtin-diff.cxx \
src/app/rpmostree-db-builtin-list.cxx \
src/app/rpmostree-db-builtin-version.cxx \
src/app/rpmostree-dbus-helpers.cxx \
src/app/rpmostree-dbus-helpers.h \
src/app/rpmostree-override-builtins.h \
src/app/rpmostree-override-builtins.cxx \
src/app/rpmostree-libbuiltin.cxx \
src/app/rpmostree-libbuiltin.h \
src/app/rpmostree-polkit-agent.cxx \
src/app/rpmostree-polkit-agent.h \
src/app/rpmostree-builtin-kargs.cxx \
src/app/rpmostree-compose-builtin-tree.cxx \
src/app/rpmostree-composeutil.cxx \
src/app/rpmostree-composeutil.h \
src/app/rpmostree-builtin-compose.cxx \
$(librpmostreed_sources) \
$(librpmostreepriv_sources) \
$(librpmostree_1_la_SOURCES) \
$(NULL)
if BUILDOPT_ROJIG
librpmostreeinternals_la_SOURCES += \
src/app/rpmostree-ex-builtin-commit2rojig.cxx \
src/app/rpmostree-ex-builtin-rojig2commit.cxx \
src/app/rpmostree-compose-builtin-rojig.cxx \
$(NULL)
endif
nodist_librpmostreeinternals_la_SOURCES = $(dbus_built_sources) $(nodist_librpmostreepriv_sources)
rpmostree_common_cflags = -I$(srcdir)/src/app -I$(srcdir)/src/daemon \
-I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \
-DG_LOG_DOMAIN=\"rpm-ostreed\" \
-DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \
-I $(top_srcdir)/libdnf \
-D_RPMOSTREE_EXTERN= \
$(PKGDEP_LIBRPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS)
rpmostree_bin_common_cflags = $(rpmostree_common_cflags)
rpmostree_common_libs = libglnx.la librpmostreecxxrs.la
rpmostree_bin_common_libs = librpmostreeinternals.la $(rpmostree_common_libs)
librpmostreeinternals_la_CFLAGS = $(AM_CFLAGS) $(rpmostree_common_cflags)
librpmostreeinternals_la_CXXFLAGS = $(AM_CXXFLAGS) $(rpmostree_common_cflags)
librpmostreeinternals_la_LIBADD = $(rpmostree_common_libs)
privdatadir=$(pkglibdir)
privdata_DATA = src/app/rpm-ostree-0-integration.conf
# Propagate automake verbose mode
cargo_build = $(cargo) build $(if $(subst 0,,$(V)),--verbose,)
if BUILDOPT_PREBUILT_BINDINGS
cargo_build += "--offline"
endif
if BUILDOPT_ENABLE_SQLITE_RPMDB_DEFAULT
cargo_build += --features sqlite-rpmdb-default
endif
if RUST_DEBUG
cargo_target_dir=debug
else
cargo_target_dir=release
endif
LIBRPMOSTREE_RUST_SRCS = $(shell find rust/src/ -name '*.rs') Cargo.toml Cargo.lock cbindgen.toml
# FIXME - build all this code in a rpmostree-sys crate, or just move all the C/C++ build
# to Rust. Currently this forces build system serialization
rpm-ostree: Makefile $(LIBRPMOSTREE_RUST_SRCS) librpmostreeinternals.la
$(cargo_build) $(CARGO_RELEASE_ARGS)
ln -sfr target/$(cargo_target_dir)/rpm-ostree $@
EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS)
ALL_LOCAL_HOOKS += rpm-ostree
CLEANFILES += rpm-ostree
# cbindgen + cxx.rs
binding_generated_sources = rpmostree-rust.h rpmostree-cxxrs.h rpmostree-cxxrs.cxx rust/cxx.h
if BUILDOPT_PREBUILT_BINDINGS
# In this case we shipped prebuilt versions in the source tarball
rpmostree-rust.h:
ln -sfr rpmostree-rust-prebuilt.h $@
rpmostree-cxxrs.h:
ln -sfr rpmostree-cxxrs-prebuilt.h $@
rpmostree-cxxrs.cxx:
ln -sfr rpmostree-cxxrs-prebuilt.cxx $@
rust/cxx.h:
ln -sfr rust/cxx-prebuilt.h $@
else
include Makefile.bindings
endif
noinst_LTLIBRARIES += librpmostreecxxrs.la
librpmostreecxxrs_la_SOURCES = rpmostree-cxxrs.h rpmostree-cxxrs.cxx
# Suppress missing-declarations because https://github.com/dtolnay/cxx/issues/590
librpmostreecxxrs_la_CXXFLAGS = $(AM_CXXFLAGS) $(rpmostree_common_cflags) -Wno-missing-declarations
librpmostreecxxrs_la_LIBADD = -lstdc++
GITIGNOREFILES += $(binding_generated_sources)
BUILT_SOURCES += $(binding_generated_sources)
# And install our binary
install-rpmostree-hook:
install -d -m 0755 $(DESTDIR)$(bindir)
install -m 0755 -t $(DESTDIR)$(bindir) rpm-ostree
INSTALL_EXEC_HOOKS += install-rpmostree-hook
# Wraps `cargo test`. This is always a debug non-release build;
# the main thing here is we still drop the `target` dir in our build
# directory, since we nominally support srcdir != builddir.
rust-test: $(binding_generated_sources) $(dbus_built_sources) $(librpmostree_rust_path) librpmostreecxxrs.la librpmostreeinternals.la
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@abs_top_builddir@/.libs/" cargo test
rust-test-%: $(binding_generated_sources) $(dbus_built_sources) $(librpmostree_rust_path) librpmostreecxxrs.la librpmostreeinternals.la
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@abs_top_builddir@/.libs/" cargo test -- $*
.PHONY: rust-test rust-test-%