From cb56ef33764ffe503aa1e1a0848ae097e200d954 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 16 Oct 2002 12:10:27 -0500 Subject: kbuild: Speed up new "make clean/mrproper" Do as little as possible apart from calling sub-makes and calling 'rm', which makes things go quite a bit faster. --- Makefile | 4 ++-- Rules.make | 5 +++++ scripts/Makefile.clean | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 scripts/Makefile.clean diff --git a/Makefile b/Makefile index 388e62bb287b..06c5c12b104d 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump -MAKEFILES = .config +#MAKEFILES = .config GENKSYMS = /sbin/genksyms DEPMOD = /sbin/depmod KALLSYMS = /sbin/kallsyms @@ -698,7 +698,7 @@ MRPROPER_DIRS += \ clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts $(addprefix _clean_,$(clean-dirs)): - +@$(call descend,$(patsubst _clean_%,%,$@), subdirclean) + $(MAKE) -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) quiet_cmd_rmclean = RM $$(CLEAN_FILES) cmd_rmclean = rm -f $(CLEAN_FILES) diff --git a/Rules.make b/Rules.make index 56e62f97f333..577f2c9ee83a 100644 --- a/Rules.make +++ b/Rules.make @@ -1,3 +1,6 @@ + +ifndef no-rules.make + # # This file contains rules which are shared between multiple Makefiles. # @@ -623,3 +626,5 @@ ifeq ($(KBUILD_VERBOSE),1) descend = echo '$(MAKE) -f $(1)/Makefile $(2)'; endif descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2) + +endif diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean new file mode 100644 index 000000000000..fa809a7e88ad --- /dev/null +++ b/scripts/Makefile.clean @@ -0,0 +1,42 @@ + +src := $(obj) + +no-rules.make := 1 + +.PHONY: __clean +__clean: + +include $(obj)/Makefile + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +__subdir-n := $(patsubst %/,%,$(filter %/, $(obj-n))) +subdir-n += $(__subdir-n) +__subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) +subdir- += $(__subdir-) + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) +subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) + +EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) +clean-files := $(addprefix $(obj)/,$(clean-files)) +host-progs := $(addprefix $(obj)/,$(host-progs)) +subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) + +__clean-files := $(wildcard $(EXTRA_TARGETS) $(host-progs) $(clean-files)) + +__clean: $(subdir-ymn) +ifneq ($(strip $(__clean-files) $(clean-rule)),) + rm -f $(__clean-files) + $(clean-rule) +else + @/bin/true +endif + +.PHONY: $(subdir-ymn) + +$(subdir-ymn): + $(MAKE) -rR -f scripts/Makefile.clean obj=$@ + -- cgit v1.2.3 From 6d65aab5bb3bbc05f280b4a49268982dfa76c2e1 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 16 Oct 2002 12:11:54 -0500 Subject: kbuild: More "make clean" cosmetics Make the DocBook "make clean" output nicer and use the fast variant for arch/i386/boot as well. --- Documentation/DocBook/Makefile | 5 +++-- arch/i386/Makefile | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 2e3a7333354e..dd49e638acd7 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -160,7 +160,8 @@ clean-files := $(DOCBOOKS) \ $(patsubst %.fig,%.png, $(IMG-parportbook)) \ $(C-procfs-example) -clean-rule := rm -rf $(patsubst %.html,%,$(HTML)) +ifneq ($(wildcard $(BOOKS)),) +clean-rule := rm -rf $(wildcard $(BOOKS)) +endif include $(TOPDIR)/Rules.make - diff --git a/arch/i386/Makefile b/arch/i386/Makefile index dbd363bdb52f..f23a066d98d8 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -88,6 +88,6 @@ install: vmlinux +@$(call makeboot,BOOTIMAGE=$(BOOTIMAGE) install) archclean: - +@$(call makeboot,subdirclean) + $(MAKE) -rR -f scripts/Makefile.clean obj=arch/i386/boot archmrproper: -- cgit v1.2.3 From 366b173e7136fe4ac6fd252fffec648a5cbf3181 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 16 Oct 2002 12:17:35 -0500 Subject: kbuild: another "make clean" micro-optimization Patch by Peter Samuelson, merged to current code, actually has a noticable impact on "make clean" speed. --- Rules.make | 19 +++++++------------ scripts/Makefile.clean | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Rules.make b/Rules.make index 577f2c9ee83a..9343c984a820 100644 --- a/Rules.make +++ b/Rules.make @@ -166,7 +166,7 @@ ifneq ($(strip $(__clean-files) $(clean-rule)),) rm -f $(__clean-files) $(clean-rule) else - @/bin/true + @: endif else @@ -182,7 +182,7 @@ ifeq ($(strip $(export-objs)),) # --------------------------------------------------------------------------- fastdep: $(subdir-ym) - @/bin/true + @: else @@ -274,7 +274,7 @@ modules_install: $(subdir-ym) ifneq ($(obj-m),) $(call cmd,modules_install) else - @/bin/true + @: endif else # ! modules_install @@ -283,23 +283,18 @@ else # ! modules_install # Building # ========================================================================== -# If a Makefile does define neither O_TARGET nor L_TARGET, -# use a standard O_TARGET named "built-in.o" - -ifndef O_TARGET -ifndef L_TARGET -O_TARGET := $(obj)/built-in.o -endif -endif +# If a Makefile does not define a L_TARGET, link an object called "built-in.o" ifdef L_TARGET L_TARGET := $(obj)/$(L_TARGET) +else +O_TARGET := $(obj)/built-in.o endif first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ $(if $(KBUILD_MODULES),$(obj-m)) \ $(subdir-ym) - @/bin/true + @: # Compile C sources (.c) # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index fa809a7e88ad..d7bb2dfb88d8 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -32,7 +32,7 @@ ifneq ($(strip $(__clean-files) $(clean-rule)),) rm -f $(__clean-files) $(clean-rule) else - @/bin/true + @: endif .PHONY: $(subdir-ymn) -- cgit v1.2.3 From 2cec3daac2214432db7052d725fcca1e5dec863b Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 16 Oct 2002 23:15:21 -0500 Subject: kbuild: Fix temporary hack We don't need to include .config for "make clean", but we sure do otherwise... (pointed out by Sam Ravnborg) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 06c5c12b104d..17c619c35339 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump -#MAKEFILES = .config +MAKEFILES = .config GENKSYMS = /sbin/genksyms DEPMOD = /sbin/depmod KALLSYMS = /sbin/kallsyms @@ -698,7 +698,7 @@ MRPROPER_DIRS += \ clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts $(addprefix _clean_,$(clean-dirs)): - $(MAKE) -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) + $(MAKE) MAKEFILES= -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) quiet_cmd_rmclean = RM $$(CLEAN_FILES) cmd_rmclean = rm -f $(CLEAN_FILES) -- cgit v1.2.3