소스 검색

app_python3: Makefile - extend python3-config lookup

Daniel-Constantin Mierla 2 년 전
부모
커밋
03356132ae
1개의 변경된 파일21개의 추가작업 그리고 8개의 파일을 삭제
  1. 21 8
      src/modules/app_python3/Makefile

+ 21 - 8
src/modules/app_python3/Makefile

@@ -1,4 +1,4 @@
-# 
+#
 # WARNING: do not run this directly, it should be run by the main Makefile
 # WARNING: do not run this directly, it should be run by the main Makefile
 
 
 include ../../Makefile.defs
 include ../../Makefile.defs
@@ -6,21 +6,34 @@ auto_gen=
 NAME=app_python3.so
 NAME=app_python3.so
 
 
 # If you have multiple Python versions installed make sure to modify the
 # If you have multiple Python versions installed make sure to modify the
-# the following to point to the correct instance. Module has been tested
-# to work with 2.6 and 2.5. Python 2.4 has been only confirmed to compile,
-# but no testing has been done with that.
-PYTHON3?=python3
+# the following to point to the correct instance.
+PYTHON3?=$(shell which python3)
+ifeq ($(PYTHON3),)
+PYTHON3=python
+endif
+
+PYTHON3CONFIG=$(shell which ${PYTHON3}-config)
+ifeq ($(PYTHON3CONFIG),)
+python_version_full := $(wordlist 2,4,$(subst ., ,$(shell ${PYTHON3} --version 2>&1)))
+python_version_major := $(word 1,${python_version_full})
+python_version_minor := $(word 2,${python_version_full})
+PYTHON3 = python${python_version_major}.${python_version_minor}
+PYTHON3CONFIG=$(shell which ${PYTHON3}-config)
+ifeq ($(PYTHON3CONFIG),)
+PYTHON3CONFIG=${PYTHON3}-config
+endif
+endif
 
 
 LIBS=${shell \
 LIBS=${shell \
-	tmp_py3_libs=$$(${PYTHON3}-config --ldflags --embed 2>/dev/null) || \
-	tmp_py3_libs=$$(${PYTHON3}-config --ldflags); \
+	tmp_py3_libs=$$(${PYTHON3CONFIG} --ldflags --embed 2>/dev/null) || \
+	tmp_py3_libs=$$(${PYTHON3CONFIG} --ldflags); \
 	echo $$tmp_py3_libs}
 	echo $$tmp_py3_libs}
 
 
 ifeq ($(OS), freebsd)
 ifeq ($(OS), freebsd)
 LIBS+=-pthread
 LIBS+=-pthread
 endif
 endif
 
 
-DEFS+=${shell ${PYTHON3}-config --includes}
+DEFS+=${shell ${PYTHON3CONFIG} --includes}
 
 
 include ../../Makefile.modules
 include ../../Makefile.modules