Commit 1a0ad1ae authored by Adrian Reber's avatar Adrian Reber Committed by Pavel Emelyanov

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: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 98cb5c62
CRIU_SO := libcriu.so CRIU_SO := libcriu.so
UAPI_HEADERS := lib/c/criu.h images/rpc.proto UAPI_HEADERS := lib/c/criu.h images/rpc.proto
PYTHON_BIN ?= python2
# #
# File to keep track of files installed by setup.py # 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 ...@@ -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) 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 $(Q) install -m 644 lib/c/criu.pc $(DESTDIR)$(LIBDIR)/pkgconfig
$(E) " INSTALL " crit $(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 .PHONY: install
uninstall: uninstall:
......
...@@ -12,11 +12,11 @@ images: ...@@ -12,11 +12,11 @@ images:
magic.py: scripts/magic-gen.py criu/include/magic.h magic.py: scripts/magic-gen.py criu/include/magic.h
$(call msg-gen, $@) $(call msg-gen, $@)
$(Q) python $^ $(obj)/$@ $(Q) $(PYTHON) $^ $(obj)/$@
pb.py: images pb.py: images
$(Q) echo "# Autogenerated. Do not edit!" > $(obj)/$@ $(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)/$@ ;\ echo "from .$$m import *" >> $(obj)/$@ ;\
done done
.PHONY: pb.py .PHONY: pb.py
......
...@@ -18,7 +18,8 @@ MAKE := make ...@@ -18,7 +18,8 @@ MAKE := make
MKDIR := mkdir -p MKDIR := mkdir -p
AWK := awk AWK := awk
PERL := perl PERL := perl
PYTHON := python FULL_PYTHON := $(shell which python2 2>/dev/null || which python3 2>/dev/null)
PYTHON ?= $(shell basename $(FULL_PYTHON))
FIND := find FIND := find
SH := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ SH := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \ else if [ -x /bin/bash ]; then echo /bin/bash; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment