Name: Module Finishing Step Author: Kai Germaschewski Depends: D: --- 1.349/Makefile Wed Nov 20 08:00:03 2002 +++ edited/Makefile Fri Nov 22 10:27:56 2002 @@ -164,6 +164,7 @@ AFLAGS_MODULE = $(MODFLAGS) CFLAGS_KERNEL = AFLAGS_KERNEL = +LDFLAGS_MODULE = -r NOSTDINC_FLAGS = -nostdinc -iwithprefix include CPPFLAGS := -D__KERNEL__ -Iinclude @@ -174,7 +175,7 @@ export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ - HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB + HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE ===== scripts/Makefile.build 1.11 vs edited ===== --- 1.11/scripts/Makefile.build Thu Nov 14 10:08:38 2002 +++ edited/scripts/Makefile.build Fri Nov 22 10:27:17 2002 @@ -65,8 +65,6 @@ $(real-objs-m:.o=.s) : quiet_modtag := [M] $(real-objs-m:.o=.lst): quiet_modtag := [M] -$(obj-m) : quiet_modtag := [M] - $(export-objs) : export_flags := $(EXPORT_FLAGS) $(export-objs:.o=.i) : export_flags := $(EXPORT_FLAGS) $(export-objs:.o=.s) : export_flags := $(EXPORT_FLAGS) @@ -79,6 +77,7 @@ $(multi-objs-m:.o=.i) : modname = $(modname-multi) $(multi-objs-m:.o=.s) : modname = $(modname-multi) $(multi-objs-m:.o=.lst) : modname = $(modname-multi) + $(multi-objs-y) : modname = $(modname-multi) $(multi-objs-y:.o=.i) : modname = $(modname-multi) $(multi-objs-y:.o=.s) : modname = $(modname-multi) @@ -169,21 +168,36 @@ endif # +# Rule to post-process single modules +# + +quiet_cmd_link_single-m = LD [M] $@ +cmd_link_single-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $< + +$(single-m): %.ko: %.o FORCE + $(call if_changed,link_single-m) + +targets += $(single-m) + +# # Rule to link composite objects # -quiet_cmd_link_multi = LD $(quiet_modtag) $@ -cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^) +quiet_cmd_link_multi-y = LD $@ +cmd_link_multi-y = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^) + +quiet_cmd_link_multi-m = LD [M] $@ +cmd_link_multi-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.ko=-objs))) $($(subst $(obj)/,,$(@:.ko=-y)))),$^) # We would rather have a list of rules like # foo.o: $(foo-objs) # but that's not so easy, so we rather make all composite objects depend # on the set of all their parts $(multi-used-y) : %.o: $(multi-objs-y) FORCE - $(call if_changed,link_multi) + $(call if_changed,link_multi-y) -$(multi-used-m) : %.o: $(multi-objs-m) FORCE - $(call if_changed,link_multi) +$(multi-used-m) : %.ko: $(multi-objs-m) FORCE + $(call if_changed,link_multi-m) targets += $(multi-used-y) $(multi-used-m) ===== scripts/Makefile.lib 1.4 vs edited ===== --- 1.4/scripts/Makefile.lib Wed Nov 20 15:02:30 2002 +++ edited/scripts/Makefile.lib Fri Nov 22 10:16:36 2002 @@ -14,7 +14,7 @@ # When an object is listed to be built compiled-in and modular, # only build the compiled-in version -obj-m := $(filter-out $(obj-y),$(obj-m)) +obj-m := $(patsubst %.o,%.ko,$(filter-out $(obj-y),$(obj-m))) # Handle objects in subdirs # --------------------------------------------------------------------------- @@ -37,18 +37,17 @@ # export.o is never a composite object, since $(export-objs) has a # fixed meaning (== objects which EXPORT_SYMBOL()) __obj-y = $(filter-out export.o,$(obj-y)) -__obj-m = $(filter-out export.o,$(obj-m)) +__obj-m = $(filter-out export.ko,$(obj-m)) # if $(foo-objs) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) -multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) -multi-used := $(multi-used-y) $(multi-used-m) +multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $(strip $($(m:.ko=-objs)) $($(m:.ko=-y))), $(m)))) +single-m := $(sort $(filter-out $(multi-used-m),$(obj-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), $($(m:.o=-objs)) $($(m:.o=-y))) -multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) -multi-objs := $(multi-objs-y) $(multi-objs-m) +multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.ko=-objs)) $($(m:.ko=-y))) # $(subdir-obj-y) is the list of objects in $(obj-y) which do not live # in the local directory @@ -56,7 +55,7 @@ # 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 $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(EXTRA_TARGETS) -real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) +real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.ko=-objs)) $($(m:.ko=-y))),$($(m:.ko=-objs)) $($(m:.ko=-y)),$(m:.ko=.o))) # Only build module versions for files which are selected to be built export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) @@ -100,6 +99,7 @@ real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) +single-m := $(addprefix $(obj)/,$(single-m)) multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) @@ -130,8 +130,9 @@ $(basename_flags) $(modname_flags) $(export_flags) # Finds the multi-part object the current object will be linked into -modname-multi = $(subst $(space),_,$(sort $(foreach m,$(multi-used),\ - $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))) +modname-multi = $(subst $(space),_,$(sort \ + $(foreach m,$(subst $(obj)/,,$(multi-used-y)),$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))) \ + $(foreach m,$(subst $(obj)/,,$(multi-used-m)),$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.ko=-objs)) $($(m:.ko=-y))),$(m:.ko=))))) # Shipped files # =========================================================================== ===== scripts/Makefile.modinst 1.5 vs edited ===== --- 1.5/scripts/Makefile.modinst Fri Nov 8 22:08:33 2002 +++ edited/scripts/Makefile.modinst Fri Nov 22 10:25:46 2002 @@ -16,8 +16,8 @@ # ========================================================================== quiet_cmd_modules_install = INSTALL $(obj-m) - cmd_modules_install = mkdir -p $(MODLIB)/kernel && \ - cp $(obj-m) $(MODLIB)/kernel/ + cmd_modules_install = mkdir -p $(MODLIB)/kernel \ + $(foreach m,$(obj-m),&& cp $(m) $(MODLIB)/kernel/$(notdir $(m:.ko=.o))) modules_install: $(subdir-ym) ifneq ($(obj-m),)