From 71f3b31f2e05dc3ed8201c409c9b9f39eb8bdfe0 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Tue, 1 Mar 2016 21:38:03 +0100
Subject: Prevented compilation from breaking when Python3 is not found.

---
 ChangeLog           |  6 ++++++
 configure.ac        | 38 +++++++++++++++++++++++++++++---------
 plugins/Makefile.am |  6 +++++-
 3 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0846995..6ae599c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+16-03-01  Cyrille Bagard <nocbos@gmail.com>
+
+	* configure.ac:
+	* plugins/Makefile.am:
+	Prevent compilation from breaking when Python3 is not found.
+
 16-02-28  Cyrille Bagard <nocbos@gmail.com>
 
 	* plugins/androhelpers/params.c:
diff --git a/configure.ac b/configure.ac
index 30ad629..b5a33c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,19 +223,36 @@ AC_SUBST(LIBSQLITE_LIBS)
 #--- Checks for Python
 
 if test "x$enable_debug" = "xyes"; then
-   LIBPYTHON_CFLAGS=`python3-dbg-config --cflags`
-   LIBPYTHON_LIBS=`python3-dbg-config --libs`
-   LIBPYTHON_ABI_FLAGS=`python3-dbg-config --abiflags`
+   AC_CHECK_PROG(python3_cfg_binary, [python3-dbg-config] , yes)
 else
-   LIBPYTHON_CFLAGS=`python3-config --cflags`
-   LIBPYTHON_LIBS=`python3-config --libs`
-   LIBPYTHON_ABI_FLAGS=`python3-config --abiflags`
+   AC_CHECK_PROG(python3_cfg_binary, [python3-config] , yes)
 fi
 
-AC_SUBST(LIBPYTHON_CFLAGS)
-AC_SUBST(LIBPYTHON_LIBS)
-AC_DEFINE_UNQUOTED(LIBPYTHON_ABI_FLAGS, "${LIBPYTHON_ABI_FLAGS}", [ABI flags of the linked Python library])
+AM_CONDITIONAL([HAVE_PYTHON3_CONFIG], [test "x$python3_cfg_binary" = "xyes"])
 
+if test "x$python3_cfg_binary" = "xyes"; then
+
+   if test "x$enable_debug" = "xyes"; then
+      LIBPYTHON_CFLAGS=`python3-dbg-config --cflags`
+      LIBPYTHON_LIBS=`python3-dbg-config --libs`
+      LIBPYTHON_ABI_FLAGS=`python3-dbg-config --abiflags`
+   else
+      LIBPYTHON_CFLAGS=`python3-config --cflags`
+      LIBPYTHON_LIBS=`python3-config --libs`
+      LIBPYTHON_ABI_FLAGS=`python3-config --abiflags`
+   fi
+
+   AC_SUBST(LIBPYTHON_CFLAGS)
+   AC_SUBST(LIBPYTHON_LIBS)
+   AC_DEFINE_UNQUOTED(LIBPYTHON_ABI_FLAGS, "${LIBPYTHON_ABI_FLAGS}", [ABI flags of the linked Python library])
+
+   python3_version=`python3 --version | cut -d ' ' -f 2`
+
+else
+
+   python3_version='-'
+
+fi
 
 #--- Checks for pygobject-3.0
 
@@ -381,6 +398,9 @@ echo The GNU Image Manipulation Program Toolkit... : $libgtk_version
 echo The XML C parser and toolkit of Gnome........ : $libxml_version
 echo The flexible interface for archives I/O...... : $libarchive_version
 echo The small, fast and reliable database engine. : $libsqlite_version
+
+echo
+echo Available Python programming language........ : $python3_version
 echo The Python GObject bindings.................. : $libpygobject_version
 
 echo
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 726534f..22ef693 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,2 +1,6 @@
 
-SUBDIRS = androhelpers devdbg libcsem mobicore pychrysa python readelf ropgadgets stackvars
+if HAVE_PYTHON3_CONFIG
+  PYTHON3_SUBDIRS = pychrysa python
+endif
+
+SUBDIRS = androhelpers devdbg libcsem mobicore $(PYTHON3_SUBDIRS) readelf ropgadgets stackvars
-- 
cgit v0.11.2-87-g4458