Commit 83a26d41 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Small cleanups

o Use a function "descend" for descending into subdirectories
o Remove unused (?) "boot" target
o Remove unnecessary intermediate "sub_dirs" target from Rules.make
o Use /bin/true instead of echo -n to suppress spurious
  "nothing to be done for ..." output from make
parent e14956f3
...@@ -52,13 +52,6 @@ CROSS_COMPILE = ...@@ -52,13 +52,6 @@ CROSS_COMPILE =
all: vmlinux all: vmlinux
# Print entire command lines instead of short version
# For now, leave the default
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 1
endif
# Decide whether to build built-in, modular, or both. # Decide whether to build built-in, modular, or both.
# Normally, just do built-in. # Normally, just do built-in.
...@@ -105,6 +98,12 @@ export KBUILD_MODULES KBUILD_BUILTIN ...@@ -105,6 +98,12 @@ export KBUILD_MODULES KBUILD_BUILTIN
# If it is set to "silent_", nothing wil be printed at all, since # If it is set to "silent_", nothing wil be printed at all, since
# the variable $(silent_cmd_cc_o_c) doesn't exist. # the variable $(silent_cmd_cc_o_c) doesn't exist.
# For now, leave verbose as default
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 1
endif
# If the user wants quiet mode, echo short versions of the commands # If the user wants quiet mode, echo short versions of the commands
# only and suppress the 'Entering/Leaving directory' messages # only and suppress the 'Entering/Leaving directory' messages
...@@ -120,7 +119,7 @@ ifneq ($(findstring s,$(MAKEFLAGS)),) ...@@ -120,7 +119,7 @@ ifneq ($(findstring s,$(MAKEFLAGS)),)
quiet=silent_ quiet=silent_
endif endif
export quiet export quiet KBUILD_VERBOSE
# #
# Include the make variables (CC, etc...) # Include the make variables (CC, etc...)
...@@ -183,7 +182,7 @@ scripts/docproc scripts/fixdep scripts/split-include : scripts ; ...@@ -183,7 +182,7 @@ scripts/docproc scripts/fixdep scripts/split-include : scripts ;
.PHONY: scripts .PHONY: scripts
scripts: scripts:
@$(MAKE) -C scripts @$(call descend,scripts,)
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
...@@ -276,12 +275,6 @@ LIBS += $(patsubst %/, %/lib.a, $(libs-y)) ...@@ -276,12 +275,6 @@ LIBS += $(patsubst %/, %/lib.a, $(libs-y))
export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT
# boot target
# ---------------------------------------------------------------------------
boot: vmlinux
@$(MAKE) -C arch/$(ARCH)/boot
# Build vmlinux # Build vmlinux
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -314,7 +307,7 @@ define rule_vmlinux ...@@ -314,7 +307,7 @@ define rule_vmlinux
echo ' Generating build number' echo ' Generating build number'
. scripts/mkversion > .tmp_version . scripts/mkversion > .tmp_version
mv -f .tmp_version .version mv -f .tmp_version .version
+$(MAKE) -C init +$(call descend,init,)
$(call cmd,link_vmlinux) $(call cmd,link_vmlinux)
echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd
$(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
...@@ -363,7 +356,7 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ; ...@@ -363,7 +356,7 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ;
.PHONY: $(SUBDIRS) .PHONY: $(SUBDIRS)
$(SUBDIRS): .hdepend prepare $(SUBDIRS): .hdepend prepare
@$(MAKE) -C $@ @$(call descend,$@,)
# Things we need done before we descend to build or make # Things we need done before we descend to build or make
# module versions are listed in "prepare" # module versions are listed in "prepare"
...@@ -386,17 +379,17 @@ targets += arch/$(ARCH)/vmlinux.lds.s ...@@ -386,17 +379,17 @@ targets += arch/$(ARCH)/vmlinux.lds.s
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
%.s: %.c FORCE %.s: %.c FORCE
@$(MAKE) -C $(@D) $(@F) @$(call descend,$(@D),$(@F))
%.i: %.c FORCE %.i: %.c FORCE
@$(MAKE) -C $(@D) $(@F) @$(call descend,$(@D),$(@F))
%.o: %.c FORCE %.o: %.c FORCE
@$(MAKE) -C $(@D) $(@F) @$(call descend,$(@D),$(@F))
%.lst: %.c FORCE %.lst: %.c FORCE
@$(MAKE) -C $(@D) $(@F) @$(call descend,$(@D),$(@F))
%.s: %.S FORCE %.s: %.S FORCE
@$(MAKE) -C $(@D) $(@F) @$(call descend,$(@D),$(@F))
%.o: %.S FORCE %.o: %.S FORCE
@$(MAKE) -C $(@D) $(@F) @$(call descend,$(@D),$(@F))
# FIXME: The asm symlink changes when $(ARCH) changes. That's # FIXME: The asm symlink changes when $(ARCH) changes. That's
# hard to detect, but I suppose "make mrproper" is a good idea # hard to detect, but I suppose "make mrproper" is a good idea
...@@ -481,7 +474,7 @@ include/linux/modversions.h: scripts/fixdep prepare FORCE ...@@ -481,7 +474,7 @@ include/linux/modversions.h: scripts/fixdep prepare FORCE
$(update-if-changed) $(update-if-changed)
$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE $(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE
@$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep @$(call descend,$(patsubst _sfdep_%,%,$@),fastdep)
else # !CONFIG_MODVERSIONS else # !CONFIG_MODVERSIONS
...@@ -533,7 +526,7 @@ _modinst_post: ...@@ -533,7 +526,7 @@ _modinst_post:
.PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
$(patsubst %, _modinst_%, $(SUBDIRS)) : $(patsubst %, _modinst_%, $(SUBDIRS)) :
@$(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install $(descend,$(patsubst _modinst_%,%,$@),modules_install)
else # CONFIG_MODULES else # CONFIG_MODULES
...@@ -631,11 +624,11 @@ ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -631,11 +624,11 @@ ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
make_with_config make_with_config
xconfig: xconfig:
@$(MAKE) -C scripts kconfig.tk @$(call descend,scripts,kconfig.tk)
wish -f scripts/kconfig.tk wish -f scripts/kconfig.tk
menuconfig: menuconfig:
@$(MAKE) -C scripts lxdialog @$(call descend,scripts,lxdialog)
$(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in
config: config:
...@@ -734,7 +727,7 @@ mrproper: clean archmrproper ...@@ -734,7 +727,7 @@ mrproper: clean archmrproper
-type f -print | xargs rm -f -type f -print | xargs rm -f
@rm -rf $(MRPROPER_DIRS) @rm -rf $(MRPROPER_DIRS)
@rm -f $(MRPROPER_FILES) @rm -f $(MRPROPER_FILES)
@$(MAKE) -C scripts mrproper @$(call descend,scripts,mrproper)
@$(MAKE) -f Documentation/DocBook/Makefile mrproper @$(MAKE) -f Documentation/DocBook/Makefile mrproper
distclean: mrproper distclean: mrproper
...@@ -909,5 +902,9 @@ define update-if-changed ...@@ -909,5 +902,9 @@ define update-if-changed
fi fi
endef endef
# $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target>
descend = $(MAKE) -C $(1) $(2)
FORCE: FORCE:
...@@ -136,8 +136,8 @@ ifeq ($(strip $(export-objs)),) ...@@ -136,8 +136,8 @@ ifeq ($(strip $(export-objs)),)
# If we don't export any symbols in this dir, just descend # If we don't export any symbols in this dir, just descend
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
fastdep: sub_dirs fastdep: $(subdir-ym)
@echo -n @/bin/true
else else
...@@ -206,7 +206,7 @@ $(MODVERDIR)/%.ver: %.c FORCE ...@@ -206,7 +206,7 @@ $(MODVERDIR)/%.ver: %.c FORCE
targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)) targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
fastdep: $(targets) sub_dirs fastdep: $(targets) $(subdir-ym)
@mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR) @mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver)) @touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))
...@@ -221,13 +221,13 @@ ifeq ($(MAKECMDGOALS),modules_install) ...@@ -221,13 +221,13 @@ ifeq ($(MAKECMDGOALS),modules_install)
.PHONY: modules_install .PHONY: modules_install
modules_install: sub_dirs modules_install: $(subdir-ym)
ifneq ($(obj-m),) ifneq ($(obj-m),)
@echo Installing modules in $(MODLIB)/kernel/$(RELDIR) @echo Installing modules in $(MODLIB)/kernel/$(RELDIR)
@mkdir -p $(MODLIB)/kernel/$(RELDIR) @mkdir -p $(MODLIB)/kernel/$(RELDIR)
@cp $(obj-m) $(MODLIB)/kernel/$(RELDIR) @cp $(obj-m) $(MODLIB)/kernel/$(RELDIR)
else else
@echo -n @/bin/true
endif endif
else # ! modules_install else # ! modules_install
...@@ -248,8 +248,8 @@ endif ...@@ -248,8 +248,8 @@ endif
# The echo suppresses the "Nothing to be done for first_rule" # The echo suppresses the "Nothing to be done for first_rule"
first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
$(if $(KBUILD_MODULES),$(obj-m)) \ $(if $(KBUILD_MODULES),$(obj-m)) \
sub_dirs $(subdir-ym)
@echo -n @/bin/true
# Compile C sources (.c) # Compile C sources (.c)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -324,7 +324,7 @@ targets += $(real-objs-y) $(real-objs-m) $(EXTRA_TARGETS) $(MAKECMDGOALS) ...@@ -324,7 +324,7 @@ targets += $(real-objs-y) $(real-objs-m) $(EXTRA_TARGETS) $(MAKECMDGOALS)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# To build objects in subdirs, we need to descend into the directories # To build objects in subdirs, we need to descend into the directories
$(sort $(subdir-obj-y)): sub_dirs ; $(sort $(subdir-obj-y)): $(subdir-ym) ;
# #
# Rule to compile a set of .o files into one .o file # Rule to compile a set of .o files into one .o file
...@@ -454,12 +454,10 @@ cmd_gzip = gzip -f -9 < $< > $@ ...@@ -454,12 +454,10 @@ cmd_gzip = gzip -f -9 < $< > $@
# Descending # Descending
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: sub_dirs $(subdir-ym) .PHONY: $(subdir-ym)
sub_dirs: $(subdir-ym)
$(subdir-ym): $(subdir-ym):
@$(MAKE) -C $@ $(MAKECMDGOALS) @$(call descend,$@,$(MAKECMDGOALS))
# Add FORCE to the prequisites of a target to force it to be always rebuilt. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -574,3 +572,8 @@ define do_cmd ...@@ -574,3 +572,8 @@ define do_cmd
$(2) $(2)
endef endef
# $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target>
descend = $(MAKE) -C $(1) $(2)
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