Commit 36a805ed authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Add EXTRA_TARGETS variable

99% of the Makefiles are very simple target-wise:

o build modules as listed in $(obj-m) and 
o build $(L_TARGET)/$(O_TARGET) as a composite object containing $(obj-y)

However, there is one exception: typically arch/$ARCH/kernel Makefile
wants the same as above, plus
o build init_task.o, head.o, using the standard rules for built-in
  targets - i.e. they are supposed to be built in the same way as all
  the other targets listed in $(obj-y), but they should not be linked
  into arch/$ARCH/kernel/$(O_TARGET). Instead they'll be linked in
  directly in the final vmlinux link.

Currently this is achieved by overriding Rules.make's first_rule in 
arch/$ARCH/kernel/Makefile. This rather ad-hoc way relies on the knowing
how Rules.make works internally and at the same time does things behind
Rules.make's back. 

To clean this up, I'm introducing a new variable, supposed to be only
used in arch/$ARCH/kernel/Makefile:

$(EXTRA_TARGETS) can be used to declare additional objects which shall
be built in the current directory (using the flags for built-in objects),
but not linked into $(O_TARGET)/$(L_TARGET)

This patch only converts arch/i386/kernel/Makefile at this time, other
archs work the same way as before.

Apart from this, this patch also removes some "unexport ..." statements,
which are unnecessary since not exporting variables is the default and
renames the internal "all_targets" to "vmlinux", since it's actually
need for building vmlinux.
parent c7355265
...@@ -2,30 +2,6 @@ ...@@ -2,30 +2,6 @@
# This file contains rules which are shared between multiple Makefiles. # This file contains rules which are shared between multiple Makefiles.
# #
#
# Special variables which should not be exported
#
unexport EXTRA_AFLAGS
unexport EXTRA_CFLAGS
unexport EXTRA_LDFLAGS
unexport EXTRA_ARFLAGS
unexport SUBDIRS
unexport SUB_DIRS
unexport ALL_SUB_DIRS
unexport MOD_SUB_DIRS
unexport O_TARGET
unexport obj-y
unexport obj-m
unexport obj-n
unexport obj-
unexport export-objs
unexport subdir-y
unexport subdir-m
unexport subdir-n
unexport subdir-
unexport mod-subdirs
# Some standard vars # Some standard vars
comma := , comma := ,
...@@ -107,14 +83,14 @@ multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs))) ...@@ -107,14 +83,14 @@ multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)))
subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
# Replace multi-part objects by their individual parts, look at local dir only # Replace multi-part objects by their individual parts, look at local dir only
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) $(EXTRA_TARGETS)
real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
# ========================================================================== # ==========================================================================
# #
# Get things started. # Get things started.
# #
first_rule: all_targets first_rule: vmlinux
# #
# Common rules # Common rules
...@@ -197,7 +173,7 @@ endif ...@@ -197,7 +173,7 @@ endif
# Build the compiled-in targets # Build the compiled-in targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
all_targets: $(O_TARGET) $(L_TARGET) sub_dirs 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 ;
...@@ -282,8 +258,7 @@ $(patsubst %,_modinst_%,$(MOD_SUB_DIRS)) : FORCE ...@@ -282,8 +258,7 @@ $(patsubst %,_modinst_%,$(MOD_SUB_DIRS)) : FORCE
endif endif
.PHONY: modules .PHONY: modules
modules: $(obj-m) FORCE \ modules: $(obj-m) FORCE $(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS))
$(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS))
.PHONY: _modinst__ .PHONY: _modinst__
_modinst__: FORCE _modinst__: FORCE
...@@ -293,8 +268,7 @@ ifneq "$(strip $(obj-m))" "" ...@@ -293,8 +268,7 @@ ifneq "$(strip $(obj-m))" ""
endif endif
.PHONY: modules_install .PHONY: modules_install
modules_install: _modinst__ \ modules_install: _modinst__ $(patsubst %,_modinst_%,$(MOD_SUB_DIRS))
$(patsubst %,_modinst_%,$(MOD_SUB_DIRS))
# 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.
......
# #
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definitions are now in the main makefile...
EXTRA_AFLAGS := -traditional
all: kernel.o head.o init_task.o EXTRA_TARGETS := head.o init_task.o
O_TARGET := kernel.o O_TARGET := kernel.o
...@@ -36,4 +29,6 @@ obj-y += setup-visws.o ...@@ -36,4 +29,6 @@ obj-y += setup-visws.o
obj-$(CONFIG_X86_VISWS_APIC) += visws_apic.o obj-$(CONFIG_X86_VISWS_APIC) += visws_apic.o
endif endif
EXTRA_AFLAGS := -traditional
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
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