build: Fix support for split build and source dirs

Building LXC in a separate target directory, by running configure from
outside the source tree, failed with multiple errors, mostly in the
Python and Lua extensions, due to assuming the source dir and build dir
are the same in a few places. To fix that:

- Pre-process setup.py with the appropriate directories at configure
  time
- Introduce the build dir as an include path in the Lua Makefile
- Link the default container configuration file from the alternatives
  in the configure stage, instead of setting a variable and using it
  in the Makefile

Signed-off-by: Daniel Miranda <danielkza2@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Daniel Miranda 2014-08-21 07:56:39 -03:00 committed by Stéphane Graber
parent d5752559f8
commit d79067a726
5 changed files with 12 additions and 12 deletions

View File

@ -1,12 +1,8 @@
configdir = $(sysconfdir)/lxc configdir = $(sysconfdir)/lxc
config_DATA = default.conf config_DATA = default.conf
distroconf = @LXC_DISTRO_CONF@
EXTRA_DIST = default.conf.ubuntu default.conf.libvirt default.conf.unknown EXTRA_DIST = default.conf.ubuntu default.conf.libvirt default.conf.unknown
default.conf:
cp $(distroconf) $@
clean-local: clean-local:
@$(RM) -f default.conf @$(RM) -f default.conf

View File

@ -73,6 +73,8 @@ AC_MSG_RESULT([$with_distro])
AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu" -o x"$with_distro" = "xraspbian"]) AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu" -o x"$with_distro" = "xraspbian"])
AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"]) AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
AC_CONFIG_LINKS([config/etc/default.conf:config/etc/${distroconf}])
# Check for init system type # Check for init system type
AC_MSG_CHECKING([for init system type]) AC_MSG_CHECKING([for init system type])
AC_ARG_WITH([init-script], AC_ARG_WITH([init-script],
@ -523,7 +525,6 @@ AS_AC_EXPAND(LXC_DEFAULT_CONFIG, "$sysconfdir/lxc/default.conf")
AS_AC_EXPAND(DATADIR, "$datadir") AS_AC_EXPAND(DATADIR, "$datadir")
AS_AC_EXPAND(LOCALSTATEDIR, "$localstatedir") AS_AC_EXPAND(LOCALSTATEDIR, "$localstatedir")
AS_AC_EXPAND(DOCDIR, "$docdir") AS_AC_EXPAND(DOCDIR, "$docdir")
AS_AC_EXPAND(LXC_DISTRO_CONF, "$distroconf")
AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date)") AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date)")
AS_AC_EXPAND(LXCPATH, "$with_config_path") AS_AC_EXPAND(LXCPATH, "$with_config_path")
AS_AC_EXPAND(LXC_GLOBAL_CONF, "$with_global_conf") AS_AC_EXPAND(LXC_GLOBAL_CONF, "$with_global_conf")
@ -759,6 +760,7 @@ AC_CONFIG_FILES([
src/lxc/lxc.functions src/lxc/lxc.functions
src/lxc/version.h src/lxc/version.h
src/python-lxc/Makefile src/python-lxc/Makefile
src/python-lxc/setup.py
src/lua-lxc/Makefile src/lua-lxc/Makefile

View File

@ -11,13 +11,13 @@ so_PROGRAMS = core.so
core_so_SOURCES = core.c core_so_SOURCES = core.c
AM_CFLAGS=-I$(top_srcdir)/src $(LUA_CFLAGS) -DVERSION=\"$(VERSION)\" -DLXCPATH=\"$(LXCPATH)\" AM_CFLAGS=-I$(top_builddir)/src -I$(top_srcdir)/src $(LUA_CFLAGS) -DVERSION=\"$(VERSION)\" -DLXCPATH=\"$(LXCPATH)\"
core_so_CFLAGS = -fPIC -DPIC $(AM_CFLAGS) core_so_CFLAGS = -fPIC -DPIC $(AM_CFLAGS)
core_so_LDFLAGS = \ core_so_LDFLAGS = \
-shared \ -shared \
-L$(top_srcdir)/src/lxc \ -L$(top_builddir)/src/lxc \
-Wl,-soname,core.so.$(firstword $(subst ., ,$(VERSION))) -Wl,-soname,core.so.$(firstword $(subst ., ,$(VERSION)))
core_so_LDADD = -llxc core_so_LDADD = -llxc

View File

@ -7,7 +7,7 @@ else
endif endif
all: all:
CFLAGS="$(CFLAGS) -I ../../src -L../../src/lxc/" $(PYTHON) setup.py build $(PYTHON) setup.py build
install: install:
if [ "$(DESTDIR)" = "" ]; then \ if [ "$(DESTDIR)" = "" ]; then \
@ -21,7 +21,6 @@ clean-local:
endif endif
EXTRA_DIST = \ EXTRA_DIST = \
setup.py \
lxc.c \ lxc.c \
lxc/__init__.py \ lxc/__init__.py \
examples/api_test.py \ examples/api_test.py \

View File

@ -19,15 +19,18 @@
# #
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
from distutils.core import setup, Extension from distutils.core import setup, Extension
module = Extension('_lxc', sources=['lxc.c'], libraries=['lxc']) module = Extension('_lxc', sources=['@srcdir@/lxc.c'],
include_dirs=['@top_builddir@/src', '@top_srcdir@/src'],
library_dirs=['@top_builddir@/src/lxc'], libraries=['lxc'])
setup(name='_lxc', setup(name='_lxc',
version='0.1', version='0.1',
description='LXC', description='LXC',
packages=['lxc'], packages=['lxc'],
package_dir={'lxc': 'lxc'}, package_dir={'lxc': '@srcdir@/lxc'},
ext_modules=[module]) ext_modules=[module])