From: Bartosz Golaszewski Date: Fri, 20 Apr 2018 09:54:51 +0000 (+0200) Subject: build: fix cross-compilation of python bindings X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=696de1b973647a871a22e2b8d4eeb0649c64de59;p=qemu-gpiodev%2Flibgpiod.git build: fix cross-compilation of python bindings AX_PYTHON_DEVEL macro from the autoconf-archive collection doesn't work when we're trying to cross-compile python bindings in environments such as buildroot or yocto. It can't properly detect the location of python headers. Let's use AM_PATH_PYTHON to detect the python3 interpreter and then either take the PYTHON_CPPFLAGS and PYTHON_LIBS variables from the environment (so that cross-compiling build systems can pass their custom locations to autotools) or try to detect them ourselves using the python3-config tool. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am index e14191b..506b733 100644 --- a/bindings/python/Makefile.am +++ b/bindings/python/Makefile.am @@ -12,7 +12,7 @@ pyexec_LTLIBRARIES = gpiod.la gpiod_la_SOURCES = gpiodmodule.c -gpiod_la_CFLAGS = -I$(top_srcdir)/include/ -include $(top_builddir)/config.h -gpiod_la_CFLAGS += $(PYTHON_CPPFLAGS) -Wall -Wextra -g +gpiod_la_CFLAGS = -I$(top_srcdir)/include/ +gpiod_la_CFLAGS += -Wall -Wextra -g $(PYTHON_CPPFLAGS) gpiod_la_LDFLAGS = -module -avoid-version -gpiod_la_LIBADD = $(top_builddir)/src/lib/libgpiod.la +gpiod_la_LIBADD = $(top_builddir)/src/lib/libgpiod.la $(PYTHON_LIBS) diff --git a/configure.ac b/configure.ac index bc4b703..487778f 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,11 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_pattern_forbid([^AX_], [Unexpanded AX_ macro found. Please install GNU autoconf-archive.]) +AC_ARG_VAR([PYTHON_CPPFLAGS], + [Compiler flags to find Python headers [default: auto-detect]]) +AC_ARG_VAR([PYTHON_LIBS], + [Libraries to link into Python extensions [default: auto-detect]]) + AC_CONFIG_SRCDIR([src]) AC_CONFIG_HEADER([config.h]) @@ -169,13 +174,12 @@ AM_CONDITIONAL([WITH_BINDINGS_PYTHON], [test "x$with_bindings_python" = xtrue]) if test "x$with_bindings_python" = xtrue then - AX_PYTHON_DEVEL([>= '3.0.0']) - AM_PATH_PYTHON([3.0]) - AC_CHECK_PROG([has_python3], [python3], [true], [false]) - if test "X$has_python3" = xfalse - then - AC_MSG_ERROR([python3 not found - needed for python bindings], [1]) - fi + AM_PATH_PYTHON([3.0], [], + [AC_MSG_ERROR([python3 not found - needed for python bindings])]) + AS_IF([test -z "$PYTHON_CPPFLAGS"], + [AC_SUBST(PYTHON_CPPFLAGS, [`$PYTHON-config --includes`])]) + AS_IF([test -z "$PYTHON_LIBS"], + [AC_SUBST(PYTHON_LIBS, [`$PYTHON-config --libs`])]) fi AC_CHECK_PROG([has_doxygen], [doxygen], [true], [false])