mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
lib Makefiles: integrate
Our whole system of Makefiles are integrated from top to bottom, meaning: 1. The paths in sub-makefiles are relative to the top source dir. 2. Sub-makefiles are executed via make $(build)=<SUBDIR> <TARGET> For some reason, makefiles under lib/ are the exclusion. Let's fix it. Side effect: you can now build any individual target under lib/, for example, "make lib/c/libcriu.so" works. [v2: use the .FORCE, thanks to dsafonov@] Signed-off-by: Kir Kolyshkin <kir@openvz.org> Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
67bd47878d
commit
2a9d9c6615
6 changed files with 59 additions and 55 deletions
8
Makefile
8
Makefile
|
|
@ -233,14 +233,12 @@ criu: images/built-in.o $(SOCCR_A) $(VERSION_HEADER) $(CONFIG_HEADER)
|
|||
# (we might generate headers and such
|
||||
# when building criu itself).
|
||||
lib/%: criu .FORCE
|
||||
$(Q) $(MAKE) -C lib $@
|
||||
$(Q) $(MAKE) $(build)=lib $@
|
||||
lib: criu
|
||||
$(Q) $(MAKE) -C lib all
|
||||
$(Q) $(MAKE) $(build)=lib all
|
||||
.PHONY: lib
|
||||
|
||||
subclean:
|
||||
$(call msg-clean, criu)
|
||||
$(Q) $(MAKE) -C lib clean
|
||||
$(Q) $(MAKE) -C Documentation clean
|
||||
$(Q) $(RM) .gitid
|
||||
.PHONY: subclean
|
||||
|
|
@ -249,6 +247,7 @@ clean: subclean
|
|||
$(Q) $(MAKE) $(build)=images $@
|
||||
$(Q) $(MAKE) $(build)=criu $@
|
||||
$(Q) $(MAKE) $(build)=soccr $@
|
||||
$(Q) $(MAKE) $(build)=lib $@
|
||||
.PHONY: clean
|
||||
|
||||
# mrproper depends on clean in nmk
|
||||
|
|
@ -256,6 +255,7 @@ mrproper: subclean
|
|||
$(Q) $(MAKE) $(build)=images $@
|
||||
$(Q) $(MAKE) $(build)=criu $@
|
||||
$(Q) $(MAKE) $(build)=soccr $@
|
||||
$(Q) $(MAKE) $(build)=lib $@
|
||||
$(Q) $(RM) $(CONFIG_HEADER)
|
||||
$(Q) $(RM) $(SOCCR_CONFIG)
|
||||
$(Q) $(RM) $(VERSION_HEADER)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ install-man:
|
|||
.PHONY: install-man
|
||||
|
||||
install-lib: lib
|
||||
$(Q) $(MAKE) -C lib install
|
||||
$(Q) $(MAKE) $(build)=lib install
|
||||
.PHONY: install-lib
|
||||
|
||||
install-criu: criu
|
||||
|
|
@ -42,6 +42,6 @@ install: install-man install-lib install-criu
|
|||
|
||||
uninstall:
|
||||
$(Q) $(MAKE) -C Documentation $@
|
||||
$(Q) $(MAKE) -C lib $@
|
||||
$(Q) $(MAKE) $(build)=lib $@
|
||||
$(Q) $(MAKE) -C criu $@
|
||||
.PHONY: uninstall
|
||||
|
|
|
|||
56
lib/Makefile
56
lib/Makefile
|
|
@ -1,62 +1,60 @@
|
|||
include $(__nmk_dir)include.mk
|
||||
|
||||
CRIU_SO := libcriu.so
|
||||
UAPI_HEADERS := c/criu.h ../images/rpc.proto
|
||||
UAPI_HEADERS := lib/c/criu.h images/rpc.proto
|
||||
PYTHON_BIN ?= python2
|
||||
|
||||
.PHONY: .FORCE
|
||||
|
||||
#
|
||||
# File to keep track of files installed by setup.py
|
||||
CRIT_SETUP_FILES := .crit-setup.files
|
||||
CRIT_SETUP_FILES := lib/.crit-setup.files
|
||||
|
||||
all-y += lib-c lib-py
|
||||
|
||||
#
|
||||
# C language bindings.
|
||||
c/%: ../Makefile.versions
|
||||
lib/c/%: .FORCE
|
||||
$(call msg-gen, $@)
|
||||
$(Q) $(MAKE) $(build)=c $@
|
||||
$(Q) $(MAKE) $(build)=lib/c $@
|
||||
|
||||
cflags-so += $(CFLAGS) -rdynamic -Wl,-soname,$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR)
|
||||
ldflags-so += -lprotobuf-c
|
||||
c/$(CRIU_SO): c/built-in.o
|
||||
|
||||
lib/c/$(CRIU_SO): lib/c/built-in.o
|
||||
$(call msg-link, $@)
|
||||
$(Q) $(CC) -shared $(cflags-so) -o $@ $^ $(ldflags-so) $(LDFLAGS)
|
||||
lib-c: c/$(CRIU_SO)
|
||||
lib-c: lib/c/$(CRIU_SO)
|
||||
.PHONY: lib-c
|
||||
|
||||
#
|
||||
# Python bindings.
|
||||
lib-py:
|
||||
lib/py/%: .FORCE
|
||||
$(call msg-gen, $@)
|
||||
$(Q) $(MAKE) -C py all
|
||||
$(Q) $(MAKE) $(build)=lib/py $@
|
||||
lib-py:
|
||||
$(Q) $(MAKE) $(build)=lib/py all
|
||||
.PHONY: lib-py
|
||||
|
||||
all: lib-c lib-py
|
||||
@true
|
||||
.PHONY: all
|
||||
clean-lib:
|
||||
$(Q) $(MAKE) $(build)=lib/c clean
|
||||
$(Q) $(MAKE) $(build)=lib/py clean
|
||||
.PHONY: clean-lib
|
||||
clean: clean-lib
|
||||
cleanup-y += lib/c/$(CRIU_SO) lib/c/criu.pc
|
||||
|
||||
clean:
|
||||
$(call msg-clean, lib-c)
|
||||
$(Q) $(MAKE) $(build)=c $@
|
||||
$(Q) $(RM) c/$(CRIU_SO)
|
||||
$(Q) $(RM) c/criu.pc
|
||||
$(call msg-clean, lib-py)
|
||||
$(Q) $(MAKE) -C py $@
|
||||
$(Q) $(RM) -r build usr
|
||||
.PHONY: clean
|
||||
|
||||
install: lib-c lib-py ../crit/crit c/criu.pc.in
|
||||
$(E) " INSTALL " $(CRIU_SO)
|
||||
install: lib-c lib-py crit/crit lib/c/criu.pc.in
|
||||
$(E) " INSTALL " lib
|
||||
$(Q) mkdir -p $(DESTDIR)$(LIBDIR)
|
||||
$(Q) install -m 755 c/$(CRIU_SO) $(DESTDIR)$(LIBDIR)/$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR).$(CRIU_SO_VERSION_MINOR)
|
||||
$(Q) install -m 755 lib/c/$(CRIU_SO) $(DESTDIR)$(LIBDIR)/$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR).$(CRIU_SO_VERSION_MINOR)
|
||||
$(Q) ln -fns $(CRIU_SO).$(CRIU_SO_VERSION_MAJOR).$(CRIU_SO_VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR)
|
||||
$(Q) ln -fns $(CRIU_SO).$(CRIU_SO_VERSION_MAJOR).$(CRIU_SO_VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(CRIU_SO)
|
||||
$(Q) mkdir -p $(DESTDIR)$(INCLUDEDIR)/criu/
|
||||
$(Q) install -m 644 $(UAPI_HEADERS) $(DESTDIR)$(INCLUDEDIR)/criu/
|
||||
$(E) " INSTALL " pkgconfig/criu.pc
|
||||
$(Q) mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
|
||||
$(Q) sed -e 's,@version@,$(CRIU_VERSION),' -e 's,@libdir@,$(LIBDIR),' -e 's,@includedir@,$(dir $(INCLUDEDIR)/criu/),' c/criu.pc.in > c/criu.pc
|
||||
$(Q) install -m 644 c/criu.pc $(DESTDIR)$(LIBDIR)/pkgconfig
|
||||
$(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 --root=$(DESTDIR) --prefix=$(PREFIX) --record $(CRIT_SETUP_FILES)
|
||||
$(Q) $(PYTHON_BIN) scripts/crit-setup.py install --root=$(DESTDIR) --prefix=$(PREFIX) --record $(CRIT_SETUP_FILES)
|
||||
.PHONY: install
|
||||
|
||||
uninstall:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
all: images rpc_pb2.py
|
||||
all-y += libpy-images rpc_pb2.py
|
||||
|
||||
.PHONY: all images clean
|
||||
.PHONY: .FORCE
|
||||
|
||||
images:
|
||||
$(Q) $(MAKE) -C images all
|
||||
$(obj)/images/%: .FORCE
|
||||
$(Q) $(MAKE) $(build)=$(obj)/images $@
|
||||
|
||||
libpy-images:
|
||||
$(Q) $(MAKE) $(build)=$(obj)/images all
|
||||
.PHONY: libpy-images
|
||||
|
||||
rpc_pb2.py:
|
||||
$(Q) protoc -I=$(SRC_DIR)/images/ --python_out=./ $(SRC_DIR)/images/$(@:_pb2.py=.proto)
|
||||
$(Q) protoc -I=$(SRC_DIR)/images/ --python_out=$(obj) $(SRC_DIR)/images/$(@:_pb2.py=.proto)
|
||||
|
||||
clean:
|
||||
$(Q) $(MAKE) -C images clean
|
||||
$(Q) $(RM) rpc_pb2.py *.pyc
|
||||
cleanup-y += $(addprefix $(obj)/,rpc_pb2.py *.pyc)
|
||||
|
||||
clean-lib-py:
|
||||
$(Q) $(MAKE) $(build)=$(obj)/images clean
|
||||
.PHONY: clean-lib-py
|
||||
clean: clean-lib-py
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
include $(__nmk_dir)msg.mk
|
||||
all: pb.py images magic.py
|
||||
|
||||
.PHONY: all images clean pb.py
|
||||
all-y += images magic.py pb.py
|
||||
|
||||
proto := $(filter-out $(SRC_DIR)/images/rpc.proto, $(sort $(wildcard $(SRC_DIR)/images/*.proto)))
|
||||
proto-py-modules := $(foreach m,$(proto),$(subst -,_,$(notdir $(m:.proto=_pb2))))
|
||||
|
|
@ -10,17 +7,19 @@ proto-py-modules := $(foreach m,$(proto),$(subst -,_,$(notdir $(m:.proto=_pb2)))
|
|||
# Unfortunately, we can't drop ugly _pb2 suffixes here, because
|
||||
# some _pb2 files depend on others _pb2 files.
|
||||
images:
|
||||
$(Q) protoc -I=$(SRC_DIR)/images -I=/usr/include/ --python_out=./ $(proto)
|
||||
$(Q) protoc -I=$(SRC_DIR)/images -I=/usr/include/ --python_out=$(obj) $(proto)
|
||||
.PHONY: images
|
||||
|
||||
magic.py: $(SRC_DIR)/scripts/magic-gen.py $(SRC_DIR)/criu/include/magic.h
|
||||
$(call msg-gen, $@)
|
||||
$(Q) python $^ $@
|
||||
$(Q) python $^ $(obj)/$@
|
||||
|
||||
pb.py: images
|
||||
$(Q) echo "# Autogenerated. Do not edit!" > $@
|
||||
$(Q) echo "# Autogenerated. Do not edit!" > $(obj)/$@
|
||||
$(Q) for m in $(proto-py-modules); do \
|
||||
echo "from $$m import *" >> $@ ;\
|
||||
echo "from $$m import *" >> $(obj)/$@ ;\
|
||||
done
|
||||
.PHONY: pb.py
|
||||
|
||||
clean:
|
||||
$(Q) $(RM) ./*_pb2.py ./*.pyc magic.py pb.py
|
||||
cleanup-y += $(addprefix $(obj)/,magic.py pb.py *.pyc)
|
||||
cleanup-y += $(call cleanify,$(addprefix $(obj)/,$(addsuffix .py,$(proto-py-modules))))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ setup(name = "crit",
|
|||
author = "CRIU team",
|
||||
author_email = "criu@openvz.org",
|
||||
url = "https://github.com/xemul/criu",
|
||||
package_dir = {'pycriu': 'py'},
|
||||
package_dir = {'pycriu': 'lib/py'},
|
||||
packages = ["pycriu", "pycriu.images"],
|
||||
scripts = ["../crit/crit"]
|
||||
scripts = ["crit/crit"]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue