[lxc-devel] [PATCH] build: Fix support for split build and source dirs

Daniel Miranda danielkza2 at gmail.com
Sun Aug 24 03:17:32 UTC 2014


I noticed a small mistake, which unfortunately breaks the build after
calling make clean: config/etc/Makefile.am should not remove default.conf.
I'll send a patch fixing it in a minute.


On Fri, Aug 22, 2014 at 4:02 PM, Stéphane Graber <stgraber at ubuntu.com>
wrote:

> On Thu, Aug 21, 2014 at 07:56:39AM -0300, Daniel Miranda wrote:
> > 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 at gmail.com>
>
> Acked-by: Stéphane Graber <stgraber at ubuntu.com>
>
> > ---
> >  config/etc/Makefile.am     |  4 ----
> >  configure.ac               |  4 +++-
> >  src/lua-lxc/Makefile.am    |  4 ++--
> >  src/python-lxc/Makefile.am |  3 +--
> >  src/python-lxc/setup.py    | 33 ---------------------------------
> >  src/python-lxc/setup.py.in | 35 +++++++++++++++++++++++++++++++++++
> >  6 files changed, 41 insertions(+), 42 deletions(-)
> >  delete mode 100644 src/python-lxc/setup.py
> >  create mode 100644 src/python-lxc/setup.py.in
> >
> > diff --git a/config/etc/Makefile.am b/config/etc/Makefile.am
> > index 81d7709..03193da 100644
> > --- a/config/etc/Makefile.am
> > +++ b/config/etc/Makefile.am
> > @@ -1,12 +1,8 @@
> >  configdir = $(sysconfdir)/lxc
> >  config_DATA = default.conf
> > -distroconf = @LXC_DISTRO_CONF@
> >
> >  EXTRA_DIST = default.conf.ubuntu default.conf.libvirt
> default.conf.unknown
> >
> > -default.conf:
> > -     cp $(distroconf) $@
> > -
> >  clean-local:
> >       @$(RM) -f default.conf
> >
> > diff --git a/configure.ac b/configure.ac
> > index 462217e..152ef5a 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -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([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
> >
> > +AC_CONFIG_LINKS([config/etc/default.conf:config/etc/${distroconf}])
> > +
> >  # Check for init system type
> >  AC_MSG_CHECKING([for init system type])
> >  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(LOCALSTATEDIR, "$localstatedir")
> >  AS_AC_EXPAND(DOCDIR, "$docdir")
> > -AS_AC_EXPAND(LXC_DISTRO_CONF, "$distroconf")
> >  AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date)")
> >  AS_AC_EXPAND(LXCPATH, "$with_config_path")
> >  AS_AC_EXPAND(LXC_GLOBAL_CONF, "$with_global_conf")
> > @@ -759,6 +760,7 @@ AC_CONFIG_FILES([
> >       src/lxc/lxc.functions
> >       src/lxc/version.h
> >       src/python-lxc/Makefile
> > +     src/python-lxc/setup.py
> >
> >       src/lua-lxc/Makefile
> >
> > diff --git a/src/lua-lxc/Makefile.am b/src/lua-lxc/Makefile.am
> > index 6201adc..9b73df1 100644
> > --- a/src/lua-lxc/Makefile.am
> > +++ b/src/lua-lxc/Makefile.am
> > @@ -11,13 +11,13 @@ so_PROGRAMS = core.so
> >
> >  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_LDFLAGS = \
> >       -shared \
> > -     -L$(top_srcdir)/src/lxc \
> > +     -L$(top_builddir)/src/lxc \
> >       -Wl,-soname,core.so.$(firstword $(subst ., ,$(VERSION)))
> >
> >  core_so_LDADD = -llxc
> > diff --git a/src/python-lxc/Makefile.am b/src/python-lxc/Makefile.am
> > index b1c10b5..4a014df 100644
> > --- a/src/python-lxc/Makefile.am
> > +++ b/src/python-lxc/Makefile.am
> > @@ -7,7 +7,7 @@ else
> >  endif
> >
> >  all:
> > -     CFLAGS="$(CFLAGS) -I ../../src -L../../src/lxc/" $(PYTHON)
> setup.py build
> > +     $(PYTHON) setup.py build
> >
> >  install:
> >       if [ "$(DESTDIR)" = "" ]; then \
> > @@ -21,7 +21,6 @@ clean-local:
> >
> >  endif
> >  EXTRA_DIST = \
> > -     setup.py \
> >       lxc.c \
> >       lxc/__init__.py \
> >       examples/api_test.py \
> > diff --git a/src/python-lxc/setup.py b/src/python-lxc/setup.py
> > deleted file mode 100644
> > index a1061f1..0000000
> > --- a/src/python-lxc/setup.py
> > +++ /dev/null
> > @@ -1,33 +0,0 @@
> > -#!/usr/bin/python3
> > -#
> > -# python-lxc: Python bindings for LXC
> > -#
> > -# (C) Copyright Canonical Ltd. 2012
> > -#
> > -# Authors:
> > -# Stéphane Graber <stgraber at ubuntu.com>
> > -#
> > -# This library is free software; you can redistribute it and/or
> > -# modify it under the terms of the GNU Lesser General Public
> > -# License as published by the Free Software Foundation; either
> > -# version 2.1 of the License, or (at your option) any later version.
> > -#
> > -# This library is distributed in the hope that it will be useful,
> > -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > -# Lesser General Public License for more details.
> > -#
> > -# You should have received a copy of the GNU Lesser General Public
> > -# License along with this library; if not, write to the Free Software
> > -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301  USA
> > -
> > -from distutils.core import setup, Extension
> > -
> > -module = Extension('_lxc', sources=['lxc.c'], libraries=['lxc'])
> > -
> > -setup(name='_lxc',
> > -      version='0.1',
> > -      description='LXC',
> > -      packages=['lxc'],
> > -      package_dir={'lxc': 'lxc'},
> > -      ext_modules=[module])
> > diff --git a/src/python-lxc/setup.py.in b/src/python-lxc/setup.py.in
> > new file mode 100644
> > index 0000000..4304f75
> > --- /dev/null
> > +++ b/src/python-lxc/setup.py.in
> > @@ -0,0 +1,35 @@
> > +#!/usr/bin/python3
> > +#
> > +# python-lxc: Python bindings for LXC
> > +#
> > +# (C) Copyright Canonical Ltd. 2012
> > +#
> > +# Authors:
> > +# Stéphane Graber <stgraber at ubuntu.com>
> > +#
> > +# This library is free software; you can redistribute it and/or
> > +# modify it under the terms of the GNU Lesser General Public
> > +# License as published by the Free Software Foundation; either
> > +# version 2.1 of the License, or (at your option) any later version.
> > +#
> > +# This library is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +# Lesser General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU Lesser General Public
> > +# License along with this library; if not, write to the Free Software
> > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301  USA
> > +
> > +from distutils.core import setup, Extension
> > +
> > +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',
> > +      version='0.1',
> > +      description='LXC',
> > +      packages=['lxc'],
> > +      package_dir={'lxc': '@srcdir@/lxc'},
> > +      ext_modules=[module])
> > --
> > 1.9.3
> >
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
>
> --
> Stéphane Graber
> Ubuntu developer
> http://www.ubuntu.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140824/d7c43397/attachment.html>


More information about the lxc-devel mailing list