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 ...@@ -172,7 +172,7 @@ export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
boot: vmlinux boot: vmlinux
@$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C arch/$(ARCH)/boot @$(MAKE) -C arch/$(ARCH)/boot
# Build vmlinux # Build vmlinux
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -202,7 +202,7 @@ define rule_link_vmlinux ...@@ -202,7 +202,7 @@ define rule_link_vmlinux
echo Generating build number echo Generating build number
. scripts/mkversion > .tmpversion . scripts/mkversion > .tmpversion
mv -f .tmpversion .version mv -f .tmpversion .version
$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" AFLAGS="$(AFLAGS) $(AFLAGS_KERNEL)" -C init $(MAKE) -C init
echo $(cmd_link_vmlinux) echo $(cmd_link_vmlinux)
$(cmd_link_vmlinux) $(cmd_link_vmlinux)
echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd
...@@ -212,11 +212,10 @@ endef ...@@ -212,11 +212,10 @@ endef
vmlinux: $(CONFIGURATION) $(vmlinux-objs) dummy vmlinux: $(CONFIGURATION) $(vmlinux-objs) dummy
$(call if_changed_rule,link_vmlinux) $(call if_changed_rule,link_vmlinux)
# The actual objects are generated when descending, make sure # The actual objects are generated when descending,
# no implicit rule kicks in # make sure no implicit rule kicks in
$(sort $(vmlinux-objs)): linuxsubdirs $(sort $(vmlinux-objs)): linuxsubdirs ;
@
# Handle descending into subdirectories listed in $(SUBDIRS) # Handle descending into subdirectories listed in $(SUBDIRS)
...@@ -224,7 +223,7 @@ $(sort $(vmlinux-objs)): linuxsubdirs ...@@ -224,7 +223,7 @@ $(sort $(vmlinux-objs)): linuxsubdirs
linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS)) linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/linux/version.h include/config/MARKER $(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 # Configuration
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -266,8 +265,6 @@ include/linux/version.h: ./Makefile ...@@ -266,8 +265,6 @@ include/linux/version.h: ./Makefile
@echo Generating $@ @echo Generating $@
@. scripts/mkversion_h $@ $(KERNELRELEASE) $(VERSION) $(PATCHLEVEL) $(SUBLEVEL) @. scripts/mkversion_h $@ $(KERNELRELEASE) $(VERSION) $(PATCHLEVEL) $(SUBLEVEL)
comma := ,
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Generate dependencies # Generate dependencies
...@@ -296,7 +293,7 @@ modules: $(patsubst %, _mod_%, $(SUBDIRS)) ...@@ -296,7 +293,7 @@ modules: $(patsubst %, _mod_%, $(SUBDIRS))
.PHONY: $(patsubst %, _mod_%, $(SUBDIRS)) .PHONY: $(patsubst %, _mod_%, $(SUBDIRS))
$(patsubst %, _mod_%, $(SUBDIRS)) : include/linux/version.h include/config/MARKER $(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 # Install modules
...@@ -497,7 +494,7 @@ tags: dummy ...@@ -497,7 +494,7 @@ tags: dummy
# FIXME: anybody still using this? # FIXME: anybody still using this?
fs lib mm ipc kernel drivers net sound: dummy 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 # Make a backup
# FIXME anybody still using this? # FIXME anybody still using this?
......
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
# This file contains rules which are shared between multiple Makefiles. # This file contains rules which are shared between multiple Makefiles.
# #
#
# False targets.
#
.PHONY: dummy
# #
# Special variables which should not be exported # Special variables which should not be exported
# #
...@@ -110,9 +105,21 @@ first_rule: all_targets ...@@ -110,9 +105,21 @@ first_rule: all_targets
# Compile C sources (.c) # 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 $@ cmd_cc_s_c = $(CC) $(c_flags) -S $< -o $@
...@@ -132,7 +139,16 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< ...@@ -132,7 +139,16 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
# Compile assembler sources (.S) # 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) $< > $@ cmd_as_s_S = $(CPP) $(a_flags) $< > $@
...@@ -166,7 +182,7 @@ endif ...@@ -166,7 +182,7 @@ endif
all_targets: $(O_TARGET) $(L_TARGET) sub_dirs all_targets: $(O_TARGET) $(L_TARGET) 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
$(subdir-obj-y): sub_dirs $(sort $(subdir-obj-y)): sub_dirs ;
# #
# Rule to compile a set of .o files into one .o file # Rule to compile a set of .o files into one .o file
...@@ -267,13 +283,14 @@ modules_install: _modinst__ \ ...@@ -267,13 +283,14 @@ modules_install: _modinst__ \
$(patsubst %,_modinst_%,$(MOD_SUB_DIRS)) $(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: dummy:
# #
# This is useful for testing # This is useful for testing
# # FIXME: really?
script: script:
$(SCRIPT) $(SCRIPT)
...@@ -363,7 +380,6 @@ endif ...@@ -363,7 +380,6 @@ endif
endif # CONFIG_MODULES endif # CONFIG_MODULES
# #
# include dependency files if they exist # 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