diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2003-06-07 00:54:35 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-06-07 00:54:35 -0700 |
commit | 1ffdd43733501712676a6a898c69608f2491d959 (patch) | |
tree | 9886c303e7718a2da1e1df4e0c0bdcccfa0f9193 /scripts | |
parent | 046511a42eb3b5b7ededf7964be712069de5a8fe (diff) | |
download | history-1ffdd43733501712676a6a898c69608f2491d959.tar.gz |
[PATCH] be more flexible about creating library archives
New makefile variable introduced: lib-y
The lib-y syntax allows you to do the usual tricks such as:
lib-$(CONFIG_SMP) += percpu_counter.o
A built-in.o is always present in a directory that list .o files in
either obj-* or lib-*.
In contrast, lib.a is made only when lib-y is defined.
I also updated lib/Makefile, so that crc32.o is now always built-in
if selected.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.build | 39 | ||||
-rw-r--r-- | scripts/Makefile.lib | 7 |
2 files changed, 25 insertions, 21 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index bcdcc4bdf4926..206af58fd7da7 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -32,9 +32,7 @@ $(warning kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete endif ifdef L_TARGET -ifneq ($(L_TARGET),lib.a) -$(warning kbuild: $(obj)/Makefile - L_TARGET := $(L_TARGET) target shall be renamed to lib.a. Please fix!) -endif +$(error kbuild: $(obj)/Makefile - Use of L_TARGET is replaced by lib-y in 2.5. Please fix!) endif ifdef list-multi @@ -47,21 +45,19 @@ endif # =========================================================================== -# If a Makefile does not define a L_TARGET, link an object called "built-in.o" - -ifdef L_TARGET -L_TARGET := $(obj)/$(L_TARGET) -else -ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-)),) -O_TARGET := $(obj)/built-in.o +ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),) +lib-target := $(obj)/lib.a endif + +ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),) +builtin-target := $(obj)/built-in.o endif # We keep a list of all modules in $(MODVERDIR) touch-module = @echo $(@:.o=.ko) > $(MODVERDIR)/$(@F:.o=.mod) -__build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(extra-y)) \ +__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ $(if $(KBUILD_MODULES),$(obj-m)) \ $(subdir-ym) $(always) @: @@ -203,7 +199,8 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< %.o: %.S FORCE $(call if_changed_dep,as_o_S) -targets += $(real-objs-y) $(real-objs-m) $(extra-y) $(MAKECMDGOALS) $(always) +targets += $(real-objs-y) $(real-objs-m) $(lib-y) +targets += $(extra-y) $(MAKECMDGOALS) $(always) # Build the compiled-in targets # --------------------------------------------------------------------------- @@ -214,30 +211,30 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; # # Rule to compile a set of .o files into one .o file # -ifdef O_TARGET +ifdef builtin-target quiet_cmd_link_o_target = LD $@ -# If the list of objects to link is empty, just create an empty O_TARGET +# If the list of objects to link is empty, just create an empty built-in.o cmd_link_o_target = $(if $(strip $(obj-y)),\ $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ rm -f $@; $(AR) rcs $@) -$(O_TARGET): $(obj-y) FORCE +$(builtin-target): $(obj-y) FORCE $(call if_changed,link_o_target) -targets += $(O_TARGET) -endif # O_TARGET +targets += $(builtin-target) +endif # builtin-target # # Rule to compile a set of .o files into one .a file # -ifdef L_TARGET +ifdef lib-target quiet_cmd_link_l_target = AR $@ -cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y) +cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(lib-y) -$(L_TARGET): $(obj-y) FORCE +$(lib-target): $(lib-y) FORCE $(call if_changed,link_l_target) -targets += $(L_TARGET) +targets += $(lib-target) endif # diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 5d4b44b7150ab..c5b5d125067b8 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -18,6 +18,12 @@ extra-y += $(EXTRA_TARGETS) obj-m := $(filter-out $(obj-y),$(obj-m)) +# Libraries are always collected in one lib file. +# Filter out objects already built-in + +lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) + + # Handle objects in subdirs # --------------------------------------------------------------------------- # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o @@ -91,6 +97,7 @@ always := $(addprefix $(obj)/,$(always)) targets := $(addprefix $(obj)/,$(targets)) obj-y := $(addprefix $(obj)/,$(obj-y)) obj-m := $(addprefix $(obj)/,$(obj-m)) +lib-y := $(addprefix $(obj)/,$(lib-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) |