File 0032-configure-add-Python-library-detection.patch of Package resource-agents.11371
From 49e3c1a4d5e6504685a16c164863ddcc7554da10 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 24 Jan 2019 11:28:00 +0100
Subject: [PATCH] configure: add Python library detection
---
configure.ac | 38 +++++++++++++++++++++++++++++++++++++-
doc/man/Makefile.am | 16 ++++++++++++++++
heartbeat/Makefile.am | 16 ++++++++++++++++
m4/ac_python_module.m4 | 30 ++++++++++++++++++++++++++++++
4 files changed, 99 insertions(+), 1 deletion(-)
create mode 100644 m4/ac_python_module.m4
diff --git a/configure.ac b/configure.ac
index d0099c28..deeeac0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,8 @@ CRM_DTD_VERSION="1.0"
PKG_FEATURES=""
AC_CONFIG_AUX_DIR(.)
+AC_CONFIG_MACRO_DIR([m4])
+
AC_CANONICAL_HOST
dnl Where #defines go (e.g. `AC_CHECK_HEADERS' below)
@@ -487,12 +489,46 @@ AC_SUBST(SHELL)
AC_SUBST(PING)
AC_SUBST(TEST)
+dnl Ensure PYTHON is an absolute path
+AC_PATH_PROG([PYTHON], [$PYTHON])
+
AM_PATH_PYTHON
if test -z "$PYTHON"; then
echo "*** Essential program python not found" 1>&2
- exit 1
fi
+AC_PYTHON_MODULE(googleapiclient)
+AC_PYTHON_MODULE(pyroute2)
+
+BUILD_AZURE_EVENTS=1
+if test -z "$PYTHON"; then
+ BUILD_AZURE_EVENTS=0
+ AC_MSG_WARN("Not building azure-events")
+fi
+AM_CONDITIONAL(BUILD_AZURE_EVENTS, test $BUILD_AZURE_EVENTS -eq 1)
+
+BUILD_GCP_PD_MOVE=1
+if test -z "$PYTHON" || test "x${HAVE_PYMOD_GOOGLEAPICLIENT}" != xyes; then
+ BUILD_GCP_PD_MOVE=0
+ AC_MSG_WARN("Not building gcp-pd-move")
+fi
+AM_CONDITIONAL(BUILD_GCP_PD_MOVE, test $BUILD_GCP_PD_MOVE -eq 1)
+
+BUILD_GCP_VPC_MOVE_ROUTE=1
+if test -z "$PYTHON" || test "x${HAVE_PYMOD_GOOGLEAPICLIENT}" != xyes || \
+ test "x${HAVE_PYMOD_PYROUTE2}" != xyes; then
+ BUILD_GCP_VPC_MOVE_ROUTE=0
+ AC_MSG_WARN("Not building gcp-vpc-move-route")
+fi
+AM_CONDITIONAL(BUILD_GCP_VPC_MOVE_ROUTE, test $BUILD_GCP_VPC_MOVE_ROUTE -eq 1)
+
+BUILD_GCP_VPC_MOVE_VIP=1
+if test -z "$PYTHON" || test "x${HAVE_PYMOD_GOOGLEAPICLIENT}" != xyes; then
+ BUILD_GCP_VPC_MOVE_VIP=0
+ AC_MSG_WARN("Not building gcp-vpc-move-vip")
+fi
+AM_CONDITIONAL(BUILD_GCP_VPC_MOVE_VIP, test $BUILD_GCP_VPC_MOVE_VIP -eq 1)
+
AC_PATH_PROGS(ROUTE, route)
AC_DEFINE_UNQUOTED(ROUTE, "$ROUTE", path to route command)
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index e18bd0aa..1a7ff5f7 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -165,6 +165,22 @@ if USE_IPV6ADDR_AGENT
man_MANS += ocf_heartbeat_IPv6addr.7
endif
+if BUILD_AZURE_EVENTS
+man_MANS += ocf_heartbeat_azure-events.7
+endif
+
+if BUILD_GCP_PD_MOVE
+man_MANS += ocf_heartbeat_gcp-pd-move.7
+endif
+
+if BUILD_GCP_VPC_MOVE_ROUTE
+man_MANS += ocf_heartbeat_gcp-vpc-move-route.7
+endif
+
+if BUILD_GCP_VPC_MOVE_VIP
+man_MANS += ocf_heartbeat_gcp-vpc-move-vip.7
+endif
+
xmlfiles = $(man_MANS:.7=.xml)
%.1 %.5 %.7 %.8: %.xml
diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
index 200a20f7..195604b2 100644
--- a/heartbeat/Makefile.am
+++ b/heartbeat/Makefile.am
@@ -161,6 +161,22 @@ ocf_SCRIPTS = AoEtarget \
vsftpd \
zabbixserver
+if BUILD_AZURE_EVENTS
+ocf_SCRIPTS += azure-events
+endif
+
+if BUILD_GCP_PD_MOVE
+ocf_SCRIPTS += gcp-pd-move
+endif
+
+if BUILD_GCP_VPC_MOVE_ROUTE
+ocf_SCRIPTS += gcp-vpc-move-route
+endif
+
+if BUILD_GCP_VPC_MOVE_VIP
+ocf_SCRIPTS += gcp-vpc-move-vip
+endif
+
ocfcommondir = $(OCF_LIB_DIR_PREFIX)/heartbeat
ocfcommon_DATA = ocf-shellfuncs \
ocf-binaries \
diff --git a/m4/ac_python_module.m4 b/m4/ac_python_module.m4
new file mode 100644
index 00000000..d1c81f66
--- /dev/null
+++ b/m4/ac_python_module.m4
@@ -0,0 +1,30 @@
+dnl @synopsis AC_PYTHON_MODULE(modname[, fatal])
+dnl
+dnl Checks for Python module.
+dnl
+dnl If fatal is non-empty then absence of a module will trigger an
+dnl error.
+dnl
+dnl @category InstalledPackages
+dnl @author Andrew Collier <colliera@nu.ac.za>.
+dnl @version 2004-07-14
+dnl @license AllPermissive
+
+AC_DEFUN([AC_PYTHON_MODULE],[
+ AC_MSG_CHECKING(python module: $1)
+ $PYTHON -c "import $1" 2>/dev/null
+ if test $? -eq 0;
+ then
+ AC_MSG_RESULT(yes)
+ eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
+ else
+ AC_MSG_RESULT(no)
+ eval AS_TR_CPP(HAVE_PYMOD_$1)=no
+ #
+ if test -n "$2"
+ then
+ AC_MSG_ERROR(failed to find required module $1)
+ exit 1
+ fi
+ fi
+])
--
2.16.4