Use python-config to find python include directories
PATCH 1/1 Use python-config to find python include directories
In Ubuntu's current development release, the Python header files have been split up for multiarch reasons. /usr/include/python2.7/Python.h includes pyconfig.h, which is in /usr/include/x86_64-linux-gnu/python2.7/. This causes a build failure beacuse the architecture specific include directory is not searched by the audit build system.
This patch uses the python-config tool, normally provided by the Python development package, to determine include directories and improves the readability of the Python section of configure.ac by adding appropriate indentation.
--- bindings/python/Makefile.am | 2 +- configure.ac | 27 ++++++++++++++++----------- swig/Makefile.am | 3 +-- 3 files changed, 18 insertions(+), 14 deletions(-)
bindings/python/Makefile.am +1 -1
@@ -26,6 +26,6 @@ CONFIG_CLEAN_FILES = *.loT *.rej *.orig pyexec_LTLIBRARIES = auparse.la auparse_la_SOURCES = auparse_python.c -auparse_la_CPPFLAGS = -I$(top_srcdir)/auparse $(AM_CPPFLAGS) -I/usr/include/python$(PYTHON_VERSION) -fno-strict-aliasing +auparse_la_CPPFLAGS = -I$(top_srcdir)/auparse $(AM_CPPFLAGS) $(PYTHON_INCLUDES) -fno-strict-aliasing auparse_la_LDFLAGS = -module -avoid-version -Wl,-z,relro auparse_la_LIBADD = ../../auparse/libauparse.la ../../lib/libaudit.la
configure.ac +16 -11
@@ -88,20 +88,24 @@ if test x$use_python = xno ; then python_found="no" AC_MSG_RESULT(no) else -AC_MSG_RESULT(testing) -AM_PATH_PYTHON -if test -f /usr/include/python${am_cv_python_version}/Python.h ; then - python_found="yes" - AC_MSG_NOTICE(Python bindings will be built) -else - python_found="no" - if test x$use_python = xyes ; then - AC_MSG_ERROR([Python explicitly required and python headers found]) + AC_MSG_RESULT(testing) + AM_PATH_PYTHON + AC_PATH_PROG([PYTHON_CONFIG], [python$PYTHON_VERSION-config python-config], no) + if test x$PYTHON_CONFIG = xno ; then + python_found="no" + if test x$use_python = xyes ; then + AC_MSG_ERROR([Python explicitly required and python-config not found]) + else + AC_MSG_WARN("python-config not found - python bindings will not be made") + fi else - AC_MSG_WARN("Python headers not found - python bindings will not be made") + python_found="yes" + AC_MSG_NOTICE(Python bindings will be built) + AC_MSG_CHECKING(Python header include directories) + PYTHON_INCLUDES=`$PYTHON_CONFIG --includes` + AC_MSG_RESULT([$PYTHON_INCLUDES]) fi fi -fi AM_CONDITIONAL(HAVE_PYTHON, test ${python_found} = "yes") #auditd listener
@@ -274,6 +278,7 @@ fi # See if we want to support lower capabilities for plugins LIBCAP_NG_PATH +AC_SUBST(PYTHON_INCLUDES) AC_SUBST(DEBUG) AC_SUBST(LIBWRAP_LIBS) #AC_SUBST(libev_LIBS)
swig/Makefile.am +1 -2
@@ -22,8 +22,7 @@ EXTRA_DIST = auditswig.i CONFIG_CLEAN_FILES = *.loT *.rej *.orig AM_CFLAGS = -fPIC -DPIC -fno-strict-aliasing -PYLIBVER ?= python$(PYTHON_VERSION) -INCLUDES = -I. -I$(top_builddir) -I${top_srcdir}/lib -I/usr/include/$(PYLIBVER) +INCLUDES = -I. -I$(top_builddir) -I${top_srcdir}/lib $(PYTHON_INCLUDES) LIBS = $(top_builddir)/lib/libaudit.la pyexec_PYTHON = audit.py pyexec_LTLIBRARIES = _audit.la
Signature · 1 line
1.7.10.4
Quoted 4 lines · Tyler Hicks
In Ubuntu's current development release, the Python header files have been split up for multiarch reasons.
/usr/include/python2.7/Python.hincludespyconfig.h, which is in/usr/include/x86_64-linux-gnu/python2.7/.
I'm not sure if this sort of a layout is going to become common or not (I would assume not). But either way, using python-config in the configure step seems to be the right thing to do.
Tyler