[lxc-devel] [lxc/master] autools: build both a shared and static liblxc

brauner on Github lxc-bot at linuxcontainers.org
Fri Jul 6 10:39:02 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 438 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180706/8f9c7b9e/attachment.bin>
-------------- next part --------------
From 30aad7ab44c07e5b3a751c7776ba21a642d7eb27 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 6 Jul 2018 12:36:44 +0200
Subject: [PATCH] autools: build both a shared and static liblxc

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
Cc: Serge Hallyn <serge at hallyn.com>
Cc: Tycho Andersen <tycho at tycho.ws>
---
 src/lxc/Makefile.am | 61 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 20 deletions(-)

diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index da647740b..0c64c205b 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -79,7 +79,7 @@ if ENABLE_SELINUX
 LSM_SOURCES += lsm/selinux.c
 endif
 
-lib_LTLIBRARIES = liblxc.la
+lib_LTLIBRARIES = liblxc.la liblxc_static.la
 liblxc_la_SOURCES = \
 	storage/storage.c storage/storage.h \
 	storage/btrfs.c storage/btrfs.h \
@@ -141,16 +141,20 @@ liblxc_la_SOURCES += \
 	../include/lxcmntent.c ../include/lxcmntent.h
 endif
 
+if !HAVE_GETLINE
+if HAVE_FGETLN
+liblxc_la_SOURCES += ../include/getline.c ../include/getline.h
+endif
+endif
+
 if !HAVE_PRLIMIT
 if HAVE_PRLIMIT64
 liblxc_la_SOURCES += ../include/prlimit.c ../include/prlimit.h
 endif
 endif
 
-if !HAVE_GETLINE
-if HAVE_FGETLN
-liblxc_la_SOURCES += ../include/getline.c ../include/getline.h
-endif
+if ENABLE_SECCOMP
+liblxc_la_SOURCES += seccomp.c
 endif
 
 if !HAVE_STRLCPY
@@ -192,6 +196,10 @@ if ENABLE_GNUTLS
 AM_CFLAGS += -DHAVE_LIBGNUTLS
 endif
 
+if ENABLE_SECCOMP
+AM_CFLAGS += -DHAVE_SECCOMP $(SECCOMP_CFLAGS)
+endif
+
 if ENABLE_SELINUX
 AM_CFLAGS += -DHAVE_SELINUX
 endif
@@ -200,20 +208,34 @@ if USE_CONFIGPATH_LOGS
 AM_CFLAGS += -DUSE_CONFIGPATH_LOGS
 endif
 
-if ENABLE_SECCOMP
-AM_CFLAGS += -DHAVE_SECCOMP $(SECCOMP_CFLAGS)
-liblxc_la_SOURCES += seccomp.c
-endif
+# build the shared library
+liblxc_la_CFLAGS = -fPIC \
+		   -DPIC \
+		   $(AM_CFLAGS) \
+		   -pthread
 
-liblxc_la_CFLAGS = -fPIC -DPIC $(AM_CFLAGS) -pthread
+liblxc_la_LDFLAGS = -pthread \
+		    -shared \
+		    -Wl,-soname,liblxc.so.$(firstword $(subst ., , at LXC_ABI@)) \
+		    -version-info @LXC_ABI_MAJOR@
 
-liblxc_la_LDFLAGS = \
-	-pthread \
-	-shared \
-	-Wl,-soname,liblxc.so.$(firstword $(subst ., , at LXC_ABI@)) \
-	-version-info @LXC_ABI_MAJOR@
+liblxc_la_LIBADD = $(CAP_LIBS) \
+		   $(GNUTLS_LIBS) \
+		   $(SELINUX_LIBS) \
+		   $(SECCOMP_LIBS)
 
-liblxc_la_LIBADD = $(CAP_LIBS) $(GNUTLS_LIBS) $(SELINUX_LIBS) $(SECCOMP_LIBS)
+# build the static library
+liblxc_static_la_SOURCES = $(liblxc_la_SOURCES)
+liblxc_static_la_CFLAGS = $(AM_CFLAGS) \
+			  -pthread
+
+liblxc_static_la_LDFLAGS = -all-static \
+			   -pthread
+
+liblxc_static_la_LIBADD = $(CAP_LIBS) \
+			  $(GNUTLS_LIBS) \
+			  $(SELINUX_LIBS) \
+			  $(SECCOMP_LIBS)
 
 bin_SCRIPTS=
 
@@ -322,10 +344,6 @@ if !HAVE_STRLCAT
 init_lxc_static_SOURCES += ../include/strlcat.c ../include/strlcat.h
 endif
 
-if !HAVE_GETGRGID_R
-liblxc_la_SOURCES += ../include/getgrgid_r.c ../include/getgrgid_r.h
-endif
-
 init_lxc_static_LDFLAGS = -all-static
 init_lxc_static_LDADD = @CAP_LIBS@
 init_lxc_static_CFLAGS = $(AM_CFLAGS) -DNO_LXC_CONF
@@ -350,12 +368,15 @@ install-exec-local: install-libLTLIBRARIES
 	cd $(DESTDIR)$(libdir); \
 	ln -sf liblxc.so. at LXC_ABI@ liblxc.so.$(firstword $(subst ., , at LXC_ABI@)); \
 	ln -sf liblxc.so.$(firstword $(subst ., , at LXC_ABI@)) liblxc.so
+	rm -f $(DESTDIR)$(libdir)/liblxc_static.a
+	mv $(shell readlink -f $(DESTDIR)$(libdir)/liblxc_static.a) $(DESTDIR)$(libdir)/liblxc_static.a
 
 install-exec-hook:
 	chmod u+s $(DESTDIR)$(libexecdir)/lxc/lxc-user-nic
 
 uninstall-local:
 	$(RM) $(DESTDIR)$(libdir)/liblxc.so*
+	$(RM) $(DESTDIR)$(libdir)/liblxc_static.a
 if ENABLE_PAM
 if HAVE_PAM
 	$(RM) $(DESTDIR)$(pamdir)/pam_cgfs.so*


More information about the lxc-devel mailing list