Commit 11768acd authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Small cleanups

o Use a shorter expression to transform 'foo.o' -> 'foo-objs'
o Define EXPORT_FLAGS (as -DEXPORT_SYMTAB) in the main Makefile
o Small rearrangement of code in Rules.make
parent 4d50e140
......@@ -37,17 +37,22 @@ OBJDUMP = $(CROSS_COMPILE)objdump
MAKEFILES = $(TOPDIR)/.config
GENKSYMS = /sbin/genksyms
DEPMOD = /sbin/depmod
PERL = perl
MODFLAGS = -DMODULE
CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE =
CFLAGS_KERNEL =
AFLAGS_KERNEL =
PERL = perl
EXPORT_FLAGS =
export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
CONFIG_SHELL TOPDIR HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL
export CPPFLAGS EXPORT_FLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
all: do-it-all
#
......@@ -94,6 +99,10 @@ CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
-fomit-frame-pointer -fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
ifdef CONFIG_MODULES
EXPORT_FLAGS := -DEXPORT_SYMTAB
endif
INIT =init/init.o
CORE_FILES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o
NETWORKS =net/network.o
......@@ -157,10 +166,6 @@ DRIVERS := $(DRIVERS-y)
include arch/$(ARCH)/Makefile
export CPPFLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS
# boot target
......
......@@ -73,8 +73,8 @@ __obj-y = $(filter-out export.o,$(obj-y))
__obj-m = $(filter-out export.o,$(obj-m))
# if $(foo-objs) exists, foo.o is a composite object
__multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(basename $(m))-objs), $(m))))
__multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(basename $(m))-objs), $(m))))
__multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $($(m:.o=-objs)), $(m))))
__multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(m:.o=-objs)), $(m))))
# FIXME: Rip this out later
# Backwards compatibility: if a composite object is listed in
......@@ -86,9 +86,16 @@ multi-used-m := $(filter-out $(list-multi),$(__multi-used-m))
# Build list of the parts of our composite objects, our composite
# objects depend on those (obviously)
multi-objs-y := $(foreach m, $(multi-used-y), $($(basename $(m))-objs))
multi-objs-m := $(foreach m, $(multi-used-m), $($(basename $(m))-objs))
multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)))
multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)))
# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
# in the local directory
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-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
# ==========================================================================
#
......@@ -103,7 +110,7 @@ first_rule: all_targets
# Compile C sources (.c)
# ---------------------------------------------------------------------------
# export_flags will be set to -DEXPORT_SYMBOL for objects in $(export-objs)
$(export-objs): export_flags := $(EXPORT_FLAGS)
c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(export_flags)
......@@ -122,7 +129,6 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
%.o: %.c dummy
$(call if_changed,cmd_cc_o_c)
# Compile assembler sources (.S)
# ---------------------------------------------------------------------------
......@@ -148,10 +154,7 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
#
all_targets: $(O_TARGET) $(L_TARGET) sub_dirs
# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
# in the local directory
subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
# Do build these objects, we need to descend into the directories
# To build objects in subdirs, we need to descend into the directories
$(subdir-obj-y): sub_dirs
#
......@@ -344,7 +347,6 @@ endif # CONFIG_MODVERSIONS
ifneq "$(strip $(export-objs))" ""
$(export-objs): $(TOPDIR)/include/linux/modversions.h
$(export-objs): export_flags := -DEXPORT_SYMTAB
endif
......
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