Commit 7e2eee9e authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

build: add mrproper target

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@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 19bd013a
......@@ -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'
......
......@@ -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
......
......@@ -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
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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
......@@ -13,5 +13,7 @@ cleanup-y += $(obj)/piegen
cleanup-y += $(obj)/*.o
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),mrproper)
incdeps := y
endif
endif
......@@ -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
......
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