[lxc-devel] summary of the latest discussions and pending patchset
Ciprian Dorin, Craciun
ciprian.craciun at gmail.com
Tue Mar 2 15:39:20 UTC 2010
On Sun, Jan 10, 2010 at 11:36 PM, Daniel Lezcano <daniel.lezcano at free.fr> wrote:
> Hi all,
>
> A little summary of what was talked about and what is pending:
>
> [... snip ...]
>
> * Statically link the executable
>
> Ciprian Dorin sent a patchset in order to generate a static library and
> link against it.
> That was a wish of Michael T Johnson of Foresight Linux.
> I will take the patchset.
>
> [... snip ...]
Hy Daniel!
A few months ago I've sent a patch that allows the user to
configure and build a static version of all our binaries. We've
exchanged a few emails about the subject (the date was after the quote
above). But then the subject was dropped.
Could I reiterate the proposal? Is there something wrong with my
approach? Should I do it in some other (better) way?
If interested my repository is at the following URL (the diff with
the current master is at the end of the email):
git://gitorious.org/~ciprian.craciun/lxc/ciprian-craciun-patches.git
Thanks,
Ciprian.
P.S.: I've also created a "mainline" mirror of LXC repository on Gitorious:
http://gitorious.org/lxc/mainline
If someone wants ownership to this repository please tell me.
(I've created it because there will be users (like myself) that would
like to "fork" it from there, and thus we could see which are
potential developers to LXC.)
My `static-build` diff to current master:
~~~~~~~~~~~~~~~~
diff --git a/configure.ac b/configure.ac
index f82e7df..aac7ce6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,6 +31,29 @@ AC_ARG_ENABLE([examples],
AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
+AC_ARG_ENABLE([static],
+ [AC_HELP_STRING([--enable-static], [build liblxc.a static library
(default is no)])],
+ [static_libraries=$enableval], [static_libraries=no])
+
+AM_CONDITIONAL([STATIC_LIBRARIES], [test "x$static_libraries" = "xyes"])
+
+AC_ARG_ENABLE([static-linking],
+ [AC_HELP_STRING([--enable-static-linking], [link all binaries
statically (default is taken from static)])],
+ [static_linking=$enableval], [static_linking=$static_libraries])
+
+AC_ARG_ENABLE([static-linking],
+ [AC_HELP_STRING([--enable-static-linking], [link all binaries
statically (default is taken from static)])],
+ [static_linking=$enableval], [static_linking=$static_libraries])
+
+AM_CONDITIONAL([STATIC_LINKING], [test "x$static_linking" = "xyes"])
+
+AC_ARG_ENABLE([shared],
+ [AC_HELP_STRING([--enable-shared], [build liblxc.so shared library
(default is negated from static)])],
+ [shared_libraries=$enableval],
+ [shared_libraries=$( if test "x$static_linking" = "xyes" ; then echo
no ; else echo yes ; fi )])
+
+AM_CONDITIONAL([SHARED_LIBRARIES], [test "x$shared_libraries" = "xyes"])
+
AS_AC_EXPAND(PREFIX, $prefix)
AS_AC_EXPAND(LIBDIR, $libdir)
AS_AC_EXPAND(BINDIR, $bindir)
@@ -57,8 +80,7 @@ AC_DEFINE_UNQUOTED(LXCLIBEXECDIR, "$LIBEXECDIR")
AC_CHECK_HEADERS([linux/netlink.h linux/genetlink.h],
[],
AC_MSG_ERROR([netlink headers not found. Please
install the linux kernel headers.]),
- [#include <sys/socket.h>
- ])
+ [#include <sys/socket.h>])
AC_CHECK_HEADERS([sys/capability.h], [], AC_MSG_ERROR([please install
libcap-devel.]),
[#include <sys/types.h>
@@ -70,18 +92,19 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [],
[#include <sys/prctl.h>])
AC_CHECK_HEADERS([sys/signalfd.h])
AC_PROG_GCC_TRADITIONAL
+AC_PROG_RANLIB
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -Wall"
fi
AC_CONFIG_FILES([
- Makefile
+ Makefile
lxc.pc
lxc.spec
- config/Makefile
+ config/Makefile
- doc/Makefile
+ doc/Makefile
doc/lxc-create.sgml
doc/lxc-destroy.sgml
doc/lxc-execute.sgml
@@ -115,7 +138,7 @@ AC_CONFIG_FILES([
scripts/lxc-fedora
scripts/lxc-sshd
- src/Makefile
+ src/Makefile
src/lxc/Makefile
src/lxc/lxc-ps
src/lxc/lxc-ls
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index f516841..eb47f99 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -12,11 +12,17 @@ pkginclude_HEADERS = \
log.h \
state.h
+if SHARED_LIBRARIES
sodir=$(libdir)
# use PROGRAMS to avoid complains from automake
so_PROGRAMS = liblxc.so
+endif
-liblxc_so_SOURCES = \
+if STATIC_LIBRARIES
+lib_LIBRARIES = liblxc.a
+endif
+
+liblxc_SOURCES = \
arguments.c arguments.h \
commands.c commands.h \
start.c \
@@ -39,22 +45,28 @@ liblxc_so_SOURCES = \
log.c log.h \
\
network.c network.h \
- nl.c nl.h \
- rtnl.c rtnl.h \
- genl.c genl.h \
+ nl.c nl.h \
+ rtnl.c rtnl.h \
+ genl.c genl.h \
\
mainloop.c mainloop.h \
af_unix.c af_unix.h
AM_CFLAGS=-I$(top_srcdir)/src
+liblxc_so_SOURCES = $(liblxc_SOURCES)
+
liblxc_so_CFLAGS = -fPIC -DPIC $(AM_CFLAGS)
liblxc_so_LDFLAGS = \
-shared \
-Wl,-soname,liblxc.so.$(firstword $(subst ., ,$(VERSION)))
-liblxc_so_LDADD = -lutil
+liblxc_so_LDADD =
+
+liblxc_a_SOURCES = $(liblxc_SOURCES)
+
+liblxc_a_CFLAGS = -fPIC -DPIC $(AM_CFLAGS)
bin_SCRIPTS = \
lxc-ps \
@@ -84,8 +96,13 @@ bin_PROGRAMS = \
libexec_PROGRAMS = \
lxc-init
+if STATIC_LINKING
+AM_LDFLAGS=-static
+LDADD=liblxc.a -lutil
+else
AM_LDFLAGS=-Wl,-E -Wl,-rpath -Wl,$(libdir)
-LDADD=liblxc.so
+LDADD=liblxc.so -lutil
+endif
lxc_cgroup_SOURCES = lxc_cgroup.c
lxc_checkpoint_SOURCES = lxc_checkpoint.c
@@ -102,11 +119,15 @@ lxc_unfreeze_SOURCES = lxc_unfreeze.c
lxc_unshare_SOURCES = lxc_unshare.c
lxc_wait_SOURCES = lxc_wait.c
+if SHARED_LIBRARIES
install-exec-local: install-soPROGRAMS
mv $(DESTDIR)$(libdir)/liblxc.so $(DESTDIR)$(libdir)/liblxc.so.$(VERSION)
/sbin/ldconfig -l $(DESTDIR)$(libdir)/liblxc.so.$(VERSION)
cd $(DESTDIR)$(libdir); \
ln -sf liblxc.so.$(firstword $(subst ., ,$(VERSION))) liblxc.so
+endif
+if SHARED_LIBRARIES
uninstall-local:
$(RM) $(DESTDIR)$(libdir)/liblxc.so*
+endif
More information about the lxc-devel
mailing list