+# Always check for python, we will fail later if some features require it and
+# it's unavailable.
+AM_PATH_PYTHON([3.4], [
+ AE_PATH_PYTHON_MODULES([PYTHON])
+
+ # pythondir is the path where extra modules are to be installed
+ pythondir=$PYTHON_PREFIX/$PYTHON_MODULES_PATH
+
+ # pyexecdir is the path that contains shared objects used by the extra modules
+ pyexecdir=$PYTHON_EXEC_PREFIX/$PYTHON_MODULES_PATH
+
+ # If no PYTHON_CONFIG was specified by the user, try to find it, starting
+ # with the one specific to the configured python version.
+ AS_IF([test "x$PYTHON_CONFIG" = "x"], [
+ AC_CHECK_PROGS([PYTHON_CONFIG], [python$PYTHON_VERSION-config python-config])
+ ])
+
+ # If PYTHON_CONFIG is set use it to get the includes and ld flags, unless
+ # they were specified by the user.
+ AS_IF([test "x$PYTHON_CONFIG" != "x" ], [
+ AS_IF([test "x$PYTHON_INCLUDE" = "x"], [
+ AC_MSG_CHECKING([Python include flags])
+ PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
+ AC_MSG_RESULT([$PYTHON_INCLUDE])
+ ])
+
+ AS_IF([test "x$PYTHON_LDFLAGS" = "x"], [
+ AC_MSG_CHECKING([Python library flags])
+ # Python 3.8+ requires that we pass --embed to get the -lpython3.x flag.
+ AS_IF([! PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags --embed`], [
+ PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
+ ])
+ AC_MSG_RESULT([$PYTHON_LDFLAGS])
+ ])
+ ])
+], [:])
+