diff options
| author | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2002-05-22 01:26:29 -0500 |
|---|---|---|
| committer | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2002-05-22 01:26:29 -0500 |
| commit | aa2ac86495439a62809d841b9effcf0e1e1c8759 (patch) | |
| tree | 91c93386cac1e501ee959e9eecca06e4760cddd1 /Rules.make | |
| parent | e6d19c6ab5f0f54d15277be9933183050d01ce2c (diff) | |
Simplify linking/building objects in subdirectories
New-style Makefiles have a nice way of declaring objects
which need to be built either built-in or as modules:
obj-$(CONFIG_EEPRO100) += eepro100.o
However, handling objects in subdirectories, which need to be
built and linked is not as nice:
subdir-$(CONFIG_E100) += e100
ifeq ($(CONFIG_E100),y)
obj-y += e100/built-in.o
endif
This means we descend into the subdirectory when building
vmlinux / modules, depending on CONFIG_XXX. When we are building
vmlinux we also need to link whatever has been built in the
subdirectory, so we add it to $(obj-y) at the appropriate place
(link order is important).
Now, the extension below allows to rewrite the second case into
obj-$(CONFIG_E100) += e100/
which looks much nicer ;-) Existing behavior is not changed, and the
only prerequisite to using the extension above is that the O_TARGET in
the subdir is named "built-in.o".
Diffstat (limited to 'Rules.make')
| -rw-r--r-- | Rules.make | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Rules.make b/Rules.make index b4d5f2f84457..291c9f81c682 100644 --- a/Rules.make +++ b/Rules.make @@ -43,6 +43,27 @@ obj-m := $(filter-out $(obj-y),$(obj-m)) # first_rule: all_targets +# Handle objects in subdirs +# --------------------------------------------------------------------------- +# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o +# and add the directory to the list of dirs to descend into: $(subdir-y) +# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) +# and add the directory to the list of dirs to descend into: $(subdir-m) + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +__subdir-n := $(patsubst %/,%,$(filter %/, $(obj-n))) +subdir-n += $(__subdir-n) +__subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) +subdir- += $(__subdir-) +obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) +obj-m := $(filter-out %/, $(obj-m)) + +# If a dir is selected in $(subdir-y) and also mentioned in $(mod-subdirs), +# add it to $(subdir-m) + both-m := $(filter $(mod-subdirs), $(subdir-y)) SUB_DIRS := $(subdir-y) MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m)) |
