Blob Blame Raw
From 687b6de661e00db74e562ab575bfd1319f750816 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <me@zygoon.pl>
Date: Mon, 6 Mar 2017 20:26:26 +0100
Subject: [PATCH] cmd: use libtool for the internal library

This just cuts some hassle integration with how the helper library is
built. I could never get to pass the right -fPIC/-fpie combination
otherwise.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
---
 cmd/Makefile.am  | 16 ++++++++--------
 cmd/configure.ac |  3 ++-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 695b07e..767bf35 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -58,12 +58,12 @@ hack: snap-confine/snap-confine snap-confine/snap-confine.apparmor
 	sudo apparmor_parser -r snap-confine/snap-confine.apparmor
 
 ##
-## libsnap-confine-private.a
+## libsnap-confine-private.la
 ##
 
-noinst_LIBRARIES += libsnap-confine-private.a
+noinst_LTLIBRARIES = libsnap-confine-private.la
 
-libsnap_confine_private_a_SOURCES = \
+libsnap_confine_private_la_SOURCES = \
 	libsnap-confine-private/classic.c \
 	libsnap-confine-private/classic.h \
 	libsnap-confine-private/cleanup-funcs.c \
@@ -131,7 +131,7 @@ noinst_PROGRAMS += decode-mount-opts/decode-mount-opts
 
 decode_mount_opts_decode_mount_opts_SOURCES = \
 	decode-mount-opts/decode-mount-opts.c
-decode_mount_opts_decode_mount_opts_LDADD = libsnap-confine-private.a
+decode_mount_opts_decode_mount_opts_LDADD = libsnap-confine-private.la
 decode_mount_opts_decode_mount_opts_STATIC =
 
 if STATIC_LIBCAP
@@ -214,7 +214,7 @@ snap_confine_snap_confine_SOURCES = \
 
 snap_confine_snap_confine_CFLAGS = -Wall -Werror $(AM_CFLAGS)
 snap_confine_snap_confine_LDFLAGS = $(AM_LDFLAGS)
-snap_confine_snap_confine_LDADD = libsnap-confine-private.a
+snap_confine_snap_confine_LDADD = libsnap-confine-private.la
 snap_confine_snap_confine_CFLAGS += $(LIBUDEV_CFLAGS)
 snap_confine_snap_confine_LDADD += $(LIBUDEV_LIBS)
 # _STATIC is where we collect statically linked in libraries
@@ -379,7 +379,7 @@ snap_discard_ns_snap_discard_ns_SOURCES = \
 	snap-discard-ns/snap-discard-ns.c
 snap_discard_ns_snap_discard_ns_CFLAGS = -Wall -Werror $(AM_CFLAGS)
 snap_discard_ns_snap_discard_ns_LDFLAGS = $(AM_LDFLAGS)
-snap_discard_ns_snap_discard_ns_LDADD = libsnap-confine-private.a
+snap_discard_ns_snap_discard_ns_LDADD = libsnap-confine-private.la
 snap_discard_ns_snap_discard_ns_STATIC =
 
 if APPARMOR
@@ -418,7 +418,7 @@ system_shutdown_system_shutdown_SOURCES = \
 	system-shutdown/system-shutdown-utils.c \
 	system-shutdown/system-shutdown-utils.h \
 	system-shutdown/system-shutdown.c
-system_shutdown_system_shutdown_LDADD = libsnap-confine-private.a
+system_shutdown_system_shutdown_LDADD = libsnap-confine-private.la
 system_shutdown_system_shutdown_CFLAGS = $(filter-out -fPIE -pie,$(CFLAGS)) -static
 system_shutdown_system_shutdown_LDFLAGS = $(filter-out -fPIE -pie,$(LDFLAGS)) -static
 
@@ -428,7 +428,7 @@ system_shutdown_unit_tests_SOURCES = \
 	libsnap-confine-private/unit-tests-main.c \
 	libsnap-confine-private/unit-tests.c \
 	system-shutdown/system-shutdown-utils-test.c
-system_shutdown_unit_tests_LDADD = libsnap-confine-private.a
+system_shutdown_unit_tests_LDADD = libsnap-confine-private.la
 system_shutdown_unit_tests_CFLAGS = $(GLIB_CFLAGS)
 system_shutdown_unit_tests_LDADD +=  $(GLIB_LIBS)
 endif
diff --git a/cmd/configure.ac b/cmd/configure.ac
index 39a6800..2ebf827 100644
--- a/cmd/configure.ac
+++ b/cmd/configure.ac
@@ -11,7 +11,8 @@ AC_PROG_CC_C99
 AC_PROG_CPP
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
-AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AC_CONFIG_MACRO_DIR([m4])
 
 AC_LANG([C])
 # Checks for libraries.