diff --git a/Makefile b/Makefile index 32fb75d65..1d5f37160 100644 --- a/Makefile +++ b/Makefile @@ -135,19 +135,25 @@ lib: criu all: criu lib .PHONY: all -clean-built: - $(Q) $(MAKE) $(build)=images clean - $(Q) $(MAKE) -C criu clean +subclean: + $(call msg-clean, criu) $(Q) $(MAKE) -C lib clean $(Q) $(MAKE) -C Documentation clean -.PHONY: clean-built + $(Q) $(RM) .gitid +.PHONY: subclean -clean: clean-built - $(call msg-clean, criu) +clean: subclean + $(Q) $(MAKE) $(build)=images $@ + $(Q) $(MAKE) -C criu $@ +.PHONY: clean + +# mrproper depends on clean in nmk +mrproper: subclean + $(Q) $(MAKE) $(build)=images $@ + $(Q) $(MAKE) -C criu $@ $(Q) $(RM) cscope.* $(Q) $(RM) tags TAGS - $(Q) $(RM) .gitid -.PHONY: clean +.PHONY: mrproper # # Non-CRIU stuff. @@ -224,7 +230,8 @@ help: @echo ' docs - Build documentation' @echo ' install - Install binary and man page' @echo ' dist - Create a source tarball' - @echo ' clean - Clean everything' + @echo ' clean - Clean most, but leave enough to navigate' + @echo ' mrproper - Delete all compiled/generated files' @echo ' tags - Generate tags file (ctags)' @echo ' etags - Generate TAGS file (etags)' @echo ' cscope - Generate cscope database' diff --git a/criu/Makefile b/criu/Makefile index 25d75dfd7..0380295a9 100644 --- a/criu/Makefile +++ b/criu/Makefile @@ -85,6 +85,7 @@ REQ-DEV-PKG-TEST-NAMES += libcap-dev # # Make sure all required libs are installed ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),mrproper) ifneq ($(shell sh -c \ 'TMP="$(OUTPUT)$(TMPOUT).$$$$"; \ echo "int main(int argc, char *argv[]) { return 0; }" | \ @@ -100,6 +101,7 @@ ifneq ($(MAKECMDGOALS),clean) $(error "Compilation aborted") endif endif +endif ifeq ($(GMON),1) CFLAGS += -pg GMONLDOPT := -pg @@ -177,22 +179,36 @@ criu: $(PROGRAM-BUILTINS) $(call msg-link, $@) $(Q) $(CC) $(CFLAGS) $^ $(ARCH-LIB) $(LIBS) $(LDFLAGS) $(GMONLDOPT) -rdynamic -o $@ + +subclean: + $(Q) $(RM) ./*.{gcda,gcno,gcov} + $(Q) $(RM) ./pie/*.{gcda,gcno,gcov} + $(Q) $(RM) ./pie/piegen/*.{gcda,gcno,gcov} + $(Q) $(RM) -r ./gcov + $(Q) $(RM) criu +.PHONY: subclean + # -# Cleanup everything. -clean: +# Clean the most, except generated c files +clean: subclean + $(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) $@ + $(Q) $(MAKE) $(call build-as,Makefile.library,pie) $@ + $(Q) $(MAKE) $(call build-as,Makefile.crtools,.) $@ + $(Q) $(MAKE) $(build)=pie/piegen $@ + $(Q) $(MAKE) $(build)=pie $@ +.PHONY: clean + +# +# Delete all generated files +mrproper: subclean $(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) $@ $(Q) $(MAKE) $(call build-as,Makefile.library,pie) $@ $(Q) $(MAKE) $(call build-as,Makefile.crtools,.) $@ $(Q) $(MAKE) $(build)=pie/piegen $@ $(Q) $(MAKE) $(build)=pie $@ - $(Q) $(RM) ./*.{gcda,gcno,gcov} - $(Q) $(RM) ./pie/*.{gcda,gcno,gcov} - $(Q) $(RM) ./pie/piegen/*.{gcda,gcno,gcov} - $(Q) $(RM) -r ./gcov $(Q) $(RM) $(VERSION_HEADER) $(Q) $(RM) $(CONFIG_HEADER) - $(Q) $(RM) criu -.PHONY: clean +.PHONY: mrproper UAPI_HEADERS := include/criu-plugin.h include/criu-log.h diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools index 44480479b..ef152d218 100644 --- a/criu/Makefile.crtools +++ b/criu/Makefile.crtools @@ -89,4 +89,4 @@ protobuf-desc-gen.h: $(PROTOBUF_GEN) include/protobuf-desc.h $(call msg-gen, $@) $(Q) $(SH) $(PROTOBUF_GEN) > $@ -cleanup-y += protobuf-desc-gen.h +mrproper-y += protobuf-desc-gen.h diff --git a/criu/arch/aarch64/Makefile.syscalls b/criu/arch/aarch64/Makefile.syscalls index 4fc185bf5..cef3f95dc 100644 --- a/criu/arch/aarch64/Makefile.syscalls +++ b/criu/arch/aarch64/Makefile.syscalls @@ -47,6 +47,6 @@ $(obj)/$(SYS-EXEC-TBL): $(obj)/$(SYS-GEN-TBL) $(obj)/syscalls/$(SYS-DEF) all-y += $(obj)/$(SYS-EXEC-TBL) -cleanup-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM) -cleanup-y += $(obj)/$(SYS-CODES) -cleanup-y += $(obj)/$(SYS-PROTO) +mrproper-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM) +mrproper-y += $(obj)/$(SYS-CODES) +mrproper-y += $(obj)/$(SYS-PROTO) diff --git a/criu/arch/arm/Makefile.syscalls b/criu/arch/arm/Makefile.syscalls index 431d69005..c5d1178fb 100644 --- a/criu/arch/arm/Makefile.syscalls +++ b/criu/arch/arm/Makefile.syscalls @@ -47,6 +47,6 @@ $(obj)/$(SYS-EXEC-TBL): $(obj)/$(SYS-GEN-TBL) $(obj)/syscalls/$(SYS-DEF) all-y += $(obj)/$(SYS-EXEC-TBL) -cleanup-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM) -cleanup-y += $(obj)/$(SYS-CODES) -cleanup-y += $(obj)/$(SYS-PROTO) +mrproper-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM) +mrproper-y += $(obj)/$(SYS-CODES) +mrproper-y += $(obj)/$(SYS-PROTO) diff --git a/criu/arch/ppc64/Makefile.syscalls b/criu/arch/ppc64/Makefile.syscalls index 1a374e331..979741a87 100644 --- a/criu/arch/ppc64/Makefile.syscalls +++ b/criu/arch/ppc64/Makefile.syscalls @@ -24,7 +24,7 @@ $(obj)/$(SYS-CODES): $(obj)/syscalls/$(SYS-DEF) 'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\ 'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}' >> $@ $(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@ -cleanup-y += $(obj)/$(SYS-CODES) +mrproper-y += $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO): $(obj)/syscalls/$(SYS-DEF) $(E) " GEN " $@ @@ -35,7 +35,7 @@ $(obj)/$(SYS-PROTO): $(obj)/syscalls/$(SYS-DEF) $(Q) echo "#include \"syscall-types.h\"" >> $@ $(Q) cat $< | awk '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}' >> $@ $(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@ -cleanup-y += $(obj)/$(SYS-PROTO) +mrproper-y += $(obj)/$(SYS-PROTO) $(obj)/$(SYS-ASM): $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON) $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO) $(E) " GEN " $@ @@ -43,12 +43,12 @@ $(obj)/$(SYS-ASM): $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON) $(Q) echo "#include \"syscall-codes.h\"" >> $@ $(Q) echo "#include \"syscalls/$(SYS-ASM-COMMON)\"" >> $@ $(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}' >> $@ -cleanup-y += $(obj)/$(SYS-ASM) +mrproper-y += $(obj)/$(SYS-ASM) SYS-EXEC-TBL := sys-exec-tbl.c $(obj)/$(SYS-EXEC-TBL): $(obj)/syscalls/$(SYS-DEF) $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO) $(E) " GEN " $@ $(Q) echo "/* Autogenerated, don't edit */" > $@ $(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}' >> $@ -cleanup-y += $(obj)/$(SYS-EXEC-TBL) +mrproper-y += $(obj)/$(SYS-EXEC-TBL) all-y += $(obj)/$(SYS-EXEC-TBL) diff --git a/criu/arch/x86/Makefile.syscalls b/criu/arch/x86/Makefile.syscalls index ba67e39e1..a2c509df6 100644 --- a/criu/arch/x86/Makefile.syscalls +++ b/criu/arch/x86/Makefile.syscalls @@ -35,7 +35,7 @@ $(obj)/$(SYS-CODES): $(obj)/syscalls/$(SYS-DEF) 'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\ 'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}' >> $@ $(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@ -cleanup-y += $(obj)/$(SYS-CODES) +mrproper-y += $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO): $(obj)/syscalls/$(SYS-DEF) $(call msg-gen, $@) @@ -52,7 +52,7 @@ ifneq ($(ARCH),x86) endif $(Q) cat $< | awk '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}' >> $@ $(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@ -cleanup-y += $(obj)/$(SYS-PROTO) +mrproper-y += $(obj)/$(SYS-PROTO) $(obj)/$(SYS-ASM): $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON) $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO) $(call msg-gen, $@) @@ -60,12 +60,12 @@ $(obj)/$(SYS-ASM): $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON) $(Q) echo "#include \"syscall-codes.h\"" >> $@ $(Q) echo "#include \"syscalls/$(SYS-ASM-COMMON)\"" >> $@ $(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}' >> $@ -cleanup-y += $(obj)/$(SYS-ASM) +mrproper-y += $(obj)/$(SYS-ASM) SYS-EXEC-TBL := sys-exec-tbl.c $(obj)/$(SYS-EXEC-TBL): $(obj)/syscalls/$(SYS-DEF) $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO) $(call msg-gen, $@) $(Q) echo "/* Autogenerated, don't edit */" > $@ $(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}' >> $@ -cleanup-y += $(obj)/$(SYS-EXEC-TBL) +mrproper-y += $(obj)/$(SYS-EXEC-TBL) all-y += $(obj)/$(SYS-EXEC-TBL) diff --git a/criu/pie/Makefile b/criu/pie/Makefile index b455a02a6..c125e8c40 100644 --- a/criu/pie/Makefile +++ b/criu/pie/Makefile @@ -96,8 +96,10 @@ endif $(BLOBS): $(obj)/$(PIELDS) all-y += $(BLOBS) +# blobs and pields are in cleanup, rather than in mrproper because +# we want them to be re-generated after `make clean && make` +cleanup-y += $(BLOBS) cleanup-y += $(obj)/$(PIELDS) cleanup-y += $(obj)/*.bin -cleanup-y += $(BLOBS) cleanup-y += $(obj)/*.built-in.bin.o cleanup-y += $(obj)/*.built-in.bin diff --git a/criu/pie/piegen/Makefile b/criu/pie/piegen/Makefile index 5c3d68b84..0af489070 100644 --- a/criu/pie/piegen/Makefile +++ b/criu/pie/piegen/Makefile @@ -13,5 +13,7 @@ cleanup-y += $(obj)/piegen cleanup-y += $(obj)/*.o ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),mrproper) incdeps := y endif +endif diff --git a/images/Makefile b/images/Makefile index 16ecb6ab5..4ced69988 100644 --- a/images/Makefile +++ b/images/Makefile @@ -102,10 +102,13 @@ $(obj)/built-in.o: $(addprefix $(obj)/,$(proto-obj-y)) $(Q) $(LD) $(ldflags-y) -r -o $@ $^ ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),mrproper) -include $(addprefix $(obj)/,$(proto-obj-y:.o=.pb-c.d)) endif +endif -cleanup-y += $(obj)/*.c.d $(obj)/*.pb-c.c $(obj)/*.pb-c.h +mrproper-y += $(obj)/*.pb-c.c $(obj)/*.pb-c.h +cleanup-y += $(obj)/*.c.d cleanup-y += $(obj)/google/protobuf/*.d cleanup-y += $(obj)/google/protobuf/*.h cleanup-y += $(obj)/google/protobuf/*.c