]> git.neil.brown.name Git - history.git/commitdiff
kbuild: Add EXTRA_TARGETS variable
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Tue, 28 May 2002 08:44:29 +0000 (03:44 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Tue, 28 May 2002 08:44:29 +0000 (03:44 -0500)
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.

Rules.make
arch/i386/kernel/Makefile

index bc18c7a017f88d3cbd9fed1a783fdeb131e31b61..95f2b210fb58c118289096807f8d1c925fabdf27 100644 (file)
@@ -2,30 +2,6 @@
 # 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
 
 comma   := ,
@@ -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)))
 
 # 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)))
 
 # ==========================================================================
 #
 # Get things started.
 #
-first_rule: all_targets
+first_rule: vmlinux
 
 #
 # Common rules
@@ -197,7 +173,7 @@ endif
 # 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
 $(sort $(subdir-obj-y)): sub_dirs ;
@@ -282,8 +258,7 @@ $(patsubst %,_modinst_%,$(MOD_SUB_DIRS)) : FORCE
 endif
 
 .PHONY: modules
-modules: $(obj-m) FORCE \
-        $(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS))
+modules: $(obj-m) FORCE $(patsubst %,_modsubdir_%,$(MOD_SUB_DIRS))
 
 .PHONY: _modinst__
 _modinst__: FORCE
@@ -293,8 +268,7 @@ ifneq "$(strip $(obj-m))" ""
 endif
 
 .PHONY: modules_install
-modules_install: _modinst__ \
-        $(patsubst %,_modinst_%,$(MOD_SUB_DIRS))
+modules_install: _modinst__ $(patsubst %,_modinst_%,$(MOD_SUB_DIRS))
 
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
index 85dea695d1c4432358ce1a5ddebf07b00d4c1712..9f534753206228f065e3bafb2c111a20373017f7 100644 (file)
@@ -1,15 +1,8 @@
 #
 # 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
 
@@ -36,4 +29,6 @@ obj-y += setup-visws.o
 obj-$(CONFIG_X86_VISWS_APIC)   += visws_apic.o
 endif
 
+EXTRA_AFLAGS   := -traditional
+
 include $(TOPDIR)/Rules.make