Commit 78e9d59f authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Clean up descending into subdirs

Rules.make now has three targets:
o default (a.k.a first_rule): The actual build. Deciding whether
  to build built-in or modular or both is decided by
  $(KBUILD_MODULES) and $(KBUILD_BUILTIN) now, instead of using
  different targets
o fastdep: doesn't actually dependencies anymore, only generates
  modversions
o modules_install: Well, you guess what that does.

Cleaned up descending, and no more differentiating between 
$(subdir-y) and $(subdir-m). That means $(mod-subdirs) can
go away now.
parent 81e93fe6
...@@ -46,6 +46,13 @@ all: vmlinux ...@@ -46,6 +46,13 @@ all: vmlinux
#KBUILD_VERBOSE := 1 #KBUILD_VERBOSE := 1
# Decide whether to build built-in, modular, or both
KBUILD_MODULES :=
KBUILD_BUILTIN := 1
export KBUILD_MODULES KBUILD_BUILTIN
# Beautify output # Beautify output
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
...@@ -379,11 +386,8 @@ MODFLAGS += -include $(HPATH)/linux/modversions.h ...@@ -379,11 +386,8 @@ MODFLAGS += -include $(HPATH)/linux/modversions.h
endif endif
.PHONY: modules .PHONY: modules
modules: $(patsubst %, _mod_%, $(SUBDIRS)) modules:
@$(MAKE) KBUILD_BUILTIN= KBUILD_MODULES=1 $(SUBDIRS)
.PHONY: $(patsubst %, _mod_%, $(SUBDIRS))
$(patsubst %, _mod_%, $(SUBDIRS)) : include/linux/version.h include/config/MARKER
@$(MAKE) -C $(patsubst _mod_%, %, $@) modules
# Install modules # Install modules
......
...@@ -52,9 +52,8 @@ obj-m := $(filter-out %/, $(obj-m)) ...@@ -52,9 +52,8 @@ obj-m := $(filter-out %/, $(obj-m))
# add it to $(subdir-m) # add it to $(subdir-m)
both-m := $(filter $(mod-subdirs), $(subdir-y)) both-m := $(filter $(mod-subdirs), $(subdir-y))
SUB_DIRS := $(subdir-y) $(if $(BUILD_MODULES),$(subdir-m)) subdir-ym := $(sort $(subdir-y) $(subdir-m))
MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m)) subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-))
# export.o is never a composite object, since $(export-objs) has a # export.o is never a composite object, since $(export-objs) has a
# fixed meaning (== objects which EXPORT_SYMBOL()) # fixed meaning (== objects which EXPORT_SYMBOL())
...@@ -89,8 +88,16 @@ real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m ...@@ -89,8 +88,16 @@ real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m
# Get things started. # Get things started.
# ========================================================================== # ==========================================================================
ifndef O_TARGET
ifndef L_TARGET
O_TARGET := built-in.o
endif
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: vmlinux $(if $(BUILD_MODULES),$(obj-m)) first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
sub_dirs
@echo -n @echo -n
# Compile C sources (.c) # Compile C sources (.c)
...@@ -169,17 +176,9 @@ cmd_as_o_S = $(CC) -Wp,-MD,.$(subst /,_,$@).d $(a_flags) -c -o $@ $< ...@@ -169,17 +176,9 @@ cmd_as_o_S = $(CC) -Wp,-MD,.$(subst /,_,$@).d $(a_flags) -c -o $@ $<
# If a Makefile does define neither O_TARGET nor L_TARGET, # If a Makefile does define neither O_TARGET nor L_TARGET,
# use a standard O_TARGET named "built-in.o" # use a standard O_TARGET named "built-in.o"
ifndef O_TARGET
ifndef L_TARGET
O_TARGET := built-in.o
endif
endif
# Build the compiled-in targets # Build the compiled-in targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
vmlinux: $(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS) sub_dirs
# 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)): sub_dirs ;
...@@ -225,61 +224,48 @@ $(multi-used-y) : %.o: $(multi-objs-y) FORCE ...@@ -225,61 +224,48 @@ $(multi-used-y) : %.o: $(multi-objs-y) FORCE
$(multi-used-m) : %.o: $(multi-objs-m) FORCE $(multi-used-m) : %.o: $(multi-objs-m) FORCE
$(call if_changed,cmd_link_multi) $(call if_changed,cmd_link_multi)
# # Descending when making module versions
# This makes module versions # ---------------------------------------------------------------------------
#
fastdep: FORCE fastdep-list := $(addprefix _sfdep_,$(subdir-ymn))
ifdef ALL_SUB_DIRS
@$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)" .PHONY: fastdep $(fastdep-list)
endif
fastdep: $(fastdep-list)
ifdef _FASTDEP_ALL_SUB_DIRS $(fastdep-list):
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
@$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep @$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
endif
# Descending when building
# ---------------------------------------------------------------------------
# subdir-list := $(addprefix _subdir_,$(subdir-ym))
# A rule to make subdirectories
# .PHONY: sub_dirs $(subdir-list)
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
sub_dirs: FORCE $(subdir-list)
ifdef SUB_DIRS sub_dirs: $(subdir-list)
$(subdir-list) : FORCE
$(subdir-list):
@$(MAKE) -C $(patsubst _subdir_%,%,$@) @$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif
# # Descending and installing modules
# A rule to make modules # ---------------------------------------------------------------------------
#
ifneq "$(strip $(MOD_SUB_DIRS))" ""
.PHONY: $(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS))
$(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS)) : FORCE
@$(MAKE) -C $(patsubst _modsubdir_%,%,$@) modules
.PHONY: $(patsubst %,_modinst_%,$(MOD_SUB_DIRS)) modinst-list := $(addprefix _modinst_,$(subdir-ym))
$(patsubst %,_modinst_%,$(MOD_SUB_DIRS)) : FORCE
@$(MAKE) -C $(patsubst _modinst_%,%,$@) modules_install
endif
.PHONY: modules .PHONY: modules_install _modinst_ $(modinst-list)
modules: $(obj-m) FORCE $(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS))
@echo -n
.PHONY: _modinst__ modules_install: $(modinst-list)
_modinst__: FORCE ifneq ($(obj-m),)
ifneq "$(strip $(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)
endif else
.PHONY: modules_install
modules_install: _modinst__ $(patsubst %,_modinst_%,$(MOD_SUB_DIRS))
@echo -n @echo -n
endif
$(modinst-list):
@$(MAKE) -C $(patsubst _modinst_%,%,$@) modules_install
# 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.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
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