971dc18
From 9d6e0f96acf99073b0763c161d5c02505c4880a8 Mon Sep 17 00:00:00 2001
bfc63f7
From: Zygmunt Krynicki <me@zygoon.pl>
bfc63f7
Date: Mon, 6 Mar 2017 20:26:26 +0100
9be0073
Subject: [PATCH] cmd: use libtool for the internal library
bfc63f7
bfc63f7
This just cuts some hassle integration with how the helper library is
bfc63f7
built. I could never get to pass the right -fPIC/-fpie combination
bfc63f7
otherwise.
bfc63f7
bfc63f7
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
bfc63f7
---
e2755c3
 cmd/Makefile.am  | 32 ++++++++++++++++----------------
bfc63f7
 cmd/configure.ac |  3 ++-
e2755c3
 2 files changed, 18 insertions(+), 17 deletions(-)
bfc63f7
bfc63f7
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
971dc18
index de905ad59..ed72749b1 100644
bfc63f7
--- a/cmd/Makefile.am
bfc63f7
+++ b/cmd/Makefile.am
971dc18
@@ -84,12 +84,12 @@ snap-seccomp/snap-seccomp: snap-seccomp/*.go
98b1193
 	cd snap-seccomp && GOPATH=$(or $(GOPATH),$(realpath $(srcdir)/../../../../..)) go build -i -v
bfc63f7
 
bfc63f7
 ##
bfc63f7
-## libsnap-confine-private.a
bfc63f7
+## libsnap-confine-private.la
bfc63f7
 ##
bfc63f7
 
bfc63f7
-noinst_LIBRARIES += libsnap-confine-private.a
9be0073
+noinst_LTLIBRARIES = libsnap-confine-private.la
bfc63f7
 
bfc63f7
-libsnap_confine_private_a_SOURCES = \
bfc63f7
+libsnap_confine_private_la_SOURCES = \
971dc18
 	libsnap-confine-private/apparmor-support.c \
971dc18
 	libsnap-confine-private/apparmor-support.h \
98b1193
 	libsnap-confine-private/cgroup-freezer-support.c \
971dc18
@@ -122,11 +122,11 @@ libsnap_confine_private_a_SOURCES = \
971dc18
 	libsnap-confine-private/tool.h \
14ee876
 	libsnap-confine-private/utils.c \
14ee876
 	libsnap-confine-private/utils.h
14ee876
-libsnap_confine_private_a_CFLAGS = $(CHECK_CFLAGS)
14ee876
+libsnap_confine_private_la_CFLAGS = $(CHECK_CFLAGS)
14ee876
 
14ee876
-noinst_LIBRARIES += libsnap-confine-private-debug.a
14ee876
-libsnap_confine_private_debug_a_SOURCES = $(libsnap_confine_private_a_SOURCES)
14ee876
-libsnap_confine_private_debug_a_CFLAGS = $(CHECK_CFLAGS) -DSNAP_CONFINE_DEBUG_BUILD=1
14ee876
+noinst_LTLIBRARIES += libsnap-confine-private-debug.la
14ee876
+libsnap_confine_private_debug_la_SOURCES = $(libsnap_confine_private_la_SOURCES)
14ee876
+libsnap_confine_private_debug_la_CFLAGS = $(CHECK_CFLAGS) -DSNAP_CONFINE_DEBUG_BUILD=1
14ee876
 
14ee876
 if WITH_UNIT_TESTS
14ee876
 noinst_PROGRAMS += libsnap-confine-private/unit-tests
971dc18
@@ -176,7 +176,7 @@ noinst_PROGRAMS += decode-mount-opts/decode-mount-opts
bfc63f7
 
bfc63f7
 decode_mount_opts_decode_mount_opts_SOURCES = \
bfc63f7
 	decode-mount-opts/decode-mount-opts.c
bfc63f7
-decode_mount_opts_decode_mount_opts_LDADD = libsnap-confine-private.a
bfc63f7
+decode_mount_opts_decode_mount_opts_LDADD = libsnap-confine-private.la
9be0073
 decode_mount_opts_decode_mount_opts_STATIC =
9be0073
 
9be0073
 if STATIC_LIBCAP
971dc18
@@ -226,7 +226,7 @@ snap_confine_snap_confine_SOURCES = \
bfc63f7
 
14ee876
 snap_confine_snap_confine_CFLAGS = $(CHECK_CFLAGS) $(AM_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -DNATIVE_LIBDIR=\"$(libdir)\"
bfc63f7
 snap_confine_snap_confine_LDFLAGS = $(AM_LDFLAGS)
bfc63f7
-snap_confine_snap_confine_LDADD = libsnap-confine-private.a
bfc63f7
+snap_confine_snap_confine_LDADD = libsnap-confine-private.la
bfc63f7
 snap_confine_snap_confine_CFLAGS += $(LIBUDEV_CFLAGS)
14ee876
 snap_confine_snap_confine_LDADD += $(snap_confine_snap_confine_extra_libs)
9be0073
 # _STATIC is where we collect statically linked in libraries
971dc18
@@ -284,7 +284,7 @@ noinst_PROGRAMS += snap-confine/snap-confine-debug
14ee876
 snap_confine_snap_confine_debug_SOURCES = $(snap_confine_snap_confine_SOURCES)
14ee876
 snap_confine_snap_confine_debug_CFLAGS = $(snap_confine_snap_confine_CFLAGS)
14ee876
 snap_confine_snap_confine_debug_LDFLAGS = $(snap_confine_snap_confine_LDFLAGS)
14ee876
-snap_confine_snap_confine_debug_LDADD = libsnap-confine-private-debug.a $(snap_confine_snap_confine_extra_libs)
14ee876
+snap_confine_snap_confine_debug_LDADD = libsnap-confine-private-debug.la $(snap_confine_snap_confine_extra_libs)
14ee876
 snap_confine_snap_confine_debug_CFLAGS += -DSNAP_CONFINE_DEBUG_BUILD=1
14ee876
 snap_confine_snap_confine_debug_STATIC = $(snap_confine_snap_confine_STATIC)
14ee876
 
971dc18
@@ -406,7 +406,7 @@ snap_discard_ns_snap_discard_ns_SOURCES = \
bfc63f7
 	snap-discard-ns/snap-discard-ns.c
47a18f3
 snap_discard_ns_snap_discard_ns_CFLAGS = $(CHECK_CFLAGS) $(AM_CFLAGS)
bfc63f7
 snap_discard_ns_snap_discard_ns_LDFLAGS = $(AM_LDFLAGS)
bfc63f7
-snap_discard_ns_snap_discard_ns_LDADD = libsnap-confine-private.a
bfc63f7
+snap_discard_ns_snap_discard_ns_LDADD = libsnap-confine-private.la
9be0073
 snap_discard_ns_snap_discard_ns_STATIC =
bfc63f7
 
971dc18
 # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
971dc18
@@ -426,7 +426,7 @@ system_shutdown_system_shutdown_SOURCES = \
bfc63f7
 	system-shutdown/system-shutdown-utils.c \
bfc63f7
 	system-shutdown/system-shutdown-utils.h \
bfc63f7
 	system-shutdown/system-shutdown.c
bfc63f7
-system_shutdown_system_shutdown_LDADD = libsnap-confine-private.a
bfc63f7
+system_shutdown_system_shutdown_LDADD = libsnap-confine-private.la
47a18f3
 system_shutdown_system_shutdown_CFLAGS = $(CHECK_CFLAGS) $(filter-out -fPIE -pie,$(CFLAGS)) -static
bfc63f7
 system_shutdown_system_shutdown_LDFLAGS = $(filter-out -fPIE -pie,$(LDFLAGS)) -static
bfc63f7
 
971dc18
@@ -436,7 +436,7 @@ system_shutdown_unit_tests_SOURCES = \
bfc63f7
 	libsnap-confine-private/unit-tests-main.c \
bfc63f7
 	libsnap-confine-private/unit-tests.c \
bfc63f7
 	system-shutdown/system-shutdown-utils-test.c
9be0073
-system_shutdown_unit_tests_LDADD = libsnap-confine-private.a
9be0073
+system_shutdown_unit_tests_LDADD = libsnap-confine-private.la
9be0073
 system_shutdown_unit_tests_CFLAGS = $(GLIB_CFLAGS)
9be0073
 system_shutdown_unit_tests_LDADD +=  $(GLIB_LIBS)
bfc63f7
 endif
971dc18
@@ -450,7 +450,7 @@ libexec_PROGRAMS += snap-gdb-shim/snap-gdb-shim
215934a
 snap_gdb_shim_snap_gdb_shim_SOURCES = \
215934a
 	snap-gdb-shim/snap-gdb-shim.c
215934a
 
215934a
-snap_gdb_shim_snap_gdb_shim_LDADD = libsnap-confine-private.a
215934a
+snap_gdb_shim_snap_gdb_shim_LDADD = libsnap-confine-private.la
215934a
 
215934a
 ##
215934a
 ## snapd-generator
971dc18
@@ -460,7 +460,7 @@ systemdsystemgeneratordir = $(SYSTEMD_SYSTEM_GENERATOR_DIR)
e2755c3
 systemdsystemgenerator_PROGRAMS = snapd-generator/snapd-generator
215934a
 
215934a
 snapd_generator_snapd_generator_SOURCES = snapd-generator/main.c
215934a
-snapd_generator_snapd_generator_LDADD = libsnap-confine-private.a
215934a
+snapd_generator_snapd_generator_LDADD = libsnap-confine-private.la
db7fe73
 
db7fe73
 ##
e2755c3
 ## snapd-env-generator
971dc18
@@ -470,7 +470,7 @@ systemdsystemenvgeneratordir=$(SYSTEMD_SYSTEM_ENV_GENERATOR_DIR)
e2755c3
 systemdsystemenvgenerator_PROGRAMS = snapd-env-generator/snapd-env-generator
e2755c3
 
e2755c3
 snapd_env_generator_snapd_env_generator_SOURCES = snapd-env-generator/main.c
e2755c3
-snapd_env_generator_snapd_env_generator_LDADD = libsnap-confine-private.a
e2755c3
+snapd_env_generator_snapd_env_generator_LDADD = libsnap-confine-private.la
e2755c3
 EXTRA_DIST += snapd-env-generator/snapd-env-generator.rst
e2755c3
 
e2755c3
 if HAVE_RST2MAN
bfc63f7
diff --git a/cmd/configure.ac b/cmd/configure.ac
e2755c3
index e3aa02655..8531b4233 100644
bfc63f7
--- a/cmd/configure.ac
bfc63f7
+++ b/cmd/configure.ac
bfc63f7
@@ -11,7 +11,8 @@ AC_PROG_CC_C99
bfc63f7
 AC_PROG_CPP
bfc63f7
 AC_PROG_INSTALL
bfc63f7
 AC_PROG_MAKE_SET
bfc63f7
-AC_PROG_RANLIB
bfc63f7
+AC_PROG_LIBTOOL
bfc63f7
+AC_CONFIG_MACRO_DIR([m4])
bfc63f7
 
bfc63f7
 AC_LANG([C])
bfc63f7
 # Checks for libraries.
4410c7f
-- 
971dc18
2.20.1
4410c7f