From: Kenn H. <ke...@us...> - 2003-08-04 12:18:17
|
Update of /cvsroot/linux-vax/kernel-2.5/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv20410/scripts Modified Files: Makefile.build Log Message: Merge with 2.5.60 Index: Makefile.build =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/scripts/Makefile.build,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Makefile.build 3 Aug 2003 18:28:35 -0000 1.7 +++ Makefile.build 4 Aug 2003 12:18:14 -0000 1.8 @@ -15,8 +15,12 @@ include scripts/Makefile.lib +ifdef export-objs +$(warning kbuild: $(obj)/Makefile - Usage of export-objs is obsolete in 2.5. Please fix!) +endif + ifdef O_TARGET -$(error kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.5. Please fix!) +$(warning kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.5. Please fix!) endif ifdef L_TARGET @@ -45,11 +49,66 @@ endif endif +ifdef CONFIG_MODVERSIONS +modules := $(obj-m) +touch-module = @echo $(@:.o=.ko) > .tmp_versions/$(@F:.o=.mod) +else +modules := $(obj-m:.o=.ko) +endif + __build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ - $(if $(KBUILD_MODULES),$(obj-m:.o=.ko)) \ + $(if $(KBUILD_MODULES),$(modules)) \ $(subdir-ym) $(build-targets) @: +# Module versioning +# --------------------------------------------------------------------------- + +ifdef CONFIG_MODVERSIONS + +# $(call if_changed_rule,vcc_o_c) does essentially the same as the +# normal $(call if_changed_dep,cc_o_c), i.e. compile an object file +# from a C file, keeping track of the command line and dependencies. +# +# However, actually it does: +# o compile a .tmp_<file>.o from <file>.c +# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does +# not export symbols, we just rename .tmp_<file>.o to <file>.o and +# are done. +# o otherwise, we calculate symbol versions using the good old +# genksyms on the preprocessed source and postprocess them in a way +# that they are usable as a linker script +# o generate <file>.o from .tmp_<file>.o using the linker to +# replace the unresolved symbols __crc_exported_symbol with +# the actual value of the checksum generated by genksyms + +quiet_cmd_vcc_o_c = CC $(quiet_modtag) $@ +cmd_vcc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< + +define rule_vcc_o_c + $(if $($(quiet)cmd_vcc_o_c),echo ' $($(quiet)cmd_vcc_o_c)';) \ + $(cmd_vcc_o_c); \ + \ + if ! $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + mv $(@D)/.tmp_$(@F) $@; \ + else \ + $(CPP) -D__GENKSYMS__ $(c_flags) $< \ + | $(GENKSYMS) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) \ + | sed -n 's/\#define __ver_\(\w*\)\W*\(\w*\)/__crc_\1 = 0x\2 ;/gp' \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ + fi; + \ + scripts/fixdep $(depfile) $@ '$(cmd_vcc_o_c)' > $(@D)/.$(@F).tmp; \ + rm -f $(depfile); \ + mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd +endef + +endif + # Compile C sources (.c) # --------------------------------------------------------------------------- @@ -69,11 +128,6 @@ $(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) -$(export-objs:.o=.lst): export_flags := $(EXPORT_FLAGS) - # Default for not multi-part modules modname = $(*F) @@ -105,7 +159,20 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< $(listing_o_c) %.o: %.c FORCE +ifdef CONFIG_MODVERSIONS + $(call if_changed_rule,vcc_o_c) +else $(call if_changed_dep,cc_o_c) +endif + +# For modversioning, we need to special case single-part modules +# to mark them in $(MODVERDIR) + +ifdef CONFIG_MODVERSIONS +$(single-used-m): %.o: %.c FORCE + $(touch-module) + $(call if_changed_rule,vcc_o_c) +endif quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ @@ -150,7 +217,7 @@ quiet_cmd_link_o_target = LD $@ # If the list of objects to link is empty, just create an empty O_TARGET cmd_link_o_target = $(if $(strip $(obj-y)),\ - $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^),\ + $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ rm -f $@; $(AR) rcs $@) $(O_TARGET): $(obj-y) FORCE @@ -175,19 +242,20 @@ # # Rule to link composite objects # +# Composite objects are specified in kbuild makefile as follows: +# <composite-object>-objs := <list of .o files> +# or +# <composite-object>-y := <list of .o files> +link_multi_deps = \ +$(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)))),$^) +cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) 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)))),$^) init/vermagic.o - -quiet_cmd_link_single-m = LD [M] $@ -cmd_link_single-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $< init/vermagic.o - -# Don't rebuilt vermagic.o unless we actually are in the init/ dir -ifneq ($(obj),init) -init/vermagic.o: ; -endif +cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) # We would rather have a list of rules like # foo.o: $(foo-objs) @@ -196,13 +264,34 @@ $(multi-used-y) : %.o: $(multi-objs-y) FORCE $(call if_changed,link_multi-y) -$(multi-used-m:.o=.ko) : %.ko: $(multi-objs-m) init/vermagic.o FORCE +$(multi-used-m) : %.o: $(multi-objs-m) FORCE + $(touch-module) $(call if_changed,link_multi-m) -$(single-used-m:.o=.ko) : %.ko: %.o init/vermagic.o FORCE - $(call if_changed,link_single-m) +targets += $(multi-used-y) $(multi-used-m) + +# +# Rule to link modules ( .o -> .ko ) +# + +# With CONFIG_MODVERSIONS, generation of the final .ko is handled +# by scripts/Makefile.modver +ifndef CONFIG_MODVERSIONS -targets += $(multi-used-y) $(multi-used-m:.o=.ko) $(single-used-m:.o=.ko) +quiet_cmd_link_module = LD [M] $@ +cmd_link_module = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $< init/vermagic.o + +# Don't rebuilt vermagic.o unless we actually are in the init/ dir +ifneq ($(obj),init) +init/vermagic.o: ; +endif + +$(single-used-m:.o=.ko) $(multi-used-m:.o=.ko): %.ko: %.o init/vermagic.o FORCE + $(call if_changed,link_module) + +targets += $(single-used-m:.o=.ko) $(multi-used-m:.o=.ko) + +endif # Compile programs on the host # =========================================================================== |