From b706ce290d2690de6ff89fcea10e00cb624c6a22 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 23 Oct 2002 09:42:06 -0500 Subject: kbuild: Split Rules.make Rules.make is used in 4 phases, o generate modversions o build o install modules o clean split out the code specific to the phase and move it into scripts/Makefile. --- scripts/Makefile.build | 167 +++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.modinst | 17 +++++ scripts/Makefile.modver | 85 ++++++++++++++++++++++++ 3 files changed, 269 insertions(+) create mode 100644 scripts/Makefile.build create mode 100644 scripts/Makefile.modinst create mode 100644 scripts/Makefile.modver (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build new file mode 100644 index 000000000000..7b28a0fd6b83 --- /dev/null +++ b/scripts/Makefile.build @@ -0,0 +1,167 @@ +# ========================================================================== +# Building +# ========================================================================== + +# 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 +O_TARGET := $(obj)/built-in.o +endif + +first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ + $(if $(KBUILD_MODULES),$(obj-m)) \ + $(subdir-ym) + @: + +# Compile C sources (.c) +# --------------------------------------------------------------------------- + +# Default is built-in, unless we know otherwise +modkern_cflags := $(CFLAGS_KERNEL) + +$(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE) +$(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE) +$(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE) + +$(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) + +c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ + $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \ + -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \ + $(export_flags) + +quiet_cmd_cc_s_c = CC $(echo_target) +cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< + +%.s: %.c FORCE + $(call if_changed_dep,cc_s_c) + +quiet_cmd_cc_i_c = CPP $(echo_target) +cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< + +%.i: %.c FORCE + $(call if_changed_dep,cc_i_c) + +quiet_cmd_cc_o_c = CC $(echo_target) +cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< + +%.o: %.c FORCE + $(call if_changed_dep,cc_o_c) + +quiet_cmd_cc_lst_c = MKLST $(echo_target) +cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && sh scripts/makelst $*.o System.map $(OBJDUMP) > $@ + +%.lst: %.c FORCE + $(call if_changed_dep,cc_lst_c) + +# Compile assembler sources (.S) +# --------------------------------------------------------------------------- + +modkern_aflags := $(AFLAGS_KERNEL) + +$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) +$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) + +a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \ + $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) + +quiet_cmd_as_s_S = CPP $(echo_target) +cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< + +%.s: %.S FORCE + $(call if_changed_dep,as_s_S) + +quiet_cmd_as_o_S = AS $(echo_target) +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_TARGETS) $(MAKECMDGOALS) + +# Build the compiled-in targets +# --------------------------------------------------------------------------- + +# To build objects in subdirs, we need to descend into the directories +$(sort $(subdir-obj-y)): $(subdir-ym) ; + +# +# Rule to compile a set of .o files into one .o file +# +ifdef O_TARGET +quiet_cmd_link_o_target = LD $(echo_target) +# 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), $^),\ + rm -f $@; $(AR) rcs $@) + +$(O_TARGET): $(obj-y) FORCE + $(call if_changed,link_o_target) + +targets += $(O_TARGET) +endif # O_TARGET + +# +# Rule to compile a set of .o files into one .a file +# +ifdef L_TARGET +quiet_cmd_link_l_target = AR $(echo_target) +cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y) + +$(L_TARGET): $(obj-y) FORCE + $(call if_changed,link_l_target) + +targets += $(L_TARGET) +endif + +# +# Rule to link composite objects +# + +quiet_cmd_link_multi = LD $(echo_target) +cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^) + +# 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) + +$(multi-used-m) : %.o: $(multi-objs-m) FORCE + $(call if_changed,link_multi) + +targets += $(multi-used-y) $(multi-used-m) + +# Compile programs on the host +# =========================================================================== + +quiet_cmd_host_cc__c = HOSTCC $(echo_target) +cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \ + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ + $(HOST_LOADLIBES) -o $@ $< + +$(host-progs-single): %: %.c FORCE + $(call if_changed_dep,host_cc__c) + +quiet_cmd_host_cc_o_c = HOSTCC $(echo_target) +cmd_host_cc_o_c = $(HOSTCC) -Wp,-MD,$(depfile) \ + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) -c -o $@ $< + +$(host-progs-multi-objs): %.o: %.c FORCE + $(call if_changed_dep,host_cc_o_c) + +quiet_cmd_host_cc__o = HOSTLD $(echo_target) +cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(subst $(obj)/,,$@)-objs)) \ + $(HOST_LOADLIBES) + +$(host-progs-multi): %: $(host-progs-multi-objs) FORCE + $(call if_changed,host_cc__o) + +targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi) + diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst new file mode 100644 index 000000000000..6e1fe0e5bcbd --- /dev/null +++ b/scripts/Makefile.modinst @@ -0,0 +1,17 @@ +# ========================================================================== +# Installing modules +# ========================================================================== + +quiet_cmd_modules_install = INSTALL $(obj-m) +cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(obj); \ + cp $(obj-m) $(MODLIB)/kernel/$(obj) + +.PHONY: modules_install + +modules_install: $(subdir-ym) +ifneq ($(obj-m),) + $(call cmd,modules_install) +else + @: +endif + diff --git a/scripts/Makefile.modver b/scripts/Makefile.modver new file mode 100644 index 000000000000..2b9a2a68ffa7 --- /dev/null +++ b/scripts/Makefile.modver @@ -0,0 +1,85 @@ +# =========================================================================== +# Module versions +# =========================================================================== + +ifeq ($(strip $(export-objs)),) + +# If we don't export any symbols in this dir, just descend +# --------------------------------------------------------------------------- + +fastdep: $(subdir-ym) + @: + +else + +# This sets version suffixes on exported symbols +# --------------------------------------------------------------------------- + +MODVERDIR := include/linux/modules + +# +# Added the SMP separator to stop module accidents between uniprocessor +# and SMP Intel boxes - AC - from bits by Michael Chastain +# + +ifdef CONFIG_SMP + genksyms_smp_prefix := -p smp_ +else + genksyms_smp_prefix := +endif + +# Don't include modversions.h, we're just about to generate it here. + +CFLAGS_MODULE := $(filter-out -include linux/modversions.h,$(CFLAGS_MODULE)) + +$(addprefix $(MODVERDIR)/,$(real-objs-y:.o=.ver)): modkern_cflags := $(CFLAGS_KERNEL) +$(addprefix $(MODVERDIR)/,$(real-objs-m:.o=.ver)): modkern_cflags := $(CFLAGS_MODULE) +$(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)): export_flags := -D__GENKSYMS__ + +c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ + $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \ + -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \ + $(export_flags) + +# Our objects only depend on modversions.h, not on the individual .ver +# files (fix-dep filters them), so touch modversions.h if any of the .ver +# files changes + +quiet_cmd_cc_ver_c = MKVER include/linux/modules/$*.ver +cmd_cc_ver_c = $(CPP) $(c_flags) $< | $(GENKSYMS) $(genksyms_smp_prefix) \ + -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp + +# Okay, let's explain what's happening in rule_make_cc_ver_c: +# o echo the command +# o execute the command +# o If the $(CPP) fails, we won't notice because it's output is piped +# to $(GENKSYMS) which does not fail. We recognize this case by +# looking if the generated $(depfile) exists, though. +# o If the .ver file changed, touch modversions.h, which is our maker +# of any changed .ver files. +# o Move command line and deps into their normal .*.cmd place. + +define rule_cc_ver_c + $(if $($(quiet)cmd_cc_ver_c),echo ' $($(quiet)cmd_cc_ver_c)';) \ + $(cmd_cc_ver_c); \ + if [ ! -r $(depfile) ]; then exit 1; fi; \ + scripts/fixdep $(depfile) $@ '$(cmd_cc_ver_c)' > $(@D)/.$(@F).tmp; \ + rm -f $(depfile); \ + if [ ! -r $@ ] || cmp -s $@ $@.tmp; then \ + touch include/linux/modversions.h; \ + fi; \ + mv -f $@.tmp $@ + mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd +endef + +$(MODVERDIR)/%.ver: %.c FORCE + @$(call if_changed_rule,cc_ver_c) + +targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)) + +fastdep: $(targets) $(subdir-ym) + @mkdir -p $(dir $(addprefix .tmp_export-objs/modules/,$(export-objs:.o=.ver))) + @touch $(addprefix .tmp_export-objs/modules/,$(export-objs:.o=.ver)) + +endif # export-objs + -- cgit v1.2.3 From 35bce88fa68ca7048312502723abac2b423ed4f2 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 23 Oct 2002 09:59:43 -0500 Subject: kbuild: Shut up "make clean" in non-verbose mode $(call ...) has a measurable performance impact, so use the new variable $(Q), which evaluates to @ when quiet to supress the echoing of commands if not wanted. IIRC, Keith Owens' kbuild-2.5 came up with that idea, so credit goes there. --- Makefile | 10 +++++++--- scripts/Makefile.clean | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 3ace002a95ba..e97cff3359be 100644 --- a/Makefile +++ b/Makefile @@ -109,8 +109,12 @@ MAKEFLAGS += --no-print-directory # If the user wants quiet mode, echo short versions of the commands # only -ifneq ($(KBUILD_VERBOSE),1) +ifeq ($(KBUILD_VERBOSE),1) + quiet = + Q = +else quiet=quiet_ + Q = @ endif # If the user is running make -s (silent mode), suppress echoing of @@ -120,7 +124,7 @@ ifneq ($(findstring s,$(MAKEFLAGS)),) quiet=silent_ endif -export quiet KBUILD_VERBOSE +export quiet Q KBUILD_VERBOSE # Paths to obj / src tree @@ -698,7 +702,7 @@ MRPROPER_DIRS += \ clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts $(addprefix _clean_,$(clean-dirs)): - $(MAKE) MAKEFILES= -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) + $(Q)$(MAKE) MAKEFILES= -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) quiet_cmd_rmclean = RM $$(CLEAN_FILES) cmd_rmclean = rm -f $(CLEAN_FILES) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index d7bb2dfb88d8..08ada532a4a1 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -38,5 +38,5 @@ endif .PHONY: $(subdir-ymn) $(subdir-ymn): - $(MAKE) -rR -f scripts/Makefile.clean obj=$@ + $(Q)$(MAKE) -rR -f scripts/Makefile.clean obj=$@ -- cgit v1.2.3 From eea2541514a26d3ebb09ef5401b97b4a441ca8d4 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 23 Oct 2002 10:26:57 -0500 Subject: kbuild: Switch "make modules_install" to fast mode ;) Use the same way we came up with for "make clean" for "make modules_install", gaining a nice speed-up. Also, some cosmetics for scripts/Makefile.clean --- Makefile | 3 +-- drivers/scsi/aic7xxx/Makefile | 5 ++-- scripts/Makefile.clean | 29 +++++++++++++++++++--- scripts/Makefile.modinst | 56 ++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 82 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index e97cff3359be..29ab9fc5f398 100644 --- a/Makefile +++ b/Makefile @@ -544,8 +544,7 @@ _modinst_post: .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) $(patsubst %, _modinst_%, $(SUBDIRS)) : - +@$(call descend,$(patsubst _modinst_%,%,$@),modules_install) - + $(Q)$(MAKE) MAKEFILES= -rR -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@) else # CONFIG_MODULES # Modules not configured diff --git a/drivers/scsi/aic7xxx/Makefile b/drivers/scsi/aic7xxx/Makefile index ea95d8a13309..56b2736a6b9f 100644 --- a/drivers/scsi/aic7xxx/Makefile +++ b/drivers/scsi/aic7xxx/Makefile @@ -24,8 +24,7 @@ endif clean-files := aic7xxx_seq.h aic7xxx_reg.h # Command to be executed upon make clean -# Note: Assignment without ':' to force late evaluation of $(src) -clean-rule = @$(MAKE) -C $(src)/aicasm clean +clean-rule := $(MAKE) -C $(src)/aicasm clean include $(TOPDIR)/Rules.make @@ -39,7 +38,7 @@ ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y) $(obj)/aic7xxx_seq.h: $(src)/aic7xxx.seq $(src)/aic7xxx.reg \ $(obj)/aicasm/aicasm - $(obj)/aicasm/aicasm -I. -r $(obj)/aic7xxx_reg.h \ + $(obj)/aicasm/aicasm -I$(obj) -r $(obj)/aic7xxx_reg.h \ -o $(obj)/aic7xxx_seq.h $(src)/aic7xxx.seq $(obj)/aic7xxx_reg.h: $(obj)/aix7xxx_seq.h diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 08ada532a4a1..14a71984c6e4 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -1,3 +1,6 @@ +# ========================================================================== +# Cleaning up +# ========================================================================== src := $(obj) @@ -8,6 +11,9 @@ __clean: include $(obj)/Makefile +# Figure out what we need to build from the various variables +# ========================================================================== + __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) @@ -17,26 +23,43 @@ subdir-n += $(__subdir-n) __subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) subdir- += $(__subdir-) +# Subdirectories we need to descend into + subdir-ym := $(sort $(subdir-y) $(subdir-m)) subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) +# Add subdir path + EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) clean-files := $(addprefix $(obj)/,$(clean-files)) host-progs := $(addprefix $(obj)/,$(host-progs)) subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) +# ========================================================================== + __clean-files := $(wildcard $(EXTRA_TARGETS) $(host-progs) $(clean-files)) +quiet_cmd_clean = CLEAN $(__cleanfiles) + cmd_clean = rm -f $(__clean-files); $(clean-rule) + __clean: $(subdir-ymn) ifneq ($(strip $(__clean-files) $(clean-rule)),) - rm -f $(__clean-files) - $(clean-rule) + $(call cmd,clean) else @: endif -.PHONY: $(subdir-ymn) +# =========================================================================== +# Generic stuff +# =========================================================================== + +# Descending +# --------------------------------------------------------------------------- +.PHONY: $(subdir-ymn) $(subdir-ymn): $(Q)$(MAKE) -rR -f scripts/Makefile.clean obj=$@ +# If quiet is set, only print short version of command + +cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 6e1fe0e5bcbd..6dcc5b132fb1 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -2,11 +2,47 @@ # Installing modules # ========================================================================== -quiet_cmd_modules_install = INSTALL $(obj-m) -cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(obj); \ - cp $(obj-m) $(MODLIB)/kernel/$(obj) +src := $(obj) + +no-rules.make := 1 .PHONY: modules_install +modules_install: + +include .config + +#$(warning $(CONFIG_X86)) + +include $(obj)/Makefile + +# Figure out what we need to build from the various variables +# ========================================================================== + +# 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)) + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +obj-m := $(filter-out %/, $(obj-m)) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) + +# Add subdir path + +obj-m := $(addprefix $(obj)/,$(obj-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) + +# ========================================================================== + +quiet_cmd_modules_install = INSTALL $(obj-m) + cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(obj); \ + cp $(obj-m) $(MODLIB)/kernel/$(obj) modules_install: $(subdir-ym) ifneq ($(obj-m),) @@ -15,3 +51,17 @@ else @: endif +# =========================================================================== +# Generic stuff +# =========================================================================== + +# Descending +# --------------------------------------------------------------------------- + +.PHONY: $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) -rR -f scripts/Makefile.modinst obj=$@ + +# If quiet is set, only print short version of command + +cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) -- cgit v1.2.3 From e846b41a2a40d1eae5e7057553c226281b310b13 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 23 Oct 2002 11:33:37 -0500 Subject: kbuild: Convert build and modversion phases Alright, so now actually all four phases are converted to new-style, i.e. we call make -f scripts/Makefile. which includes the actual subdir Makefile. The obvious drawback is some code duplication between the four scripts/Makefile., which could easily be overcome including shared parts, but since I'm going for maximum performance, I did not for now. Rules.make is empty now ;) (Well, not quite, since if it was 0 bytes, make mrproper would remove it...) --- Makefile | 30 ++-- Rules.make | 353 ------------------------------------------------ arch/i386/Makefile | 2 +- init/Makefile | 4 +- scripts/Makefile.build | 285 ++++++++++++++++++++++++++++++++++++-- scripts/Makefile.clean | 6 +- scripts/Makefile.modver | 157 ++++++++++++++++++++- 7 files changed, 445 insertions(+), 392 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 29ab9fc5f398..da2c93fa709d 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,11 @@ endif MAKEFLAGS += --no-print-directory +# For maximum performance (+ possibly random breakage, uncomment +# the following) + +#MAKEFLAGS += -rR + # If the user wants quiet mode, echo short versions of the commands # only @@ -146,7 +151,6 @@ NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump -MAKEFILES = .config GENKSYMS = /sbin/genksyms DEPMOD = /sbin/depmod KALLSYMS = /sbin/kallsyms @@ -165,7 +169,7 @@ AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ - CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL + CPP AR NM STRIP OBJCOPY OBJDUMP MAKE GENKSYMS PERL export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE @@ -369,7 +373,7 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ; .PHONY: $(SUBDIRS) $(SUBDIRS): .hdepend prepare - +@$(call descend,$@,) + +$(call descend,$@,) # Things we need done before we descend to build or make # module versions are listed in "prepare" @@ -476,9 +480,11 @@ ifdef CONFIG_MODVERSIONS # Update modversions.h, but only if it would change. -include/linux/modversions.h: FORCE +.PHONY: __rm_tmp_export-objs +__rm_tmp_export-objs: @rm -rf .tmp_export-objs - @$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) + +include/linux/modversions.h: $(patsubst %,_modver_%,$(SUBDIRS)) @echo -n ' Generating $@' @( echo "#ifndef _LINUX_MODVERSIONS_H";\ echo "#define _LINUX_MODVERSIONS_H"; \ @@ -491,8 +497,9 @@ include/linux/modversions.h: FORCE ) > $@.tmp; \ $(update-if-changed) -$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE - +@$(call descend,$(patsubst _sfdep_%,%,$@),fastdep) +.PHONY: $(patsubst %, _modver_%, $(SUBDIRS)) +$(patsubst %, _modver_%, $(SUBDIRS)): __rm_tmp_export-objs + $(Q)$(MAKE) -f scripts/Makefile.modver obj=$(patsubst _modver_%,%,$@) else # !CONFIG_MODVERSIONS @@ -544,7 +551,7 @@ _modinst_post: .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) $(patsubst %, _modinst_%, $(SUBDIRS)) : - $(Q)$(MAKE) MAKEFILES= -rR -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@) + $(Q)$(MAKE) -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@) else # CONFIG_MODULES # Modules not configured @@ -701,7 +708,7 @@ MRPROPER_DIRS += \ clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts $(addprefix _clean_,$(clean-dirs)): - $(Q)$(MAKE) MAKEFILES= -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) + $(Q)$(MAKE) -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@) quiet_cmd_rmclean = RM $$(CLEAN_FILES) cmd_rmclean = rm -f $(CLEAN_FILES) @@ -890,9 +897,6 @@ endef # $(call descend,,) # Recursively call a sub-make in with target -ifeq ($(KBUILD_VERBOSE),1) -descend = echo '$(MAKE) -f $(1)/Makefile $(2)'; -endif -descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2) +descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) FORCE: diff --git a/Rules.make b/Rules.make index b8cdabe3ec2b..8b137891791f 100644 --- a/Rules.make +++ b/Rules.make @@ -1,354 +1 @@ -ifndef no-rules.make - -# -# This file contains rules which are shared between multiple Makefiles. -# - -# Some standard vars - -comma := , -empty := -space := $(empty) $(empty) - -# Some bug traps -# --------------------------------------------------------------------------- - -ifdef O_TARGET -$(error kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.5. Please fix!) -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 -endif - -ifdef list-multi -$(warning kbuild: $(obj)/Makefile - list-multi := $(list-multi) is obsolete in 2.5. Please fix!) -endif - -ifndef obj -$(warning kbuild: Rules.make is included improperly) -endif - -# Some paths for the Makefiles to use -# --------------------------------------------------------------------------- - -# Usage: -# -# $(obj)/target.o : target.o in the build dir -# $(src)/target.c : target.c in the source dir -# $(objtree)/include/linux/version.h : Some file relative to the build -# dir root -# $(srctree)/include/linux/module.h : Some file relative to the source -# dir root -# -# $(obj) and $(src) can only be used in the section after -# include $(TOPDIR)/Rules.make, i.e for generated files and the like. -# Intentionally. -# -# We don't support separate source / object yet, so these are just -# placeholders for now - -src := $(obj) - -# Figure out what we need to build from the various variables -# =========================================================================== - -# 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)) - -# 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)) - -# Subdirectories we need to descend into - -subdir-ym := $(sort $(subdir-y) $(subdir-m)) -subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) - -# 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)) - -# if $(foo-objs) exists, foo.o is a composite object -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)))) - -# 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))) -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))) $(EXTRA_TARGETS) -real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) - -# Only build module versions for files which are selected to be built -export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) - -host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) -host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) -host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) - -# Add subdir path - -EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) -obj-y := $(addprefix $(obj)/,$(obj-y)) -obj-m := $(addprefix $(obj)/,$(obj-m)) -export-objs := $(addprefix $(obj)/,$(export-objs)) -subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) -real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) -real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) -multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) -multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) -multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) -multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) -subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) -clean-files := $(addprefix $(obj)/,$(clean-files)) -host-progs := $(addprefix $(obj)/,$(host-progs)) -host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) -host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) -host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) - -# The temporary file to save gcc -MD generated dependencies must not -# contain a comma -depfile = $(subst $(comma),_,$(@D)/.$(@F).d) - -# We're called for one of four purposes: -# o subdirclean: Delete intermidiate files in the current directory -# o fastdep: build module version files (.ver) for $(export-objs) in -# the current directory -# o modules_install: install the modules in the current directory -# o build: When no target is given, first_rule is the default and -# will build the built-in and modular objects in this dir -# (or a subset thereof, depending on $(KBUILD_MODULES),$(KBUILD_BUILTIN) -# When targets are given directly (like foo.o), we just build these -# targets (That happens when someone does make some/dir/foo.[ois]) - -ifeq ($(MAKECMDGOALS),subdirclean) - -__clean-files := $(wildcard $(EXTRA_TARGETS) $(host-progs) $(clean-files)) - -subdirclean: $(subdir-ymn) -ifneq ($(strip $(__clean-files) $(clean-rule)),) - rm -f $(__clean-files) - $(clean-rule) -else - @: -endif - -else -ifeq ($(MAKECMDGOALS),fastdep) - -include scripts/Makefile.modver - -else # ! fastdep -ifeq ($(MAKECMDGOALS),modules_install) - -include scripts/Makefile.modinst - -else # ! modules_install - -include scripts/Makefile.build - -endif # ! subdirclean -endif # ! modules_install -endif # ! fastdep - -# Shipped files -# =========================================================================== - -quiet_cmd_shipped = SHIPPED $@ -cmd_shipped = cat $< > $@ - -%:: %_shipped - $(call cmd,shipped) - -# Commands useful for building a boot image -# =========================================================================== -# -# Use as following: -# -# target: source(s) FORCE -# $(if_changed,ld/objcopy/gzip) -# -# and add target to EXTRA_TARGETS so that we know we have to -# read in the saved command line - -# Linking -# --------------------------------------------------------------------------- - -quiet_cmd_ld = LD $@ -cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ - $(filter-out FORCE,$^) -o $@ - -# Objcopy -# --------------------------------------------------------------------------- - -quiet_cmd_objcopy = OBJCOPY $@ -cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ - -# Gzip -# --------------------------------------------------------------------------- - -quiet_cmd_gzip = GZIP $@ -cmd_gzip = gzip -f -9 < $< > $@ - -# =========================================================================== -# Generic stuff -# =========================================================================== - -# Descending -# --------------------------------------------------------------------------- - -.PHONY: $(subdir-ymn) - -$(subdir-ymn): - +@$(call descend,$@,$(MAKECMDGOALS)) - -# Add FORCE to the prequisites of a target to force it to be always rebuilt. -# --------------------------------------------------------------------------- - -.PHONY: FORCE - -FORCE: - -# -# This sets version suffixes on exported symbols -# Separate the object into "normal" objects and "exporting" objects -# Exporting objects are: all objects that define symbol tables -# - -# --------------------------------------------------------------------------- -# Check if command line has changed - -# Usage: -# normally one uses rules like -# -# %.o: %.c -# -# -# However, these only rebuild the target when the source has changed, -# but not when e.g. the command or the flags on the command line changed. -# -# This extension allows to do the following: -# -# command = -# -# %.o: %.c dummy -# $(call if_changed,command) -# -# which will make sure to rebuild the target when either its prerequisites -# change or the command line changes -# -# The magic works as follows: -# The addition of dummy to the dependencies causes the rule for rebuilding -# to be always executed. However, the if_changed function will generate -# an empty command when -# o none of the prequesites changed (i.e $? is empty) -# o the command line did not change (we compare the old command line, -# which is saved in ..o, to the current command line using -# the two filter-out commands) - -# Read all saved command lines and dependencies for the $(targets) we -# may be building above, using $(if_changed{,_dep}). As an -# optimization, we don't need to read them if the target does not -# exist, we will rebuild anyway in that case. - -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) - -ifneq ($(cmd_files),) - include $(cmd_files) -endif - -# function to only execute the passed command if necessary - -if_changed = $(if $(strip $? \ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ - $(cmd_$(1)); \ - echo 'cmd_$@ := $(cmd_$(1))' > $(@D)/.$(@F).cmd) - - -# execute the command and also postprocess generated .d dependencies -# file - -if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ - $(cmd_$(1)); \ - scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \ - rm -f $(depfile); \ - mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) - -# Usage: $(call if_changed_rule,foo) -# will check if $(cmd_foo) changed, or any of the prequisites changed, -# and if so will execute $(rule_foo) - -if_changed_rule = $(if $(strip $? \ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - mkdir -p $(dir $@); \ - $(rule_$(1))) - -# If quiet is set, only print short version of command - -cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) - -# do_cmd is a shorthand used to support both compressed, verbose -# and silent output in a single line. -# Compared to cmd described avobe, do_cmd does no rely on any variables -# previously assigned a value. -# -# Usage $(call do_cmd,CMD $@,cmd_to_execute bla bla) -# Example: -# $(call do_cmd,CP $@,cp -b $< $@) -# make -s => nothing will be printed -# make KBUILD_VERBOSE=1 => cp -b path/to/src.file path/to/dest.file -# make KBUILD_VERBOSE=0 => CP path/to/dest.file -define do_cmd - @$(if $(filter quiet_,$(quiet)), echo ' $(1)' &&, - $(if $(filter silent_,$(quiet)),, - echo "$(2)" &&)) \ - $(2) -endef - -# $(call descend,,) -# Recursively call a sub-make in with target - -ifeq ($(KBUILD_VERBOSE),1) -descend = echo '$(MAKE) -f $(1)/Makefile $(2)'; -endif -descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2) - -endif diff --git a/arch/i386/Makefile b/arch/i386/Makefile index f23a066d98d8..517d27f46bb3 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -88,6 +88,6 @@ install: vmlinux +@$(call makeboot,BOOTIMAGE=$(BOOTIMAGE) install) archclean: - $(MAKE) -rR -f scripts/Makefile.clean obj=arch/i386/boot + @$(MAKE) -f scripts/Makefile.clean obj=arch/i386/boot archmrproper: diff --git a/init/Makefile b/init/Makefile index 987e97108ce8..f2ac5d4ab05f 100644 --- a/init/Makefile +++ b/init/Makefile @@ -11,13 +11,13 @@ include $(TOPDIR)/Rules.make # dependencies on generated files need to be listed explicitly -$(obj)/version.o: $(obj)/../include/linux/compile.h +$(obj)/version.o: include/linux/compile.h # compile.h changes depending on hostname, generation number, etc, # so we regenerate it always. # mkcompile_h will make sure to only update the # actual file if its content has changed. -$(obj)/../include/linux/compile.h: FORCE +include/linux/compile.h: FORCE @echo -n ' Generating $@' @sh $(srctree)/scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)" diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 7b28a0fd6b83..dab20c07e6b1 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -2,6 +2,131 @@ # Building # ========================================================================== +src := $(obj) + +no-rules.make := 1 + +.PHONY: __build +__build: + +include .config + +include $(obj)/Makefile + +# Standard vars + +comma := , +empty := +space := $(empty) $(empty) + +# bug traps +# =========================================================================== + +ifdef O_TARGET +$(error kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.5. Please fix!) +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 +endif + +ifdef list-multi +$(warning kbuild: $(obj)/Makefile - list-multi := $(list-multi) is obsolete in 2.5. Please fix!) +endif + +ifndef obj +$(warning kbuild: Rules.make is included improperly) +endif + +# Figure out what we need to build from the various variables +# =========================================================================== + +# 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)) + +# 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)) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) +subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) + +# 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)) + +# if $(foo-objs) exists, foo.o is a composite object +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)))) + +# 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))) +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))) $(EXTRA_TARGETS) +real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) + +# Only build module versions for files which are selected to be built +export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) + +host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) +host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) +host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) + +# Add subdir path + +EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) +obj-y := $(addprefix $(obj)/,$(obj-y)) +obj-m := $(addprefix $(obj)/,$(obj-m)) +export-objs := $(addprefix $(obj)/,$(export-objs)) +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) +real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) +real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) +multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) +multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) +multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) +multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) +subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) +clean-files := $(addprefix $(obj)/,$(clean-files)) +host-progs := $(addprefix $(obj)/,$(host-progs)) +host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) +host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) +host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) + +# The temporary file to save gcc -MD generated dependencies must not +# contain a comma +depfile = $(subst $(comma),_,$(@D)/.$(@F).d) + +# =========================================================================== + # If a Makefile does not define a L_TARGET, link an object called "built-in.o" ifdef L_TARGET @@ -10,9 +135,9 @@ else O_TARGET := $(obj)/built-in.o endif -first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ - $(if $(KBUILD_MODULES),$(obj-m)) \ - $(subdir-ym) +__build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ + $(if $(KBUILD_MODULES),$(obj-m)) \ + $(subdir-ym) @: # Compile C sources (.c) @@ -35,25 +160,25 @@ c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \ $(export_flags) -quiet_cmd_cc_s_c = CC $(echo_target) +quiet_cmd_cc_s_c = CC $@ cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< %.s: %.c FORCE $(call if_changed_dep,cc_s_c) -quiet_cmd_cc_i_c = CPP $(echo_target) +quiet_cmd_cc_i_c = CPP $@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< %.i: %.c FORCE $(call if_changed_dep,cc_i_c) -quiet_cmd_cc_o_c = CC $(echo_target) +quiet_cmd_cc_o_c = CC $@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< %.o: %.c FORCE $(call if_changed_dep,cc_o_c) -quiet_cmd_cc_lst_c = MKLST $(echo_target) +quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && sh scripts/makelst $*.o System.map $(OBJDUMP) > $@ %.lst: %.c FORCE @@ -70,13 +195,13 @@ $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \ $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) -quiet_cmd_as_s_S = CPP $(echo_target) +quiet_cmd_as_s_S = CPP $@ cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< %.s: %.S FORCE $(call if_changed_dep,as_s_S) -quiet_cmd_as_o_S = AS $(echo_target) +quiet_cmd_as_o_S = AS $@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< %.o: %.S FORCE @@ -94,7 +219,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; # Rule to compile a set of .o files into one .o file # ifdef O_TARGET -quiet_cmd_link_o_target = LD $(echo_target) +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), $^),\ @@ -110,7 +235,7 @@ endif # O_TARGET # Rule to compile a set of .o files into one .a file # ifdef L_TARGET -quiet_cmd_link_l_target = AR $(echo_target) +quiet_cmd_link_l_target = AR $@ cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y) $(L_TARGET): $(obj-y) FORCE @@ -123,7 +248,7 @@ endif # Rule to link composite objects # -quiet_cmd_link_multi = LD $(echo_target) +quiet_cmd_link_multi = LD $@ cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^) # We would rather have a list of rules like @@ -141,7 +266,7 @@ targets += $(multi-used-y) $(multi-used-m) # Compile programs on the host # =========================================================================== -quiet_cmd_host_cc__c = HOSTCC $(echo_target) +quiet_cmd_host_cc__c = HOSTCC $@ cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \ $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ $(HOST_LOADLIBES) -o $@ $< @@ -149,14 +274,14 @@ cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \ $(host-progs-single): %: %.c FORCE $(call if_changed_dep,host_cc__c) -quiet_cmd_host_cc_o_c = HOSTCC $(echo_target) +quiet_cmd_host_cc_o_c = HOSTCC $@ cmd_host_cc_o_c = $(HOSTCC) -Wp,-MD,$(depfile) \ $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) -c -o $@ $< $(host-progs-multi-objs): %.o: %.c FORCE $(call if_changed_dep,host_cc_o_c) -quiet_cmd_host_cc__o = HOSTLD $(echo_target) +quiet_cmd_host_cc__o = HOSTLD $@ cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(subst $(obj)/,,$@)-objs)) \ $(HOST_LOADLIBES) @@ -165,3 +290,133 @@ $(host-progs-multi): %: $(host-progs-multi-objs) FORCE targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi) +# Shipped files +# =========================================================================== + +quiet_cmd_shipped = SHIPPED $@ +cmd_shipped = cat $< > $@ + +%:: %_shipped + $(call cmd,shipped) + +# Commands useful for building a boot image +# =========================================================================== +# +# Use as following: +# +# target: source(s) FORCE +# $(if_changed,ld/objcopy/gzip) +# +# and add target to EXTRA_TARGETS so that we know we have to +# read in the saved command line + +# Linking +# --------------------------------------------------------------------------- + +quiet_cmd_ld = LD $@ +cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ + $(filter-out FORCE,$^) -o $@ + +# Objcopy +# --------------------------------------------------------------------------- + +quiet_cmd_objcopy = OBJCOPY $@ +cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ + +# Gzip +# --------------------------------------------------------------------------- + +quiet_cmd_gzip = GZIP $@ +cmd_gzip = gzip -f -9 < $< > $@ + +# =========================================================================== +# Generic stuff +# =========================================================================== + +# Descending +# --------------------------------------------------------------------------- + +.PHONY: $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) -f scripts/Makefile.build obj=$@ + +# Add FORCE to the prequisites of a target to force it to be always rebuilt. +# --------------------------------------------------------------------------- + +.PHONY: FORCE + +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + include $(cmd_files) +endif + +# function to only execute the passed command if necessary + +if_changed = $(if $(strip $? \ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ + $(cmd_$(1)); \ + echo 'cmd_$@ := $(cmd_$(1))' > $(@D)/.$(@F).cmd) + + +# execute the command and also postprocess generated .d dependencies +# file + +if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ + $(cmd_$(1)); \ + scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \ + rm -f $(depfile); \ + mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) + +# Usage: $(call if_changed_rule,foo) +# will check if $(cmd_foo) changed, or any of the prequisites changed, +# and if so will execute $(rule_foo) + +if_changed_rule = $(if $(strip $? \ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + mkdir -p $(dir $@); \ + $(rule_$(1))) + +# If quiet is set, only print short version of command + +cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) + +# do_cmd is a shorthand used to support both compressed, verbose +# and silent output in a single line. +# Compared to cmd described avobe, do_cmd does no rely on any variables +# previously assigned a value. +# +# Usage $(call do_cmd,CMD $@,cmd_to_execute bla bla) +# Example: +# $(call do_cmd,CP $@,cp -b $< $@) +# make -s => nothing will be printed +# make KBUILD_VERBOSE=1 => cp -b path/to/src.file path/to/dest.file +# make KBUILD_VERBOSE=0 => CP path/to/dest.file +define do_cmd + @$(if $(filter quiet_,$(quiet)), echo ' $(1)' &&, + $(if $(filter silent_,$(quiet)),, + echo "$(2)" &&)) \ + $(2) +endef + +# $(call descend,,) +# Recursively call a sub-make in with target + +descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 14a71984c6e4..a1fac8bdfc77 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -39,8 +39,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) __clean-files := $(wildcard $(EXTRA_TARGETS) $(host-progs) $(clean-files)) -quiet_cmd_clean = CLEAN $(__cleanfiles) - cmd_clean = rm -f $(__clean-files); $(clean-rule) +quiet_cmd_clean = CLEAN $(obj) + cmd_clean = rm -f $(__clean-files); $(clean-rule) __clean: $(subdir-ymn) ifneq ($(strip $(__clean-files) $(clean-rule)),) @@ -58,7 +58,7 @@ endif .PHONY: $(subdir-ymn) $(subdir-ymn): - $(Q)$(MAKE) -rR -f scripts/Makefile.clean obj=$@ + $(Q)$(MAKE) -f scripts/Makefile.clean obj=$@ # If quiet is set, only print short version of command diff --git a/scripts/Makefile.modver b/scripts/Makefile.modver index 2b9a2a68ffa7..fedd0bd94b8f 100644 --- a/scripts/Makefile.modver +++ b/scripts/Makefile.modver @@ -2,12 +2,110 @@ # Module versions # =========================================================================== +src := $(obj) + +no-rules.make := 1 + +.PHONY: modver +modver: + +include .config + +include $(obj)/Makefile + +# Figure out what we need to build from the various variables +# =========================================================================== + +# 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)) + +# 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)) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) +subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) + +# 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)) + +# if $(foo-objs) exists, foo.o is a composite object +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)))) + +# 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))) +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))) $(EXTRA_TARGETS) +real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) + +# Only build module versions for files which are selected to be built +export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) + +host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) +host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) +host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) + +# Add subdir path + +EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) +obj-y := $(addprefix $(obj)/,$(obj-y)) +obj-m := $(addprefix $(obj)/,$(obj-m)) +export-objs := $(addprefix $(obj)/,$(export-objs)) +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) +real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) +real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) +multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) +multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) +multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) +multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) +subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) +clean-files := $(addprefix $(obj)/,$(clean-files)) +host-progs := $(addprefix $(obj)/,$(host-progs)) +host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) +host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) +host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) + +# The temporary file to save gcc -MD generated dependencies must not +# contain a comma +depfile = $(subst $(comma),_,$(@D)/.$(@F).d) + +# =========================================================================== + ifeq ($(strip $(export-objs)),) # If we don't export any symbols in this dir, just descend # --------------------------------------------------------------------------- -fastdep: $(subdir-ym) +modver: $(subdir-ym) @: else @@ -55,7 +153,7 @@ cmd_cc_ver_c = $(CPP) $(c_flags) $< | $(GENKSYMS) $(genksyms_smp_prefix) \ # o If the $(CPP) fails, we won't notice because it's output is piped # to $(GENKSYMS) which does not fail. We recognize this case by # looking if the generated $(depfile) exists, though. -# o If the .ver file changed, touch modversions.h, which is our maker +# o If the .ver file changed, touch modversions.h, which is our marker # of any changed .ver files. # o Move command line and deps into their normal .*.cmd place. @@ -72,14 +170,63 @@ define rule_cc_ver_c mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd endef +targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)) + $(MODVERDIR)/%.ver: %.c FORCE @$(call if_changed_rule,cc_ver_c) -targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)) - -fastdep: $(targets) $(subdir-ym) +modver: $(targets) $(subdir-ym) @mkdir -p $(dir $(addprefix .tmp_export-objs/modules/,$(export-objs:.o=.ver))) @touch $(addprefix .tmp_export-objs/modules/,$(export-objs:.o=.ver)) endif # export-objs +# Shipped files +# =========================================================================== + +quiet_cmd_shipped = SHIPPED $@ +cmd_shipped = cat $< > $@ + +%:: %_shipped + $(call cmd,shipped) + +# =========================================================================== +# Generic stuff +# =========================================================================== + +# Descending +# --------------------------------------------------------------------------- + +.PHONY: $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) -f scripts/Makefile.modver obj=$@ + +# Add FORCE to the prequisites of a target to force it to be always rebuilt. +# --------------------------------------------------------------------------- + +.PHONY: FORCE + +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + include $(cmd_files) +endif + +# Usage: $(call if_changed_rule,foo) +# will check if $(cmd_foo) changed, or any of the prequisites changed, +# and if so will execute $(rule_foo) + +if_changed_rule = $(if $(strip $? \ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + mkdir -p $(dir $@); \ + $(rule_$(1))) -- cgit v1.2.3 From 1752729653ae35381ace4aa664c868e6e263db97 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 23 Oct 2002 11:59:59 -0500 Subject: kbuild: Allow for -y as well as -objs for multipart objects. Traditionally, the individual components of a multipart module are listed in -objs. Allow for using -y as well, as that turns out to simplify declaring optional parts of multi-part modules, see the converted examples in net/*/Makefile. This change is backwards-compatible, i.e. not converted Makefiles still work just fine. --- net/appletalk/Makefile | 1 - net/ax25/Makefile | 1 - net/bluetooth/rfcomm/Makefile | 3 +-- net/decnet/Makefile | 1 - net/ipx/Makefile | 1 - net/irda/Makefile | 1 - net/llc/Makefile | 1 - net/netrom/Makefile | 1 - net/rose/Makefile | 1 - net/sctp/Makefile | 2 -- net/sunrpc/Makefile | 1 - net/unix/Makefile | 1 - net/x25/Makefile | 1 - scripts/Makefile.build | 14 +++++++------- 14 files changed, 8 insertions(+), 22 deletions(-) (limited to 'scripts') diff --git a/net/appletalk/Makefile b/net/appletalk/Makefile index 0f8309f9d5a6..997f49b4f03b 100644 --- a/net/appletalk/Makefile +++ b/net/appletalk/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_ATALK) += appletalk.o appletalk-y := aarp.o ddp.o atalk_proc.o appletalk-$(CONFIG_SYSCTL) += sysctl_net_atalk.o -appletalk-objs := $(appletalk-y) include $(TOPDIR)/Rules.make diff --git a/net/ax25/Makefile b/net/ax25/Makefile index 8233831615c0..4117987a132a 100644 --- a/net/ax25/Makefile +++ b/net/ax25/Makefile @@ -11,7 +11,6 @@ ax25-y := ax25_addr.o ax25_dev.o ax25_iface.o ax25_in.o ax25_ip.o ax25_out.o \ ax25_subr.o ax25_timer.o ax25_uid.o af_ax25.o ax25-$(CONFIG_AX25_DAMA_SLAVE) += ax25_ds_in.o ax25_ds_subr.o ax25_ds_timer.o ax25-$(CONFIG_SYSCTL) += sysctl_net_ax25.o -ax25-objs := $(ax25-y) include $(TOPDIR)/Rules.make diff --git a/net/bluetooth/rfcomm/Makefile b/net/bluetooth/rfcomm/Makefile index 9cae42fee3d6..fad3b0c5066d 100644 --- a/net/bluetooth/rfcomm/Makefile +++ b/net/bluetooth/rfcomm/Makefile @@ -4,8 +4,7 @@ obj-$(CONFIG_BT_RFCOMM) += rfcomm.o -rfcomm-y := core.o sock.o crc.o +rfcomm-y := core.o sock.o crc.o rfcomm-$(CONFIG_BT_RFCOMM_TTY) += tty.o -rfcomm-objs := $(rfcomm-y) include $(TOPDIR)/Rules.make diff --git a/net/decnet/Makefile b/net/decnet/Makefile index 74a8bae054e7..f08bc37384d9 100644 --- a/net/decnet/Makefile +++ b/net/decnet/Makefile @@ -5,7 +5,6 @@ decnet-y := af_decnet.o dn_nsp_in.o dn_nsp_out.o dn_route.o dn_dev.o dn_neigh.o decnet-$(CONFIG_DECNET_ROUTER) += dn_fib.o dn_rules.o dn_table.o decnet-$(CONFIG_DECNET_FW) += dn_fw.o decnet-y += sysctl_net_decnet.o -decnet-objs := $(decnet-y) include $(TOPDIR)/Rules.make diff --git a/net/ipx/Makefile b/net/ipx/Makefile index e17fffc815d8..95d20a027109 100644 --- a/net/ipx/Makefile +++ b/net/ipx/Makefile @@ -6,6 +6,5 @@ obj-$(CONFIG_IPX) += ipx.o ipx-y := af_ipx.o ipx_proc.o ipx-$(CONFIG_SYSCTL) += sysctl_net_ipx.o -ipx-objs := $(ipx-y) include $(TOPDIR)/Rules.make diff --git a/net/irda/Makefile b/net/irda/Makefile index 380ae32c8eab..eb5561eec5e2 100644 --- a/net/irda/Makefile +++ b/net/irda/Makefile @@ -15,6 +15,5 @@ irda-y := iriap.o iriap_event.o irlmp.o irlmp_event.o irlmp_frame.o \ discovery.o parameters.o irsyms.o irda-$(CONFIG_PROC_FS) += irproc.o irda-$(CONFIG_SYSCTL) += irsysctl.o -irda-objs := $(irda-y) include $(TOPDIR)/Rules.make diff --git a/net/llc/Makefile b/net/llc/Makefile index 5c9a53fe6988..b2fde6ef561e 100644 --- a/net/llc/Makefile +++ b/net/llc/Makefile @@ -18,7 +18,6 @@ llc-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_mac.o llc_sap.o llc_s_st.o \ llc_main.o llc_s_ac.o llc_conn.o llc_c_st.o llc_stat.o llc_actn.o \ llc_s_ev.o llc_evnt.o llc_pdu.o llc_proc.o llc-$(CONFIG_LLC_UI) += af_llc.o -llc-objs := $(llc-y) # Objects that export symbols. export-objs := llc_if.o diff --git a/net/netrom/Makefile b/net/netrom/Makefile index 1992013851b5..6f5c9ad566d6 100644 --- a/net/netrom/Makefile +++ b/net/netrom/Makefile @@ -7,7 +7,6 @@ obj-$(CONFIG_NETROM) += netrom.o netrom-y := af_netrom.o nr_dev.o nr_in.o nr_loopback.o \ nr_out.o nr_route.o nr_subr.o nr_timer.o netrom-$(CONFIG_SYSCTL) += sysctl_net_netrom.o -netrom-objs := $(netrom-y) include $(TOPDIR)/Rules.make diff --git a/net/rose/Makefile b/net/rose/Makefile index cc9688cd6f39..4e1d25f93144 100644 --- a/net/rose/Makefile +++ b/net/rose/Makefile @@ -7,7 +7,6 @@ obj-$(CONFIG_ROSE) += rose.o rose-y := af_rose.o rose_dev.o rose_in.o rose_link.o rose_loopback.o \ rose_out.o rose_route.o rose_subr.o rose_timer.o rose-$(CONFIG_SYSCTL) += sysctl_net_rose.o -rose-objs := $(rose-y) include $(TOPDIR)/Rules.make diff --git a/net/sctp/Makefile b/net/sctp/Makefile index 3e0bb4c05287..602cebb0361f 100644 --- a/net/sctp/Makefile +++ b/net/sctp/Makefile @@ -23,6 +23,4 @@ sctp-$(CONFIG_SYSCTL) += sysctl.o sctp-$(subst m,y,$(CONFIG_IPV6)) += ipv6.o -sctp-objs := $(sctp-y) - include $(TOPDIR)/Rules.make diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile index 33275b9a78ad..6070ace3b94c 100644 --- a/net/sunrpc/Makefile +++ b/net/sunrpc/Makefile @@ -13,6 +13,5 @@ sunrpc-y := clnt.o xprt.o sched.o \ sunrpc_syms.o cache.o sunrpc-$(CONFIG_PROC_FS) += stats.o sunrpc-$(CONFIG_SYSCTL) += sysctl.o -sunrpc-objs := $(sunrpc-y) include $(TOPDIR)/Rules.make diff --git a/net/unix/Makefile b/net/unix/Makefile index 4c8e36185709..b590913e9025 100644 --- a/net/unix/Makefile +++ b/net/unix/Makefile @@ -6,7 +6,6 @@ obj-$(CONFIG_UNIX) += unix.o unix-y := af_unix.o garbage.o unix-$(CONFIG_SYSCTL) += sysctl_net_unix.o -unix-objs := $(unix-y) include $(TOPDIR)/Rules.make diff --git a/net/x25/Makefile b/net/x25/Makefile index eb24260baafc..bdc6c4825951 100644 --- a/net/x25/Makefile +++ b/net/x25/Makefile @@ -8,7 +8,6 @@ x25-y := af_x25.o x25_dev.o x25_facilities.o x25_in.o \ x25_link.o x25_out.o x25_route.o x25_subr.o \ x25_timer.o x25_proc.o x25-$(CONFIG_SYSCTL) += sysctl_net_x25.o -x25-objs := $(x25-y) include $(TOPDIR)/Rules.make diff --git a/scripts/Makefile.build b/scripts/Makefile.build index dab20c07e6b1..31836de5f958 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -77,21 +77,21 @@ __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 $($(m:.o=-objs)), $(m)))) -multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $($(m:.o=-objs)), $(m)))) +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)))) # 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))) -multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs))) +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))) # $(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))) $(EXTRA_TARGETS) -real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) +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))) # Only build module versions for files which are selected to be built export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) @@ -249,7 +249,7 @@ endif # quiet_cmd_link_multi = LD $@ -cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs)))),$^) +cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^) # We would rather have a list of rules like # foo.o: $(foo-objs) -- cgit v1.2.3 From 54a6c2fce5739f5a9c084f14555763f3d5c97e5e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 25 Oct 2002 02:25:46 +0200 Subject: kbuild: Removed unused definitions o Deleted subdir-n and subdir- handling in Makefile.build o Deleted all host-progs related stuff in Makfile.modver o In Makefile.modver also deleted everything related to composite objects o Fixed an error when deleting a .ver file + .hdepend and then do make - filter-out in Makefile.modver was faulty --- scripts/Makefile.build | 13 +------------ scripts/Makefile.clean | 2 -- scripts/Makefile.modinst | 4 ---- scripts/Makefile.modver | 46 +++++----------------------------------------- 4 files changed, 6 insertions(+), 59 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 31836de5f958..134632c805d0 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -4,8 +4,6 @@ src := $(obj) -no-rules.make := 1 - .PHONY: __build __build: @@ -16,8 +14,6 @@ include $(obj)/Makefile # Standard vars comma := , -empty := -space := $(empty) $(empty) # bug traps # =========================================================================== @@ -37,7 +33,7 @@ $(warning kbuild: $(obj)/Makefile - list-multi := $(list-multi) is obsolete in 2 endif ifndef obj -$(warning kbuild: Rules.make is included improperly) +$(warning kbuild: Makefile.build is included improperly) endif # Figure out what we need to build from the various variables @@ -59,17 +55,12 @@ __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)) # Subdirectories we need to descend into subdir-ym := $(sort $(subdir-y) $(subdir-m)) -subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) # export.o is never a composite object, since $(export-objs) has a # fixed meaning (== objects which EXPORT_SYMBOL()) @@ -114,8 +105,6 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) -clean-files := $(addprefix $(obj)/,$(clean-files)) host-progs := $(addprefix $(obj)/,$(host-progs)) host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index a1fac8bdfc77..2c843e0380bc 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -4,8 +4,6 @@ src := $(obj) -no-rules.make := 1 - .PHONY: __clean __clean: diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 6dcc5b132fb1..f3151345afac 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -4,15 +4,11 @@ src := $(obj) -no-rules.make := 1 - .PHONY: modules_install modules_install: include .config -#$(warning $(CONFIG_X86)) - include $(obj)/Makefile # Figure out what we need to build from the various variables diff --git a/scripts/Makefile.modver b/scripts/Makefile.modver index fedd0bd94b8f..4499c5dfbdef 100644 --- a/scripts/Makefile.modver +++ b/scripts/Makefile.modver @@ -4,8 +4,6 @@ src := $(obj) -no-rules.make := 1 - .PHONY: modver modver: @@ -13,6 +11,10 @@ include .config include $(obj)/Makefile +# Standard vars + +comma := , + # Figure out what we need to build from the various variables # =========================================================================== @@ -32,31 +34,11 @@ __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)) # Subdirectories we need to descend into - subdir-ym := $(sort $(subdir-y) $(subdir-m)) -subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) - -# 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)) - -# if $(foo-objs) exists, foo.o is a composite object -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)))) - -# 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))) -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 @@ -69,30 +51,12 @@ real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m # Only build module versions for files which are selected to be built export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) -host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) -host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) -host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) - # Add subdir path -EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) -obj-y := $(addprefix $(obj)/,$(obj-y)) -obj-m := $(addprefix $(obj)/,$(obj-m)) export-objs := $(addprefix $(obj)/,$(export-objs)) -subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) -multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) -multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) -multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) -multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) -clean-files := $(addprefix $(obj)/,$(clean-files)) -host-progs := $(addprefix $(obj)/,$(host-progs)) -host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) -host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) -host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) # The temporary file to save gcc -MD generated dependencies must not # contain a comma @@ -128,7 +92,7 @@ endif # Don't include modversions.h, we're just about to generate it here. -CFLAGS_MODULE := $(filter-out -include linux/modversions.h,$(CFLAGS_MODULE)) +CFLAGS_MODULE := $(filter-out -include include/linux/modversions.h,$(CFLAGS_MODULE)) $(addprefix $(MODVERDIR)/,$(real-objs-y:.o=.ver)): modkern_cflags := $(CFLAGS_KERNEL) $(addprefix $(MODVERDIR)/,$(real-objs-m:.o=.ver)): modkern_cflags := $(CFLAGS_MODULE) -- cgit v1.2.3 From 675f908dd724899613fc21ef1bed5bae69aa18d8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 27 Oct 2002 22:16:30 +0100 Subject: kbuild: scrits/Makefile.lib Moved generic definitions to Makefile.lib, This allows us to share all generic definitions between the different Makefiles. Performance impact has been measured to less than 1% --- scripts/Makefile.build | 190 +------------------------------------------------ scripts/Makefile.lib | 190 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 189 deletions(-) create mode 100644 scripts/Makefile.lib (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 134632c805d0..cd75f49b58f9 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -11,12 +11,7 @@ include .config include $(obj)/Makefile -# Standard vars - -comma := , - -# bug traps -# =========================================================================== +include scripts/Makefile.lib ifdef O_TARGET $(error kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.5. Please fix!) @@ -36,84 +31,6 @@ ifndef obj $(warning kbuild: Makefile.build is included improperly) endif -# Figure out what we need to build from the various variables -# =========================================================================== - -# 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)) - -# 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) -obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) -obj-m := $(filter-out %/, $(obj-m)) - -# Subdirectories we need to descend into - -subdir-ym := $(sort $(subdir-y) $(subdir-m)) - -# 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)) - -# 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)))) - -# 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))) - -# $(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 $(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))) - -# Only build module versions for files which are selected to be built -export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) - -host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) -host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) -host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) - -# Add subdir path - -EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) -obj-y := $(addprefix $(obj)/,$(obj-y)) -obj-m := $(addprefix $(obj)/,$(obj-m)) -export-objs := $(addprefix $(obj)/,$(export-objs)) -subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) -real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) -real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) -multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) -multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) -multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) -multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) -subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -host-progs := $(addprefix $(obj)/,$(host-progs)) -host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) -host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) -host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) - -# The temporary file to save gcc -MD generated dependencies must not -# contain a comma -depfile = $(subst $(comma),_,$(@D)/.$(@F).d) - # =========================================================================== # If a Makefile does not define a L_TARGET, link an object called "built-in.o" @@ -279,49 +196,6 @@ $(host-progs-multi): %: $(host-progs-multi-objs) FORCE targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi) -# Shipped files -# =========================================================================== - -quiet_cmd_shipped = SHIPPED $@ -cmd_shipped = cat $< > $@ - -%:: %_shipped - $(call cmd,shipped) - -# Commands useful for building a boot image -# =========================================================================== -# -# Use as following: -# -# target: source(s) FORCE -# $(if_changed,ld/objcopy/gzip) -# -# and add target to EXTRA_TARGETS so that we know we have to -# read in the saved command line - -# Linking -# --------------------------------------------------------------------------- - -quiet_cmd_ld = LD $@ -cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ - $(filter-out FORCE,$^) -o $@ - -# Objcopy -# --------------------------------------------------------------------------- - -quiet_cmd_objcopy = OBJCOPY $@ -cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ - -# Gzip -# --------------------------------------------------------------------------- - -quiet_cmd_gzip = GZIP $@ -cmd_gzip = gzip -f -9 < $< > $@ - -# =========================================================================== -# Generic stuff -# =========================================================================== - # Descending # --------------------------------------------------------------------------- @@ -347,65 +221,3 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif - -# function to only execute the passed command if necessary - -if_changed = $(if $(strip $? \ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ - $(cmd_$(1)); \ - echo 'cmd_$@ := $(cmd_$(1))' > $(@D)/.$(@F).cmd) - - -# execute the command and also postprocess generated .d dependencies -# file - -if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ - $(cmd_$(1)); \ - scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \ - rm -f $(depfile); \ - mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) - -# Usage: $(call if_changed_rule,foo) -# will check if $(cmd_foo) changed, or any of the prequisites changed, -# and if so will execute $(rule_foo) - -if_changed_rule = $(if $(strip $? \ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - mkdir -p $(dir $@); \ - $(rule_$(1))) - -# If quiet is set, only print short version of command - -cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) - -# do_cmd is a shorthand used to support both compressed, verbose -# and silent output in a single line. -# Compared to cmd described avobe, do_cmd does no rely on any variables -# previously assigned a value. -# -# Usage $(call do_cmd,CMD $@,cmd_to_execute bla bla) -# Example: -# $(call do_cmd,CP $@,cp -b $< $@) -# make -s => nothing will be printed -# make KBUILD_VERBOSE=1 => cp -b path/to/src.file path/to/dest.file -# make KBUILD_VERBOSE=0 => CP path/to/dest.file -define do_cmd - @$(if $(filter quiet_,$(quiet)), echo ' $(1)' &&, - $(if $(filter silent_,$(quiet)),, - echo "$(2)" &&)) \ - $(2) -endef - -# $(call descend,,) -# Recursively call a sub-make in with target - -descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib new file mode 100644 index 000000000000..73668ee0fbea --- /dev/null +++ b/scripts/Makefile.lib @@ -0,0 +1,190 @@ +# =========================================================================== +# kbuild: Generic definitions +# =========================================================================== + +# Standard vars + +comma := , + +# Figure out what we need to build from the various variables +# =========================================================================== + +# 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)) + +# 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) +obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) +obj-m := $(filter-out %/, $(obj-m)) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) + +# 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)) + +# 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)))) + +# 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))) + +# $(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 $(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))) + +# Only build module versions for files which are selected to be built +export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) + +host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) +host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) +host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) + +# Add subdir path + +EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) +obj-y := $(addprefix $(obj)/,$(obj-y)) +obj-m := $(addprefix $(obj)/,$(obj-m)) +export-objs := $(addprefix $(obj)/,$(export-objs)) +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) +real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) +real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) +multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) +multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) +multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) +multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) +host-progs := $(addprefix $(obj)/,$(host-progs)) +host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) +host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) +host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) + +# The temporary file to save gcc -MD generated dependencies must not +# contain a comma +depfile = $(subst $(comma),_,$(@D)/.$(@F).d) + +# Shipped files +# =========================================================================== + +quiet_cmd_shipped = SHIPPED $@ +cmd_shipped = cat $< > $@ + +%:: %_shipped + $(call cmd,shipped) + +# Commands useful for building a boot image +# =========================================================================== +# +# Use as following: +# +# target: source(s) FORCE +# $(if_changed,ld/objcopy/gzip) +# +# and add target to EXTRA_TARGETS so that we know we have to +# read in the saved command line + +# Linking +# --------------------------------------------------------------------------- + +quiet_cmd_ld = LD $@ +cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ + $(filter-out FORCE,$^) -o $@ + +# Objcopy +# --------------------------------------------------------------------------- + +quiet_cmd_objcopy = OBJCOPY $@ +cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ + +# Gzip +# --------------------------------------------------------------------------- + +quiet_cmd_gzip = GZIP $@ +cmd_gzip = gzip -f -9 < $< > $@ + +# =========================================================================== +# Generic stuff +# =========================================================================== + +# function to only execute the passed command if necessary + +if_changed = $(if $(strip $? \ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ + $(cmd_$(1)); \ + echo 'cmd_$@ := $(cmd_$(1))' > $(@D)/.$(@F).cmd) + + +# execute the command and also postprocess generated .d dependencies +# file + +if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ + $(cmd_$(1)); \ + scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \ + rm -f $(depfile); \ + mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) + +# Usage: $(call if_changed_rule,foo) +# will check if $(cmd_foo) changed, or any of the prequisites changed, +# and if so will execute $(rule_foo) + +if_changed_rule = $(if $(strip $? \ + $(filter-out $(cmd_$(1)),$(cmd_$@))\ + $(filter-out $(cmd_$@),$(cmd_$(1)))),\ + @set -e; \ + mkdir -p $(dir $@); \ + $(rule_$(1))) + +# If quiet is set, only print short version of command + +cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) + +# do_cmd is a shorthand used to support both compressed, verbose +# and silent output in a single line. +# Compared to cmd described avobe, do_cmd does no rely on any variables +# previously assigned a value. +# +# Usage $(call do_cmd,CMD $@,cmd_to_execute bla bla) +# Example: +# $(call do_cmd,CP $@,cp -b $< $@) +# make -s => nothing will be printed +# make KBUILD_VERBOSE=1 => cp -b path/to/src.file path/to/dest.file +# make KBUILD_VERBOSE=0 => CP path/to/dest.file +define do_cmd + @$(if $(filter quiet_,$(quiet)), echo ' $(1)' &&, + $(if $(filter silent_,$(quiet)),, + echo "$(2)" &&)) \ + $(2) +endef + +# $(call descend,,) +# Recursively call a sub-make in with target + +descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) -- cgit v1.2.3 From b6ebbc09df40b98dcff43de458c9a234b169ccae Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 27 Oct 2002 22:30:40 +0100 Subject: kbuild: Use Makefile.lib for modversion and modules_install Most definitions required were present in Makefile.lib, so delete the definitions and include Makefile.lib. --- scripts/Makefile.modinst | 31 +------------------- scripts/Makefile.modver | 75 +----------------------------------------------- 2 files changed, 2 insertions(+), 104 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index f3151345afac..626a9a95866c 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -11,28 +11,7 @@ include .config include $(obj)/Makefile -# Figure out what we need to build from the various variables -# ========================================================================== - -# 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)) - -__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) -subdir-y += $(__subdir-y) -__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) -subdir-m += $(__subdir-m) -obj-m := $(filter-out %/, $(obj-m)) - -# Subdirectories we need to descend into - -subdir-ym := $(sort $(subdir-y) $(subdir-m)) - -# Add subdir path - -obj-m := $(addprefix $(obj)/,$(obj-m)) -subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) +include scripts/Makefile.lib # ========================================================================== @@ -47,17 +26,9 @@ else @: endif -# =========================================================================== -# Generic stuff -# =========================================================================== - # Descending # --------------------------------------------------------------------------- .PHONY: $(subdir-ym) $(subdir-ym): $(Q)$(MAKE) -rR -f scripts/Makefile.modinst obj=$@ - -# If quiet is set, only print short version of command - -cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) diff --git a/scripts/Makefile.modver b/scripts/Makefile.modver index 4499c5dfbdef..0ee922a3aadf 100644 --- a/scripts/Makefile.modver +++ b/scripts/Makefile.modver @@ -11,56 +11,7 @@ include .config include $(obj)/Makefile -# Standard vars - -comma := , - -# Figure out what we need to build from the various variables -# =========================================================================== - -# 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)) - -# 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) -obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) -obj-m := $(filter-out %/, $(obj-m)) - -# Subdirectories we need to descend into -subdir-ym := $(sort $(subdir-y) $(subdir-m)) - -# $(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))) $(EXTRA_TARGETS) -real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) - -# Only build module versions for files which are selected to be built -export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) - -# Add subdir path - -export-objs := $(addprefix $(obj)/,$(export-objs)) -real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) -real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) -subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) - -# The temporary file to save gcc -MD generated dependencies must not -# contain a comma -depfile = $(subst $(comma),_,$(@D)/.$(@F).d) +include scripts/Makefile.lib # =========================================================================== @@ -145,19 +96,6 @@ modver: $(targets) $(subdir-ym) endif # export-objs -# Shipped files -# =========================================================================== - -quiet_cmd_shipped = SHIPPED $@ -cmd_shipped = cat $< > $@ - -%:: %_shipped - $(call cmd,shipped) - -# =========================================================================== -# Generic stuff -# =========================================================================== - # Descending # --------------------------------------------------------------------------- @@ -183,14 +121,3 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif - -# Usage: $(call if_changed_rule,foo) -# will check if $(cmd_foo) changed, or any of the prequisites changed, -# and if so will execute $(rule_foo) - -if_changed_rule = $(if $(strip $? \ - $(filter-out $(cmd_$(1)),$(cmd_$@))\ - $(filter-out $(cmd_$@),$(cmd_$(1)))),\ - @set -e; \ - mkdir -p $(dir $@); \ - $(rule_$(1))) -- cgit v1.2.3 From c23e6bf05f7802e92fd3da69a1ed35e56f9c85bb Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Mon, 28 Oct 2002 01:16:34 -0600 Subject: kbuild: Fix a "make -j" warning --- scripts/Makefile.clean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 2c843e0380bc..e7c392fd5788 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -42,7 +42,7 @@ quiet_cmd_clean = CLEAN $(obj) __clean: $(subdir-ymn) ifneq ($(strip $(__clean-files) $(clean-rule)),) - $(call cmd,clean) + +$(call cmd,clean) else @: endif -- cgit v1.2.3