[CRIU] [RFC] [PATCH 2/2] build: add mrproper target

Dmitry Safonov dsafonov at virtuozzo.com
Fri Mar 18 03:09:33 PDT 2016


Each time I type `make clean` and find that my tags are cleaned
and generated headers/c-files are deleted, I'm getting annoyed.
Mostly it's about protobuf images definitions.
(And then I need to run `make` and `make tags` again which
is painful).

I think, we may separate clean process on two parts, just
like it's done in the kernel (omitting distclean):
 o Cleaning all binaries/objects, but leave enough to navigate
 o Clean everything compiled/generated/etc.

In this patch pie blobs are still deleted on clean stage - I may
fix it in the later patches.
(they _should_ be regenerated on `make clean && make`)

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 Makefile                            | 25 ++++++++++++++++---------
 criu/Makefile                       | 32 ++++++++++++++++++++++++--------
 criu/Makefile.crtools               |  2 +-
 criu/arch/aarch64/Makefile.syscalls |  6 +++---
 criu/arch/arm/Makefile.syscalls     |  6 +++---
 criu/arch/ppc64/Makefile.syscalls   |  8 ++++----
 criu/arch/x86/Makefile.syscalls     |  8 ++++----
 criu/pie/Makefile                   |  4 +++-
 criu/pie/piegen/Makefile            |  2 ++
 images/Makefile                     |  5 ++++-
 10 files changed, 64 insertions(+), 34 deletions(-)

diff --git a/Makefile b/Makefile
index 5b4dbf2..16b79b8 100644
--- a/Makefile
+++ b/Makefile
@@ -136,19 +136,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.
@@ -225,7 +231,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 25d75df..0380295 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 00e0d3e..d610d2f 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -94,4 +94,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 4fc185b..cef3f95 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 431d690..c5d1178 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 1a374e3..979741a 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 ba67e39..a2c509d 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 b455a02..c125e8c 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 5c3d68b..0af4890 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 ea0db79..aae6ed1 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -103,10 +103,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
-- 
2.7.2



More information about the CRIU mailing list