diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2014-03-24 08:27:19 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2014-03-26 22:30:56 -0300 |
commit | 3a33a7a566c221e13c426c0d2f3519ebe8f70a34 (patch) | |
tree | 95c461f52f94f6a694847d20494e3f41b5d2f5bd | |
parent | 5ad36e522226732d3815ace77b2ec19198bd24fc (diff) | |
download | kmod-3a33a7a566c221e13c426c0d2f3519ebe8f70a34.tar.gz kmod-3a33a7a566c221e13c426c0d2f3519ebe8f70a34.tar.bz2 kmod-3a33a7a566c221e13c426c0d2f3519ebe8f70a34.zip |
build-sys: add hooks to build python bindings
Add --enable-python configure switch so we build the python bindings. We
also pass version.py through SED_PROCESS macro, so the version is kept
in sync with kmod.
Acked-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | Makefile.am | 70 | ||||
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | libkmod/python/.gitignore | 1 | ||||
-rw-r--r-- | libkmod/python/kmod/version.py.in (renamed from libkmod/python/kmod/version.py) | 2 |
4 files changed, 89 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index 46b7652..e65fdfb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,8 @@ endif DISTCLEAN_LOCAL_HOOKS = EXTRA_DIST = -CLEANFILES = +CLEANFILES = $(BUILT_FILES) +BUILT_FILES = ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} AM_MAKEFLAGS = --no-print-directory @@ -125,6 +126,70 @@ ${noinst_SCRIPTS}: tools/kmod endif # ------------------------------------------------------------------------------ +# PYTHON BINDINGS +# ------------------------------------------------------------------------------ + +CYTHON_FLAGS_VERBOSE_ = +CYTHON_FLAGS_VERBOSE_0 = +CYTHON_FLAGS_VERBOSE_1 = -v +CYTHON_FLAGS = $(CYTHON_FLAGS_VERBOSE_$(V)) +AM_V_CYTHON = $(am__v_CYTHON_$(V)) +am__v_CYTHON_ = $(am__v_CYTHON_$(AM_DEFAULT_VERBOSITY)) +am__v_CYTHON_0 = @echo " CYTHON " $@; + +.pyx.c: + $(AM_V_CYTHON)$(CYTHON) -o $@ $< + +%.py: %.py.in Makefile + $(SED_PROCESS) + +# Remove some warnings for generated code +PYTHON_NOWARN = -Wno-redundant-decls -Wno-shadow -Wno-strict-aliasing + +CPYTHON_MODULE_CFLAGS = $(AM_CFLAGS) -DCPYTHON_COMPILING_IN_PYPY=0 \ + $(PYTHON_NOWARN) $(PYTHON_CFLAGS) \ + -fvisibility=default +CPYTHON_MODULE_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version -shared + +if BUILD_PYTHON +pkgpyexec_LTLIBRARIES = libkmod/python/kmod/kmod.la \ + libkmod/python/kmod/list.la \ + libkmod/python/kmod/module.la \ + libkmod/python/kmod/_util.la + +libkmod_python_kmod_kmod_la_SOURCES = libkmod/python/kmod/kmod.c +libkmod_python_kmod_kmod_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS) +libkmod_python_kmod_kmod_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS) +libkmod_python_kmod_kmod_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la + +libkmod_python_kmod_list_la_SOURCES = libkmod/python/kmod/list.c +libkmod_python_kmod_list_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS) +libkmod_python_kmod_list_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS) +libkmod_python_kmod_list_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la + +libkmod_python_kmod_module_la_SOURCES = libkmod/python/kmod/module.c +libkmod_python_kmod_module_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS) +libkmod_python_kmod_module_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS) +libkmod_python_kmod_module_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la + +libkmod_python_kmod__util_la_SOURCES = libkmod/python/kmod/_util.c +libkmod_python_kmod__util_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS) +libkmod_python_kmod__util_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS) +libkmod_python_kmod__util_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la + +BUILT_FILES += $(libkmod_python_kmod_kmod_la_SOURCES) \ + $(libkmod_python_kmod_list_la_SOURCES) \ + $(libkmod_python_kmod_module_la_SOURCES) \ + $(libkmod_python_kmod__util_la_SOURCES) + +dist_pkgpyexec_PYTHON = libkmod/python/kmod/error.py \ + libkmod/python/kmod/__init__.py \ + libkmod/python/kmod/version.py + +BUILT_FILES += libkmod/python/kmod/version.py + +endif +# ------------------------------------------------------------------------------ # TESTSUITE # ------------------------------------------------------------------------------ @@ -211,7 +276,8 @@ testsuite-distclean: DISTCLEAN_LOCAL_HOOKS += testsuite-distclean EXTRA_DIST += testsuite/rootfs-pristine -DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib \ +DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --enable-python --sysconfdir=/etc \ + --with-zlib \ --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) distclean-local: $(DISTCLEAN_LOCAL_HOOKS) diff --git a/configure.ac b/configure.ac index f2070c6..b195296 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,24 @@ AS_IF([test "x$enable_debug" = "xyes"], [ AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.]) ]) +AC_ARG_ENABLE([python], + AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]), + [], [enable_python=no]) +AS_IF([test "x$enable_python" = "xyes"], [ + AM_PATH_PYTHON(,,[:]) + AC_PATH_PROG([CYTHON], [cython], [:]) + + PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}], + [have_python=yes], + [PKG_CHECK_MODULES([PYTHON], [python], + [have_python=yes], + [have_python=no])]) + + AS_IF([test "x$have_python" = xno], + [AC_MSG_ERROR([*** python support requested but libraries not found])]) +]) +AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"]) + m4_ifdef([GTK_DOC_CHECK], [ GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat]) ], [ @@ -222,6 +240,7 @@ AC_MSG_RESULT([ ldflags: ${with_ldflags} ${LDFLAGS} tools: ${enable_tools} + python bindings: ${enable_python} logging: ${enable_logging} compression: xz=${with_xz} zlib=${with_zlib} debug: ${enable_debug} diff --git a/libkmod/python/.gitignore b/libkmod/python/.gitignore index 46ec2ea..69af451 100644 --- a/libkmod/python/.gitignore +++ b/libkmod/python/.gitignore @@ -3,3 +3,4 @@ dist *.c *.pyc *.so +kmod/version.py diff --git a/libkmod/python/kmod/version.py b/libkmod/python/kmod/version.py.in index 1ef04eb..4daa94d 100644 --- a/libkmod/python/kmod/version.py +++ b/libkmod/python/kmod/version.py.in @@ -14,4 +14,4 @@ # You should have received a copy of the GNU Lesser General Public License # along with python-kmod. If not, see <http://www.gnu.org/licenses/>. -__version__ = '0.9.1' +__version__ = '@VERSION@' |