criu/lib/py/images/Makefile
Adrian Reber 1a0ad1ae87 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>
2018-07-09 18:25:16 +03:00

25 lines
910 B
Makefile

all-y += images magic.py pb.py
proto := $(filter-out images/rpc.proto, $(sort $(wildcard images/*.proto)))
proto-py-modules := $(foreach m,$(proto),$(subst -,_,$(notdir $(m:.proto=_pb2))))
# We don't need rpc_pb2.py here, as it is not related to the images.
# Unfortunately, we can't drop ugly _pb2 suffixes here, because
# some _pb2 files depend on others _pb2 files.
images:
$(Q) protoc -I=images/ -I=/usr/include/ --python_out=$(obj) $(proto)
.PHONY: images
magic.py: scripts/magic-gen.py criu/include/magic.h
$(call msg-gen, $@)
$(Q) $(PYTHON) $^ $(obj)/$@
pb.py: images
$(Q) echo "# Autogenerated. Do not edit!" > $(obj)/$@
$(Q) for m in $(filter-out opts_pb2, $(proto-py-modules)); do \
echo "from .$$m import *" >> $(obj)/$@ ;\
done
.PHONY: pb.py
cleanup-y += $(addprefix $(obj)/,magic.py pb.py *.pyc)
cleanup-y += $(call cleanify,$(addprefix $(obj)/,$(addsuffix .py,$(proto-py-modules))))