aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-25 12:55:01 +0200
committervan Hauser <vh@thc.org>2020-04-25 12:55:01 +0200
commita3ee281e2ba364b618c056569222d70de036a3d7 (patch)
tree5bb2b3695b7917c3ff62abf04cdfe76decd6a0f2
parent232290108e2792034836193fa768562ef4476959 (diff)
downloadafl++-a3ee281e2ba364b618c056569222d70de036a3d7.tar.gz
fix python detection for Ubuntu and others
-rw-r--r--.travis.yml2
-rw-r--r--GNUmakefile54
2 files changed, 41 insertions, 15 deletions
diff --git a/.travis.yml b/.travis.yml
index 89d72c34..a360bd42 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,7 +32,7 @@ jobs:
- arch: arm64
env:
- - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_STOP_MANUALLY=1
+ - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1
# - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_EXIT_WHEN_DONE=1
# TODO: test AFL_BENCH_UNTIL_CRASH once we have a target that crashes
# - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_BENCH_JUST_ONE=1
diff --git a/GNUmakefile b/GNUmakefile
index e8e81c65..0ba4a2b6 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -88,24 +88,50 @@ ifneq "$(shell command -v python3m 2>/dev/null)" ""
endif
endif
-ifneq "$(shell command -v python3 2>/dev/null)" ""
- ifneq "$(shell command -v python3-config 2>/dev/null)" ""
- PYTHON_INCLUDE ?= $(shell python3-config --includes)
- PYTHON_VERSION ?= $(strip $(shell python3 --version 2>&1))
- # Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
- ifeq "$(shell python3-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
- PYTHON_LIB ?= $(shell python3-config --libs --embed --ldflags)
- else
- PYTHON_LIB ?= $(shell python3-config --ldflags)
+ifeq "$(PYTHON_INCLUDE)" ""
+ ifneq "$(shell command -v python3 2>/dev/null)" ""
+ ifneq "$(shell command -v python3-config 2>/dev/null)" ""
+ PYTHON_INCLUDE ?= $(shell python3-config --includes)
+ PYTHON_VERSION ?= $(strip $(shell python3 --version 2>&1))
+ # Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
+ ifeq "$(shell python3-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
+ PYTHON_LIB ?= $(shell python3-config --libs --embed --ldflags)
+ else
+ PYTHON_LIB ?= $(shell python3-config --ldflags)
+ endif
+ endif
+ endif
+endif
+
+ifeq "$(PYTHON_INCLUDE)" ""
+ ifneq "$(shell command -v python 2>/dev/null)" ""
+ ifneq "$(shell command -v python-config 2>/dev/null)" ""
+ PYTHON_INCLUDE ?= $(shell python-config --includes)
+ PYTHON_LIB ?= $(shell python-config --ldflags)
+ PYTHON_VERSION ?= $(strip $(shell python --version 2>&1))
endif
endif
endif
-ifneq "$(shell command -v python 2>/dev/null)" ""
- ifneq "$(shell command -v python-config 2>/dev/null)" ""
- PYTHON_INCLUDE ?= $(shell python-config --includes)
- PYTHON_LIB ?= $(shell python-config --ldflags)
- PYTHON_VERSION ?= $(strip $(shell python --version 2>&1))
+# Old Ubuntu and others dont have python/python3-config so we hardcode 3.7
+ifeq "$(PYTHON_INCLUDE)" ""
+ ifneq "$(shell command -v python3.7 2>/dev/null)" ""
+ ifneq "$(shell command -v python-config3.7-config 2>/dev/null)" ""
+ PYTHON_INCLUDE ?= $(shell python-config --includes)
+ PYTHON_LIB ?= $(shell python-config --ldflags)
+ PYTHON_VERSION ?= $(strip $(shell python --version 2>&1))
+ endif
+ endif
+endif
+
+# Old Ubuntu and others dont have python/python2-config so we hardcode 2.7
+ifeq "$(PYTHON_INCLUDE)" ""
+ ifneq "$(shell command -v python2.7 2>/dev/null)" ""
+ ifneq "$(shell command -v python-config2.7-config 2>/dev/null)" ""
+ PYTHON_INCLUDE ?= $(shell python-config --includes)
+ PYTHON_LIB ?= $(shell python-config --ldflags)
+ PYTHON_VERSION ?= $(strip $(shell python --version 2>&1))
+ endif
endif
endif