Makefiles: auto-detect python version - prefer python2

This prepares CRIT for python2/python3 compatibility by auto-detecting
the installed python version. python2 is detected first and then the
variable PYTHON is set.

By setting the variable PYTHON to python2/python3 the user can override
the auto-detection.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Adrian Reber 2018-05-16 06:20:23 +00:00 committed by Andrei Vagin
parent af353d0f69
commit 222ad25bed
3 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,5 @@
CRIU_SO := libcriu.so
UAPI_HEADERS := lib/c/criu.h images/rpc.proto
PYTHON_BIN ?= python2
#
# File to keep track of files installed by setup.py
@ -54,7 +53,7 @@ install: lib-c lib-py crit/crit lib/c/criu.pc.in
$(Q) sed -e 's,@version@,$(CRIU_VERSION),' -e 's,@libdir@,$(LIBDIR),' -e 's,@includedir@,$(dir $(INCLUDEDIR)/criu/),' lib/c/criu.pc.in > lib/c/criu.pc
$(Q) install -m 644 lib/c/criu.pc $(DESTDIR)$(LIBDIR)/pkgconfig
$(E) " INSTALL " crit
$(Q) $(PYTHON_BIN) scripts/crit-setup.py install --prefix=$(DESTDIR)$(PREFIX) --record $(CRIT_SETUP_FILES)
$(Q) $(PYTHON) scripts/crit-setup.py install --prefix=$(DESTDIR)$(PREFIX) --record $(CRIT_SETUP_FILES)
.PHONY: install
uninstall:

View file

@ -12,11 +12,11 @@ images:
magic.py: scripts/magic-gen.py criu/include/magic.h
$(call msg-gen, $@)
$(Q) python $^ $(obj)/$@
$(Q) $(PYTHON) $^ $(obj)/$@
pb.py: images
$(Q) echo "# Autogenerated. Do not edit!" > $(obj)/$@
$(Q) for m in $(proto-py-modules); do \
$(Q) for m in $(filter-out opts_pb2, $(proto-py-modules)); do \
echo "from .$$m import *" >> $(obj)/$@ ;\
done
.PHONY: pb.py

View file

@ -18,7 +18,8 @@ MAKE := make
MKDIR := mkdir -p
AWK := awk
PERL := perl
PYTHON := python
FULL_PYTHON := $(shell which python2 2>/dev/null || which python3 2>/dev/null)
PYTHON ?= $(shell basename $(FULL_PYTHON))
FIND := find
SH := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \