From ff187d24b7441e88e1f0361d59b0f6f55851791f Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Mon, 4 Feb 2019 19:45:19 +0100
Subject: Added an option to drop Python support at compilation time.

---
 configure.ac                 | 23 ++++++++++++++++++++---
 plugins/Makefile.am          |  6 ++++--
 plugins/arm/Makefile.am      | 23 +++++++++++++++++------
 plugins/arm/core.c           | 16 ++++++++++++++--
 plugins/dalvik/core.c        | 10 +++++++++-
 plugins/dex/Makefile.am      | 23 +++++++++++++++++------
 plugins/dex/core.c           | 18 ++++++++++++++++--
 plugins/dexbnf/Makefile.am   | 23 +++++++++++++++++------
 plugins/dexbnf/core.c        | 16 ++++++++++++++--
 plugins/dwarf/core.c         | 10 +++++++++-
 plugins/elf/Makefile.am      | 23 +++++++++++++++++------
 plugins/elf/core.c           | 18 ++++++++++++++++--
 plugins/itanium/Makefile.am  | 24 ++++++++++++++++++------
 plugins/itanium/core.c       | 16 ++++++++++++++--
 plugins/javadesc/Makefile.am | 23 +++++++++++++++++------
 plugins/javadesc/core.c      | 16 ++++++++++++++--
 plugins/ropgadgets/plugin.c  | 10 +++++++++-
 src/plugins/plugin-def.h     |  2 ++
 18 files changed, 244 insertions(+), 56 deletions(-)

diff --git a/configure.ac b/configure.ac
index c8e6cf1..4e2967e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -279,13 +279,22 @@ AC_SUBST(LIBSSL_LIBS)
 
 #--- Checks for Python
 
+AC_ARG_ENABLE([python-bindings],
+              AS_HELP_STRING([--disable-python-bindings], [disable Python bindings [default=no]]),
+              [], [enable_python_bindings=yes])
+
 if test "x$enable_debug" = "xyes"; then
    AC_CHECK_PROG(python3_cfg_binary, [python3-dbg-config] , yes)
 else
    AC_CHECK_PROG(python3_cfg_binary, [python3-config] , yes)
 fi
 
-AM_CONDITIONAL([HAVE_PYTHON3_CONFIG], [test "x$python3_cfg_binary" = "xyes"])
+AM_CONDITIONAL([BUILD_PYTHON3_BINDINGS], [test "x$enable_python_bindings$python3_cfg_binary" = "xyesyes"])
+
+if test "x$BUILD_PYTHON3_BINDINGS_TRUE" = "x"; then
+   AC_DEFINE(HAVE_PYTHON3_BINDINGS, 1,
+             [Define to 1 if the Python bindings are available and enabled.])
+fi
 
 if test "x$python3_cfg_binary" = "xyes"; then
 
