Commit 2c98ce0a authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Figure out flags independently from pass

We now have the information which objects are being built
modular / built-in in Rules.make, so use this information instead
of passing flags to the sub makes.
parent c43626f4
......@@ -172,7 +172,7 @@ export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS
# ---------------------------------------------------------------------------
boot: vmlinux
@$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C arch/$(ARCH)/boot
@$(MAKE) -C arch/$(ARCH)/boot
# Build vmlinux
# ---------------------------------------------------------------------------
......@@ -202,7 +202,7 @@ define rule_link_vmlinux
echo Generating build number
. scripts/mkversion > .tmpversion
mv -f .tmpversion .version
$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C init
$(MAKE) -C init
echo $(cmd_link_vmlinux)
$(cmd_link_vmlinux)
echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd
......@@ -212,11 +212,10 @@ endef
vmlinux: $(CONFIGURATION) $(vmlinux-objs) dummy
$(call if_changed_rule,link_vmlinux)
# The actual objects are generated when descending, make sure
# no implicit rule kicks in
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
$(sort $(vmlinux-objs)): linuxsubdirs
@
$(sort $(vmlinux-objs)): linuxsubdirs ;
# Handle descending into subdirectories listed in $(SUBDIRS)
......@@ -224,7 +223,7 @@ $(sort $(vmlinux-objs)): linuxsubdirs
linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/linux/version.h include/config/MARKER
@$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C $(patsubst _dir_%, %, $@)
@$(MAKE) -C $(patsubst _dir_%, %, $@)
# Configuration
# ---------------------------------------------------------------------------
......@@ -266,8 +265,6 @@ include/linux/version.h: ./Makefile
@echo Generating $@
@. scripts/mkversion_h $@ $(KERNELRELEASE) $(VERSION) $(PATCHLEVEL) $(SUBLEVEL)
comma := ,
# ---------------------------------------------------------------------------
# Generate dependencies
......@@ -296,7 +293,7 @@ modules: $(patsubst %, _mod_%, $(SUBDIRS))
.PHONY: $(patsubst %, _mod_%, $(SUBDIRS))
$(patsubst %, _mod_%, $(SUBDIRS)) : include/linux/version.h include/config/MARKER
@$(MAKE) -C $(patsubst _mod_%, %, $@) CFLAGS="$(CFLAGS) $(CFLAGS_MODULE)" AFLAGS="$(AFLAGS) $(AFLAGS_MODULE)" modules
@$(MAKE) -C $(patsubst _mod_%, %, $@) modules
# Install modules
......@@ -497,7 +494,7 @@ tags: dummy
# FIXME: anybody still using this?
fs lib mm ipc kernel drivers net sound: dummy
$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" $(subst $@, _dir_$@, $@)
$(MAKE) $(subst $@, _dir_$@, $@)
# Make a backup
# FIXME anybody still using this?
......
......@@ -2,11 +2,6 @@
# This file contains rules which are shared between multiple Makefiles.
#
#
# False targets.
#
.PHONY: dummy
#
# Special variables which should not be exported
#
......@@ -110,9 +105,21 @@ first_rule: all_targets
# Compile C sources (.c)
# ---------------------------------------------------------------------------
$(export-objs): export_flags := $(EXPORT_FLAGS)
# FIXME: if we don't know if built-in or modular, assume built-in.
# Only happens in Makefiles which override the default first_rule:
modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y) : modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y:.o=.i): modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-y:.o=.s): modkern_cflags := $(CFLAGS_KERNEL)
$(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE)
$(real-objs-m:.o=.i): modkern_cflags := $(CFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_cflags := $(CFLAGS_MODULE)
$(export-objs) : export_flags := $(EXPORT_FLAGS)
c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(export_flags)
c_flags = $(CFLAGS) $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(export_flags)
cmd_cc_s_c = $(CC) $(c_flags) -S $< -o $@
......@@ -132,7 +139,16 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
# Compile assembler sources (.S)
# ---------------------------------------------------------------------------
a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
# FIXME (s.a.)
modkern_aflags := $(AFLAGS_KERNEL)
$(real-objs-y) : modkern_aflags := $(AFLAGS_KERNEL)
$(real-objs-y:.o=.s): modkern_aflags := $(AFLAGS_KERNEL)
$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
a_flags = $(AFLAGS) $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
cmd_as_s_S = $(CPP) $(a_flags) $< > $@
......@@ -166,7 +182,7 @@ endif
all_targets: $(O_TARGET) $(L_TARGET) sub_dirs
# To build objects in subdirs, we need to descend into the directories
$(subdir-obj-y): sub_dirs
$(sort $(subdir-obj-y)): sub_dirs ;
#
# Rule to compile a set of .o files into one .o file
......@@ -267,13 +283,14 @@ modules_install: _modinst__ \
$(patsubst %,_modinst_%,$(MOD_SUB_DIRS))
#
# A rule to do nothing
# FIXME: This is usually called FORCE, to express what it's used for
#
.PHONY: dummy
dummy:
#
# This is useful for testing
#
# FIXME: really?
script:
$(SCRIPT)
......@@ -363,7 +380,6 @@ endif
endif # CONFIG_MODULES
#
# include dependency files if they exist
#
......
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