@@ -303,7 +312,11 @@ if test "x$python3_cfg_binary" = "xyes"; then
    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`
+   if test "x$enable_python_bindings" = "xyes"; then
+      python3_version=`python3 --version | cut -d ' ' -f 2`
+   else
+      python3_version="`python3 --version | cut -d ' ' -f 2` (skipped)"
+   fi
 
 else
 
@@ -317,7 +330,11 @@ fi
 PKG_CHECK_MODULES(LIBPYGOBJECT,pygobject-3.0 >= 3.12.1,[libpygobject_found=yes],[libpygobject_found=no])
 
 if test "$libpygobject_found" = "yes"; then
-   libpygobject_version=`pkg-config pygobject-3.0 --modversion`
+   if test "x$enable_python_bindings" = "xyes"; then
+      libpygobject_version=`pkg-config pygobject-3.0 --modversion`
+   else
+      libpygobject_version="`pkg-config pygobject-3.0 --modversion` (skipped)"
+   fi
 else
    libpygobject_version='-'
 fi
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 8731354..785a1ed 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,6 +1,8 @@
 
-if HAVE_PYTHON3_CONFIG
-    PYTHON3_SUBDIRS = pychrysalide python
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_SUBDIRS = pychrysalide python
+
 endif
 
 # androhelpers
diff --git a/plugins/arm/Makefile.am b/plugins/arm/Makefile.am
index 12e58fd..3091db7 100644
--- a/plugins/arm/Makefile.am
+++ b/plugins/arm/Makefile.am
@@ -4,6 +4,18 @@ lib_LTLIBRARIES = libarm.la
 libdir = $(pluginslibdir)
 
 
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_LIBADD = python/libarmpython.la
+
+PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \
+					-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+
+PYTHON3_SUBDIRS = python
+
+endif
+
+
 libarm_la_SOURCES =						\
 	cond.h								\
 	context-int.h						\
@@ -18,13 +30,12 @@ libarm_la_SOURCES =						\
 	register.h register.c
 
 libarm_la_LIBADD =						\
-	python/libarmpython.la				\
+	$(PYTHON3_LIBADD)					\
 	v7/libarmv7.la
 
-libarm_la_LDFLAGS =													\
-	-L$(top_srcdir)/src/.libs -lchrysacore							\
-	-Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs			\
-	-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+libarm_la_LDFLAGS =								\
+	-L$(top_srcdir)/src/.libs -lchrysacore		\
+	$(PYTHON3_LDFLAGS)
 
 
 devdir = $(includedir)/chrysalide-$(subdir)
@@ -37,4 +48,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
 
-SUBDIRS = v7 python
+SUBDIRS = v7 $(PYTHON3_SUBDIRS)
diff --git a/plugins/arm/core.c b/plugins/arm/core.c
index 07b9b24..3e7aa9a 100644
--- a/plugins/arm/core.c
+++ b/plugins/arm/core.c
@@ -24,16 +24,26 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <plugins/plugin-def.h>
 
 
-#include "python/module.h"
+#ifdef HAVE_PYTHON3_BINDINGS
+#   include "python/module.h"
+#endif
 #include "v7/core.h"
 
 
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
+
+
 
 DEFINE_CHRYSALIDE_PLUGIN("GArmPlugin", "arm", "Add support for the ARM architecture", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT));
+                         PG_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT));
 
 
 
@@ -55,8 +65,10 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 
     result = init_armv7_core();
 
+#ifdef HAVE_PYTHON3_BINDINGS
     if (result)
         result = add_arch_arm_module_to_python_module();
+#endif
 
     return result;
 
diff --git a/plugins/dalvik/core.c b/plugins/dalvik/core.c
index d7e5a04..3220e2d 100644
--- a/plugins/dalvik/core.c
+++ b/plugins/dalvik/core.c
@@ -24,6 +24,7 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <plugins/plugin-def.h>
 
 
@@ -34,9 +35,16 @@
 #include "v35/core.h"
 
 
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
+
+
 
 DEFINE_CHRYSALIDE_PLUGIN("GDalvikPlugin", "dalvik", "Add support for the Dalvik architecture", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT));
+                         PG_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT));
 
 
 
diff --git a/plugins/dex/Makefile.am b/plugins/dex/Makefile.am
index 95a63e0..9b6cb72 100644
--- a/plugins/dex/Makefile.am
+++ b/plugins/dex/Makefile.am
@@ -4,6 +4,18 @@ lib_LTLIBRARIES = libdex.la
 libdir = $(pluginslibdir)
 
 
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_LIBADD = python/libdexpython.la
+
+PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \
+					-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+
+PYTHON3_SUBDIRS = python
+
+endif
+
+
 libdex_la_SOURCES =						\
 	core.h core.c						\
 	class.h class.c						\
@@ -16,12 +28,11 @@ libdex_la_SOURCES =						\
 	pool.h pool.c
 
 libdex_la_LIBADD =						\
-	python/libdexpython.la
+	$(PYTHON3_LIBADD)
 
-libdex_la_LDFLAGS =													\
-	-L$(top_srcdir)/src/.libs -lchrysacore							\
-	-Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs			\
-	-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+libdex_la_LDFLAGS =								\
+	-L$(top_srcdir)/src/.libs -lchrysacore		\
+	$(PYTHON3_LDFLAGS)
 
 
 devdir = $(includedir)/chrysalide-$(subdir)
@@ -33,4 +44,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
-SUBDIRS = python
+SUBDIRS = $(PYTHON3_SUBDIRS)
diff --git a/plugins/dex/core.c b/plugins/dex/core.c
index 3e5b835..0f66c86 100644
--- a/plugins/dex/core.c
+++ b/plugins/dex/core.c
@@ -24,17 +24,27 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <core/global.h>
 #include <plugins/plugin-def.h>
 
 
 #include "format.h"
-#include "python/module.h"
+#ifdef HAVE_PYTHON3_BINDINGS
+#   include "python/module.h"
+#endif
+
+
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide", "dexbnf")
+#else
+#   define PG_REQ RL("dexbnf")
+#endif
 
 
 
 DEFINE_CHRYSALIDE_PLUGIN("GDexPlugin", "dex", "Add support for the DEX format", "0.1.0",
-                         RL("PyChrysalide", "dexbnf"), AL(PGA_PLUGIN_INIT, PGA_CONTENT_RESOLVER));
+                         PG_REQ, AL(PGA_PLUGIN_INIT, PGA_CONTENT_RESOLVER));
 
 
 
@@ -54,7 +64,11 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 {
     bool result;                            /* Bilan à retourner           */
 
+#ifdef HAVE_PYTHON3_BINDINGS
     result = add_format_dex_module_to_python_module();
+#else
+    result = true;
+#endif
 
     return result;
 
diff --git a/plugins/dexbnf/Makefile.am b/plugins/dexbnf/Makefile.am
index 226bcc0..f460459 100644
--- a/plugins/dexbnf/Makefile.am
+++ b/plugins/dexbnf/Makefile.am
@@ -4,6 +4,18 @@ lib_LTLIBRARIES = libdexbnf.la
 libdir = $(pluginslibdir)
 
 
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_LIBADD = python/libdexbnfpython.la
+
+PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \
+					-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+
+PYTHON3_SUBDIRS = python
+
+endif
+
+
 libdexbnf_la_SOURCES =					\
 	context.h context.c					\
 	core.h core.c						\
@@ -13,12 +25,11 @@ libdexbnf_la_SOURCES =					\
 	type.h type.c
 
 libdexbnf_la_LIBADD =					\
-	python/libdexbnfpython.la
+	$(PYTHON3_LIBADD)
 
-libdexbnf_la_LDFLAGS =												\
-	-L$(top_srcdir)/src/.libs -lchrysacore							\
-	-Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs			\
-	-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+libdexbnf_la_LDFLAGS =							\
+	-L$(top_srcdir)/src/.libs -lchrysacore		\
+	$(PYTHON3_LDFLAGS)
 
 
 devdir = $(includedir)/chrysalide-$(subdir)
@@ -30,4 +41,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
-SUBDIRS = python
+SUBDIRS = $(PYTHON3_SUBDIRS)
diff --git a/plugins/dexbnf/core.c b/plugins/dexbnf/core.c
index 736fa5f..f96f64b 100644
--- a/plugins/dexbnf/core.c
+++ b/plugins/dexbnf/core.c
@@ -24,17 +24,27 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <core/demanglers.h>
 #include <plugins/plugin-def.h>
 
 
 #include "demangler.h"
-#include "python/module.h"
+#ifdef HAVE_PYTHON3_BINDINGS
+#   include "python/module.h"
+#endif
+
+
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
 
 
 
 DEFINE_CHRYSALIDE_PLUGIN("GDexBnfPlugin", "dexbnf", "Symbol demangler for Dex", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT));
+                         PG_REQ, AL(PGA_PLUGIN_INIT));
 
 
 
@@ -56,8 +66,10 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 
     result = register_demangler_type("dex", G_TYPE_DEX_DEMANGLER);
 
+#ifdef HAVE_PYTHON3_BINDINGS
     if (result)
         result = add_mangling_dexbnf_module_to_python_module();
+#endif
 
     return result;
 
diff --git a/plugins/dwarf/core.c b/plugins/dwarf/core.c
index 1e2d900..9a548ab 100644
--- a/plugins/dwarf/core.c
+++ b/plugins/dwarf/core.c
@@ -24,15 +24,23 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <plugins/plugin-def.h>
 
 
 #include "format.h"
 
 
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
+
+
 
 DEFINE_CHRYSALIDE_PLUGIN("GDwarfPlugin", "dwarf", "Add support for the DWARF format", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT, PGA_FORMAT_ATTACH_DEBUG));
+                         PG_REQ, AL(PGA_PLUGIN_INIT, PGA_FORMAT_ATTACH_DEBUG));
 
 
 
diff --git a/plugins/elf/Makefile.am b/plugins/elf/Makefile.am
index 50c9d49..59ee46c 100644
--- a/plugins/elf/Makefile.am
+++ b/plugins/elf/Makefile.am
@@ -4,6 +4,18 @@ lib_LTLIBRARIES = libelf.la
 libdir = $(pluginslibdir)
 
 
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_LIBADD = python/libelfpython.la
+
+PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \
+					-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+
+PYTHON3_SUBDIRS = python
+
+endif
+
+
 libelf_la_SOURCES =						\
 	core.h core.c						\
 	elf-int.h elf-int.c					\
@@ -19,12 +31,11 @@ libelf_la_SOURCES =						\
 	symbols.h symbols.c
 
 libelf_la_LIBADD =						\
-	python/libelfpython.la
+	$(PYTHON3_LIBADD)
 
-libelf_la_LDFLAGS =													\
-	-L$(top_srcdir)/src/.libs -lchrysacore							\
-	-Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs			\
-	-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+libelf_la_LDFLAGS =								\
+	-L$(top_srcdir)/src/.libs -lchrysacore		\
+	$(PYTHON3_LDFLAGS)
 
 
 devdir = $(includedir)/chrysalide-$(subdir)
@@ -36,4 +47,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
-SUBDIRS = python
+SUBDIRS = $(PYTHON3_SUBDIRS)
diff --git a/plugins/elf/core.c b/plugins/elf/core.c
index d3d226e..41adff7 100644
--- a/plugins/elf/core.c
+++ b/plugins/elf/core.c
@@ -24,17 +24,27 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <core/global.h>
 #include <plugins/plugin-def.h>
 
 
 #include "format.h"
-#include "python/module.h"
+#ifdef HAVE_PYTHON3_BINDINGS
+#   include "python/module.h"
+#endif
+
+
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
 
 
 
 DEFINE_CHRYSALIDE_PLUGIN("GElfPlugin", "elf", "Add support for the ELF format", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT, PGA_CONTENT_RESOLVER));
+                         PG_REQ, AL(PGA_PLUGIN_INIT, PGA_CONTENT_RESOLVER));
 
 
 
@@ -54,7 +64,11 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 {
     bool result;                            /* Bilan à retourner           */
 
+#ifdef HAVE_PYTHON3_BINDINGS
     result = add_format_elf_module_to_python_module();
+#else
+    result = true;
+#endif
 
     return result;
 
diff --git a/plugins/itanium/Makefile.am b/plugins/itanium/Makefile.am
index b6d62ff..ecbdc93 100644
--- a/plugins/itanium/Makefile.am
+++ b/plugins/itanium/Makefile.am
@@ -3,6 +3,19 @@ lib_LTLIBRARIES  = libitanium.la
 
 libdir = $(pluginslibdir)
 
+
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_LIBADD = python/libitaniumpython.la
+
+PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \
+					-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+
+PYTHON3_SUBDIRS = python
+
+endif
+
+
 libitanium_la_SOURCES =					\
 	abi.h abi.c							\
 	component-int.h						\
@@ -12,12 +25,11 @@ libitanium_la_SOURCES =					\
 	demangler.h demangler.c
 
 libitanium_la_LIBADD =					\
-	python/libitaniumpython.la
+	$(PYTHON3_LIBADD)
 
-libitanium_la_LDFLAGS =												\
-	-L$(top_srcdir)/src/.libs -lchrysacore							\
-	-Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs			\
-	-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+libitanium_la_LDFLAGS =							\
+	-L$(top_srcdir)/src/.libs -lchrysacore		\
+	$(PYTHON3_LDFLAGS)
 
 
 devdir = $(includedir)/chrysalide-$(subdir)
@@ -29,4 +41,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
-SUBDIRS = python
+SUBDIRS = $(PYTHON3_SUBDIRS)
diff --git a/plugins/itanium/core.c b/plugins/itanium/core.c
index 71816f7..974e244 100644
--- a/plugins/itanium/core.c
+++ b/plugins/itanium/core.c
@@ -24,17 +24,27 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <core/demanglers.h>
 #include <plugins/plugin-def.h>
 
 
 #include "demangler.h"
-#include "python/module.h"
+#ifdef HAVE_PYTHON3_BINDINGS
+#   include "python/module.h"
+#endif
+
+
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
 
 
 
 DEFINE_CHRYSALIDE_PLUGIN("GItaniumPlugin", "itanium", "Symbol demangler for Itanium", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT));
+                         PG_REQ, AL(PGA_PLUGIN_INIT));
 
 
 
@@ -56,8 +66,10 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 
     result = register_demangler_type("itanium", G_TYPE_ITANIUM_DEMANGLER);
 
+#ifdef HAVE_PYTHON3_BINDINGS
     if (result)
         result = add_mangling_itanium_module_to_python_module();
+#endif
 
     return result;
 
diff --git a/plugins/javadesc/Makefile.am b/plugins/javadesc/Makefile.am
index bc55192..9474a87 100644
--- a/plugins/javadesc/Makefile.am
+++ b/plugins/javadesc/Makefile.am
@@ -4,6 +4,18 @@ lib_LTLIBRARIES = libjavadesc.la
 libdir = $(pluginslibdir)
 
 
+if BUILD_PYTHON3_BINDINGS
+
+PYTHON3_LIBADD = python/libjavadescpython.la
+
+PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \
+					-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+
+PYTHON3_SUBDIRS = python
+
+endif
+
+
 libjavadesc_la_SOURCES =				\
 	context.h context.c					\
 	core.h core.c						\
@@ -12,12 +24,11 @@ libjavadesc_la_SOURCES =				\
 	method.h method.c
 
 libjavadesc_la_LIBADD =					\
-	python/libjavadescpython.la
+	$(PYTHON3_LIBADD)
 
-libjavadesc_la_LDFLAGS =											\
-	-L$(top_srcdir)/src/.libs -lchrysacore							\
-	-Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs			\
-	-L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so
+libjavadesc_la_LDFLAGS =						\
+	-L$(top_srcdir)/src/.libs -lchrysacore		\
+	$(PYTHON3_LDFLAGS)
 
 
 devdir = $(includedir)/chrysalide-$(subdir)
@@ -29,4 +40,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
-SUBDIRS = python
+SUBDIRS = $(PYTHON3_SUBDIRS)
diff --git a/plugins/javadesc/core.c b/plugins/javadesc/core.c
index 41c4789..84c96e8 100644
--- a/plugins/javadesc/core.c
+++ b/plugins/javadesc/core.c
@@ -24,17 +24,27 @@
 #include "core.h"
 
 
+#include <config.h>
 #include <core/demanglers.h>
 #include <plugins/plugin-def.h>
 
 
 #include "demangler.h"
-#include "python/module.h"
+#ifdef HAVE_PYTHON3_BINDINGS
+#   include "python/module.h"
+#endif
+
+
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
 
 
 
 DEFINE_CHRYSALIDE_PLUGIN("GJavaDescPlugin", "javadesc", "Symbol demangler for Java", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT));
+                         PG_REQ, AL(PGA_PLUGIN_INIT));
 
 
 
@@ -56,8 +66,10 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 
     result = register_demangler_type("java", G_TYPE_JAVA_DEMANGLER);
 
+#ifdef HAVE_PYTHON3_BINDINGS
     if (result)
         result = add_mangling_javadesc_module_to_python_module();
+#endif
 
     return result;
 
diff --git a/plugins/ropgadgets/plugin.c b/plugins/ropgadgets/plugin.c
index d560c88..1e8aef6 100644
--- a/plugins/ropgadgets/plugin.c
+++ b/plugins/ropgadgets/plugin.c
@@ -24,6 +24,7 @@
 #include "plugin.h"
 
 
+#include <config.h>
 #include <i18n.h>
 
 
@@ -35,9 +36,16 @@
 #include "select.h"
 
 
+#ifdef HAVE_PYTHON3_BINDINGS
+#   define PG_REQ RL("PyChrysalide")
+#else
+#   define PG_REQ NO_REQ
+#endif
+
+
 
 DEFINE_CHRYSALIDE_PLUGIN("GROPPlugin", "ROP gadgets", "Find available gadgets for a ROP chain", "0.1.0",
-                         RL("PyChrysalide"), AL(PGA_PLUGIN_INIT));
+                         PG_REQ, AL(PGA_PLUGIN_INIT));
 
 
 
diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h
index b8cdca8..6d4253e 100644
--- a/src/plugins/plugin-def.h
+++ b/src/plugins/plugin-def.h
@@ -253,6 +253,8 @@ typedef struct _plugin_interface
 
 #define RL(...) BUILD_PG_LIST(.required, ((const char *[]){ __VA_ARGS__ }))
 
+#define NO_REQ EMPTY_PG_LIST(.required)
+
 
 #define DEFINE_CHRYSALIDE_PLUGIN(t, n, d, v, r, a)              \
 G_MODULE_EXPORT const plugin_interface _chrysalide_plugin = {   \
-- 
cgit v0.11.2-87-g4458