diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Kbuild.include | 100 | ||||
-rw-r--r-- | scripts/Makefile | 7 | ||||
-rw-r--r-- | scripts/Makefile.build | 5 | ||||
-rw-r--r-- | scripts/Makefile.headersinst | 126 | ||||
-rw-r--r-- | scripts/Makefile.host | 20 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 13 | ||||
-rw-r--r-- | scripts/basic/docproc.c | 1 | ||||
-rwxr-xr-x | scripts/checkstack.pl | 2 | ||||
-rw-r--r-- | scripts/gcc-x86_64-has-stack-protector.sh | 6 | ||||
-rwxr-xr-x | scripts/hdrcheck.sh | 2 | ||||
-rw-r--r-- | scripts/kconfig/Makefile | 1 | ||||
-rw-r--r-- | scripts/kconfig/confdata.c | 8 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 24 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 42 | ||||
-rwxr-xr-x | scripts/package/mkspec | 4 | ||||
-rw-r--r-- | scripts/unifdef.c | 1005 |
16 files changed, 1271 insertions, 95 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index bb19c1561f1..4f5ff19b992 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -8,9 +8,13 @@ empty := space := $(empty) $(empty) ### +# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o +dot-target = $(dir $@).$(notdir $@) + +### # The temporary file to save gcc -MD generated dependencies must not # contain a comma -depfile = $(subst $(comma),_,$(@D)/.$(@F).d) +depfile = $(subst $(comma),_,$(dot-target).d) ### # filename of target with directory and extension stripped @@ -59,6 +63,13 @@ as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ else echo "$(2)"; fi ;) +# as-instr +# Usage: cflags-y += $(call as-instr, instr, option1, option2) + +as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o astest$$$$.out ; \ + then echo "$(2)"; else echo "$(3)"; fi; \ + rm -f astest$$$$.out) + # cc-option # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) @@ -119,40 +130,83 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) ifneq ($(KBUILD_NOCMDDEP),1) # Check if both arguments has same arguments. Result in empty string if equal # User may override this check using make KBUILD_NOCMDDEP=1 -arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) ) +arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ + $(filter-out $(cmd_$@), $(cmd_$(1))) ) endif # echo command. Short version is $(quiet) equals quiet, otherwise full command echo-cmd = $(if $($(quiet)cmd_$(1)), \ - echo ' $(call escsq,$($(quiet)cmd_$(1)))';) + echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) +# >'< substitution is for echo to work, +# >$< substitution to preserve $ when reloading .cmd file +# note: when using inline perl scripts [perl -e '...$$t=1;...'] +# in $(cmd_xxx) double $$ your perl vars make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) -# function to only execute the passed command if necessary -# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file -# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars +# Find any prerequisites that is newer than target or that does not exist. +# PHONY targets skipped in both cases. +any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) + +# Execute command if command has changed or prerequisitei(s) are updated # -if_changed = $(if $(strip $(filter-out $(PHONY),$?) \ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ - @set -e; \ - $(echo-cmd) $(cmd_$(1)); \ - echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) +if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ + @set -e; \ + $(echo-cmd) $(cmd_$(1)); \ + echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) # execute the command and also postprocess generated .d dependencies # file -if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \ - $(filter-out FORCE $(wildcard $^),$^) \ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ - @set -e; \ - $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ - rm -f $(depfile); \ - mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) +if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ + @set -e; \ + $(echo-cmd) $(cmd_$(1)); \ + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ + rm -f $(depfile); \ + mv -f $(dot-target).tmp $(dot-target).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 $(PHONY),$?) \ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ - @set -e; \ - $(rule_$(1))) +if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ + @set -e; \ + $(rule_$(1))) + +### +# why - tell why a a target got build +# enabled by make V=2 +# Output (listed in the order they are checked): +# (1) - due to target is PHONY +# (2) - due to target missing +# (3) - due to: file1.h file2.h +# (4) - due to command line change +# (5) - due to missing .cmd file +# (6) - due to target not in $(targets) +# (1) PHONY targets are always build +# (2) No target, so we better build it +# (3) Prerequisite is newer than target +# (4) The command line stored in the file named dir/.target.cmd +# differed from actual command line. This happens when compiler +# options changes +# (5) No dir/.target.cmd file (used to store command line) +# (6) No dir/.target.cmd file and target not listed in $(targets) +# This is a good hint that there is a bug in the kbuild file +ifeq ($(KBUILD_VERBOSE),2) +why = \ + $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ + $(if $(wildcard $@), \ + $(if $(strip $(any-prereq)),- due to: $(any-prereq), \ + $(if $(arg-check), \ + $(if $(cmd_$@),- due to command line change, \ + $(if $(filter $@, $(targets)), \ + - due to missing .cmd file, \ + - due to $(notdir $@) not in $$(targets) \ + ) \ + ) \ + ) \ + ), \ + - due to target missing \ + ) \ + ) + +echo-why = $(call escsq, $(strip $(why))) +endif diff --git a/scripts/Makefile b/scripts/Makefile index 6f6b48f39f0..1c73c5aea66 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -13,10 +13,13 @@ hostprogs-$(CONFIG_VT) += conmakehash hostprogs-$(CONFIG_PROM_CONSOLE) += conmakehash hostprogs-$(CONFIG_IKCONFIG) += bin2c -always := $(hostprogs-y) +always := $(hostprogs-y) $(hostprogs-m) + +# The following hostprogs-y programs are only build on demand +hostprogs-y += unifdef subdir-$(CONFIG_MODVERSIONS) += genksyms -subdir-$(CONFIG_MODULES) += mod +subdir-y += mod # Let clean descend into subdirs subdir- += basic kconfig package diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 3cb445cc743..e2ad2dccccd 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -191,9 +191,10 @@ define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ $(cmd_modversions) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \ + scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ + $(dot-target).tmp; \ rm -f $(depfile); \ - mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd + mv -f $(dot-target).tmp $(dot-target).cmd endef # Built-in and composite module parts diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 12e1daf875c..cac8f21a339 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -7,7 +7,7 @@ # # ========================================================================== -UNIFDEF := unifdef -U__KERNEL__ +UNIFDEF := scripts/unifdef -U__KERNEL__ # Eliminate the contents of (and inclusions of) compiler.h HDRSED := sed -e "s/ inline / __inline__ /g" \ @@ -23,30 +23,30 @@ HDRSED := sed -e "s/ inline / __inline__ /g" \ _dst := $(if $(dst),$(dst),$(obj)) -.PHONY: __headersinst -__headersinst: - - ifeq (,$(patsubst include/asm/%,,$(obj)/)) # For producing the generated stuff in include/asm for biarch builds, include # both sets of Kbuild files; we'll generate anything which is mentioned in # _either_ arch, and recurse into subdirectories which are mentioned in either # arch. Since some directories may exist in one but not the other, we must -# use '-include'. +# use $(wildcard...). GENASM := 1 archasm := $(subst include/asm,asm-$(ARCH),$(obj)) altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) --include $(srctree)/include/$(archasm)/Kbuild --include $(srctree)/include/$(altarchasm)/Kbuild +KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild) else -include $(srctree)/$(obj)/Kbuild +KBUILDFILES := $(srctree)/$(obj)/Kbuild endif -include scripts/Kbuild.include +include $(KBUILDFILES) + +include scripts/Kbuild.include # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then # override $(_dst) so that we install to include/asm directly. -ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)) +# Unless $(BIASMDIR) is set, in which case we're probably doing +# a 'headers_install_all' build and we should keep the -$(ARCH) +# in the directory name. +ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR)) _dst := include/asm endif @@ -56,6 +56,23 @@ subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) header-y := $(filter-out %/, $(header-y)) header-y := $(filter-out $(unifdef-y),$(header-y)) +# stamp files for header checks +check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y)) + +# Work out what needs to be removed +oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) +unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders)) + +oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) +unwanted += $(filter-out $(check-y),$(oldcheckstamps)) + +# Prefix them all with full paths to $(INSTALL_HDR_PATH) +header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) +unifdef-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(unifdef-y)) +objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) +check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) + + ifdef ALTARCH ifeq ($(obj),include/asm-$(ARCH)) altarch-y := altarch-dir @@ -67,43 +84,47 @@ export ALTARCH export ARCHDEF export ALTARCHDEF -quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@ - cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst) +quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ + $(INSTALL_HDR_PATH)/$(_dst) -quiet_cmd_headers_install = INSTALL $(_dst)/$@ - cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ - > $(INSTALL_HDR_PATH)/$(_dst)/$@ +quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ + > $@ -quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ - cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ - > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : +quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ + | $(HDRSED) > $@ || : -quiet_cmd_check = CHECK $(_dst)/$@ +quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) cmd_check = $(srctree)/scripts/hdrcheck.sh \ - $(INSTALL_HDR_PATH)/include \ - $(INSTALL_HDR_PATH)/$(_dst)/$@ + $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ + +quiet_cmd_remove = REMOVE $(_dst)/$@ + cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ -quiet_cmd_mkdir = MKDIR $@ - cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ +quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_mkdir = mkdir -p $@ -quiet_cmd_gen = GEN $(_dst)/$@ +quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) cmd_gen = \ -STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \ +FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@) \ +STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z. A-Z_`; \ (echo "/* File autogenerated by 'make headers_install' */" ; \ echo "\#ifndef $$STUBDEF" ; \ echo "\#define $$STUBDEF" ; \ echo "\# if $(ARCHDEF)" ; \ -if [ -r $(INSTALL_HDR_PATH)/include/$(archasm)/$@ ]; then \ - echo "\# include <$(archasm)/$@>" ; \ +if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \ + echo "\# include <$(archasm)/$$FNAME>" ; \ else \ - echo "\# error $(archasm)/$@ does not exist in" \ + echo "\# error $(archasm)/$$FNAME does not exist in" \ "the $(ARCH) architecture" ; \ fi ; \ echo "\# elif $(ALTARCHDEF)" ; \ -if [ -r $(INSTALL_HDR_PATH)/include/$(altarchasm)/$@ ]; then \ - echo "\# include <$(altarchasm)/$@>" ; \ +if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \ + echo "\# include <$(altarchasm)/$$FNAME>" ; \ else \ - echo "\# error $(altarchasm)/$@ does not exist in" \ + echo "\# error $(altarchasm)/$$FNAME does not exist in" \ "the $(ALTARCH) architecture" ; \ fi ; \ echo "\# else" ; \ @@ -111,37 +132,49 @@ echo "\# warning This machine appears to be" \ "neither $(ARCH) nor $(ALTARCH)." ; \ echo "\# endif" ; \ echo "\#endif /* $$STUBDEF */" ; \ -) > $(INSTALL_HDR_PATH)/$(_dst)/$@ +) > $@ -__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) - -.PHONY: $(header-y) $(unifdef-y) $(subdir-y) +.PHONY: __headersinst __headerscheck ifdef HDRCHECK -# Rules for checking headers -$(objhdr-y) $(header-y) $(unifdef-y): +__headerscheck: $(subdir-y) $(check-y) + @true + +$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h $(call cmd,check) + +# Other dependencies for $(check-y) +-include /dev/null $(check-y) + +# ... but leave $(check-y) as .PHONY for now until those deps are actually correct. +.PHONY: $(check-y) + else # Rules for installing headers +__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) + @true -$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) +$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) -.PHONY: $(_dst) -$(_dst): +$(INSTALL_HDR_PATH)/$(_dst): $(call cmd,mkdir) +.PHONY: $(unwanted) +$(unwanted): + $(call cmd,remove) + ifdef GENASM -$(objhdr-y) $(header-y) $(unifdef-y): +$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES) $(call cmd,gen) else -$(objhdr-y): +$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) $(call cmd,o_hdr_install) -$(header-y): +$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) $(call cmd,headers_install) -$(unifdef-y): +$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) $(call cmd,unifdef) endif endif @@ -153,8 +186,9 @@ hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj # for their existence. altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y) $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) - $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm + $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR) # Recursion +.PHONY: $(subdir-y) $(subdir-y): $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 060f4c563a5..575afbe5e37 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -32,11 +32,6 @@ __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) -# hostprogs-y := tools/build may have been specified. Retreive directory -host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) -host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) - - # C code # Executables compiled from a single .c file host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) @@ -65,6 +60,21 @@ host-cobjs := $(filter-out %.so,$(host-cobjs)) #Object (.o) files used by the shared libaries host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) +# output directory for programs/.o files +# hostprogs-y := tools/build may have been specified. Retreive directory +host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) +# directory of .o files from prog-objs notation +host-objdirs += $(foreach f,$(host-cmulti), \ + $(foreach m,$($(f)-objs), \ + $(if $(dir $(m)),$(dir $(m))))) +# directory of .o files from prog-cxxobjs notation +host-objdirs += $(foreach f,$(host-cxxmulti), \ + $(foreach m,$($(f)-cxxobjs), \ + $(if $(dir $(m)),$(dir $(m))))) + +host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) + + __hostprogs := $(addprefix $(obj)/,$(__hostprogs)) host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 0a64688c2b5..4b2721ca97d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -51,19 +51,26 @@ _modpost: $(modules) # Step 2), invoke modpost # Includes step 3,4 -quiet_cmd_modpost = MODPOST +quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules cmd_modpost = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(filter-out FORCE,$^) + $(if $(KBUILD_EXTMOD),-w) \ + $(wildcard vmlinux) $(filter-out FORCE,$^) PHONY += __modpost -__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE +__modpost: $(modules:.ko=.o) FORCE $(call cmd,modpost) +quiet_cmd_kernel-mod = MODPOST $@ + cmd_kernel-mod = $(cmd_modpost) + +vmlinux: FORCE + $(call cmd,kernel-mod) + # Declare generated files as targets for modpost $(symverfile): __modpost ; $(modules:.ko=.mod.c): __modpost ; diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index cb02baa6325..4ab6cbf0922 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c @@ -177,6 +177,7 @@ void find_export_symbols(char * filename) { fprintf(stderr, "docproc: "); perror(real_filename); + exit(1); } while(fgets(line, MAXLINESZ, fp)) { char *p; diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index b34924663ac..f7844f6aa48 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -62,6 +62,8 @@ my (@stack, $re, $x, $xs); } elsif ($arch eq 'ppc64') { #XXX $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o; + } elsif ($arch eq 'powerpc') { + $re = qr/.*st[dw]u.*r1,-($x{1,8})\(r1\)/o; } elsif ($arch =~ /^s390x?$/) { # 11160: a7 fb ff 60 aghi %r15,-160 $re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o; diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh new file mode 100644 index 00000000000..325c0a1b03b --- /dev/null +++ b/scripts/gcc-x86_64-has-stack-protector.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "int foo(void) { char X[200]; return 3; }" | $1 -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" +if [ "$?" -eq "0" ] ; then + echo $2 +fi diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh index b5ca35aa174..31598584f87 100755 --- a/scripts/hdrcheck.sh +++ b/scripts/hdrcheck.sh @@ -6,3 +6,5 @@ for FILE in `grep '^[ \t]*#[ \t]*include[ \t]*<' $2 | cut -f2 -d\< | cut -f1 -d\ exit 1 fi done +# FIXME: List dependencies into $3 +touch $3 diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index e6499db4c8c..a90d3cc76bf 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -74,6 +74,7 @@ help: @echo ' xconfig - Update current config utilising a QT based front-end' @echo ' gconfig - Update current config utilising a GTK based front-end' @echo ' oldconfig - Update current config utilising a provided .config as base' + @echo ' silentoldconfig - Same as oldconfig, but quietly' @echo ' randconfig - New config with random answer to all options' @echo ' defconfig - New config with default answer to all options' @echo ' allmodconfig - New config selecting modules when possible' diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index a69d8acbf27..69f96b398c2 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -193,8 +193,11 @@ load: continue; *p++ = 0; p2 = strchr(p, '\n'); - if (p2) - *p2 = 0; + if (p2) { + *p2-- = 0; + if (*p2 == '\r') + *p2 = 0; + } if (def == S_DEF_USER) { sym = sym_find(line + 7); if (!sym) { @@ -266,6 +269,7 @@ load: ; } break; + case '\r': case '\n': break; default: diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index e2de650d3db..f61c9ccef6a 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -265,6 +265,14 @@ static int do_ccw_entry(const char *filename, return 1; } +/* looks like: "ap:tN" */ +static int do_ap_entry(const char *filename, + struct ap_device_id *id, char *alias) +{ + sprintf(alias, "ap:t%02X", id->dev_type); + return 1; +} + /* Looks like: "serio:tyNprNidNexN" */ static int do_serio_entry(const char *filename, struct serio_device_id *id, char *alias) @@ -436,6 +444,14 @@ static int do_input_entry(const char *filename, struct input_device_id *id, return 1; } +static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, + char *alias) +{ + if (eisa->sig[0]) + sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); + return 1; +} + /* Ignore any prefix, eg. v850 prepends _ */ static inline int sym_is(const char *symbol, const char *name) { @@ -503,6 +519,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, do_table(symval, sym->st_size, sizeof(struct ccw_device_id), "ccw", do_ccw_entry, mod); + else if (sym_is(symname, "__mod_ap_device_table")) + do_table(symval, sym->st_size, + sizeof(struct ap_device_id), "ap", + do_ap_entry, mod); else if (sym_is(symname, "__mod_serio_device_table")) do_table(symval, sym->st_size, sizeof(struct serio_device_id), "serio", @@ -535,6 +555,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, do_table(symval, sym->st_size, sizeof(struct input_device_id), "input", do_input_entry, mod); + else if (sym_is(symname, "__mod_eisa_device_table")) + do_table(symval, sym->st_size, + sizeof(struct eisa_device_id), "eisa", + do_eisa_entry, mod); } /* Now add out buffered information to the generated C source */ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index dfde0e87a76..41277963f47 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -23,6 +23,8 @@ int have_vmlinux = 0; static int all_versions = 0; /* If we are modposting external module set to 1 */ static int external_module = 0; +/* Only warn about unresolved symbols */ +static int warn_unresolved = 0; /* How a symbol is exported */ enum export { export_plain, export_unused, export_gpl, @@ -581,8 +583,8 @@ static int strrcmp(const char *s, const char *sub) * fromsec = .data * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one **/ -static int secref_whitelist(const char *tosec, const char *fromsec, - const char *atsym) +static int secref_whitelist(const char *modname, const char *tosec, + const char *fromsec, const char *atsym) { int f1 = 1, f2 = 1; const char **s; @@ -618,8 +620,16 @@ static int secref_whitelist(const char *tosec, const char *fromsec, for (s = pat2sym; *s; s++) if (strrcmp(atsym, *s) == 0) f1 = 1; + if (f1 && f2) + return 1; - return f1 && f2; + /* Whitelist all references from .pci_fixup section if vmlinux */ + if (is_vmlinux(modname)) { + if ((strcmp(fromsec, ".pci_fixup") == 0) && + (strcmp(tosec, ".init.text") == 0)) + return 1; + } + return 0; } /** @@ -726,7 +736,8 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, /* check whitelist - we may ignore it */ if (before && - secref_whitelist(secname, fromsec, elf->strtab + before->st_name)) + secref_whitelist(modname, secname, fromsec, + elf->strtab + before->st_name)) return; if (before && after) { @@ -1187,16 +1198,19 @@ static void add_header(struct buffer *b, struct module *mod) /** * Record CRCs for unresolved symbols **/ -static void add_versions(struct buffer *b, struct module *mod) +static int add_versions(struct buffer *b, struct module *mod) { struct symbol *s, *exp; + int err = 0; for (s = mod->unres; s; s = s->next) { exp = find_symbol(s->name); if (!exp || exp->module == mod) { - if (have_vmlinux && !s->weak) + if (have_vmlinux && !s->weak) { warn("\"%s\" [%s.ko] undefined!\n", s->name, mod->name); + err = warn_unresolved ? 0 : 1; + } continue; } s->module = exp->module; @@ -1205,7 +1219,7 @@ static void add_versions(struct buffer *b, struct module *mod) } if (!modversions) - return; + return err; buf_printf(b, "\n"); buf_printf(b, "static const struct modversion_info ____versions[]\n"); @@ -1225,6 +1239,8 @@ static void add_versions(struct buffer *b, struct module *mod) } buf_printf(b, "};\n"); + + return err; } static void add_depends(struct buffer *b, struct module *mod, @@ -1402,8 +1418,9 @@ int main(int argc, char **argv) char *kernel_read = NULL, *module_read = NULL; char *dump_write = NULL; int opt; + int err; - while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) { + while ((opt = getopt(argc, argv, "i:I:mo:aw")) != -1) { switch(opt) { case 'i': kernel_read = optarg; @@ -1421,6 +1438,9 @@ int main(int argc, char **argv) case 'a': all_versions = 1; break; + case 'w': + warn_unresolved = 1; + break; default: exit(1); } @@ -1441,6 +1461,8 @@ int main(int argc, char **argv) check_exports(mod); } + err = 0; + for (mod = modules; mod; mod = mod->next) { if (mod->skip) continue; @@ -1448,7 +1470,7 @@ int main(int argc, char **argv) buf.pos = 0; add_header(&buf, mod); - add_versions(&buf, mod); + err |= add_versions(&buf, mod); add_depends(&buf, mod, modules); add_moddevtable(&buf, mod); add_srcversion(&buf, mod); @@ -1460,5 +1482,5 @@ int main(int argc, char **argv) if (dump_write) write_dump(dump_write); - return 0; + return err; } diff --git a/scripts/package/mkspec b/scripts/package/mkspec index df892841b11..ffd61fe0c1a 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -63,9 +63,9 @@ fi echo "%install" echo "%ifarch ia64" -echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules' +echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' echo "%else" -echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules' +echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' echo "%endif" echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install' diff --git a/scripts/unifdef.c b/scripts/unifdef.c new file mode 100644 index 00000000000..552025e72ac --- /dev/null +++ b/scripts/unifdef.c @@ -0,0 +1,1005 @@ +/* + * Copyright (c) 2002 - 2005 Tony Finch <dot@dotat.at>. All rights reserved. + * + * This code is derived from software contributed to Berkeley by Dave Yost. + * It was rewritten to support ANSI C by Tony Finch. The original version of + * unifdef carried the following copyright notice. None of its code remains + * in this version (though some of the names remain). + * + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> + +#ifndef lint +#if 0 +static const char copyright[] = +"@(#) Copyright (c) 1985, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif +#ifdef __IDSTRING +__IDSTRING(Berkeley, "@(#)unifdef.c 8.1 (Berkeley) 6/6/93"); +__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.8 2000/07/03 02:51:36 matt Exp $"); +__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.171 2005/03/08 12:38:48 fanf2 Exp $"); +#endif +#endif /* not lint */ +#ifdef __FBSDID +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05/21 09:55:09 ru Exp $"); +#endif + +/* + * unifdef - remove ifdef'ed lines + * + * Wishlist: + * provide an option which will append the name of the + * appropriate symbol after #else's and #endif's + * provide an option which will check symbols after + * #else's and #endif's to see that they match their + * corresponding #ifdef or #ifndef + * + * The first two items above require better buffer handling, which would + * also make it possible to handle all "dodgy" directives correctly. + */ + +#include <ctype.h> +#include <err.h> +#include <stdarg.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +size_t strlcpy(char *dst, const char *src, size_t siz); + +/* types of input lines: */ +typedef enum { + LT_TRUEI, /* a true #if with ignore flag */ + LT_FALSEI, /* a false #if with ignore flag */ + LT_IF, /* an unknown #if */ + LT_TRUE, /* a true #if */ + LT_FALSE, /* a false #if */ + LT_ELIF, /* an unknown #elif */ + LT_ELTRUE, /* a true #elif */ + LT_ELFALSE, /* a false #elif */ + LT_ELSE, /* #else */ + LT_ENDIF, /* #endif */ + LT_DODGY, /* flag: directive is not on one line */ + LT_DODGY_LAST = LT_DODGY + LT_ENDIF, + LT_PLAIN, /* ordinary line */ + LT_EOF, /* end of file */ + LT_COUNT +} Linetype; + +static char const * const linetype_name[] = { + "TRUEI", "FALSEI", "IF", "TRUE", "FALSE", + "ELIF", "ELTRUE", "ELFALSE", "ELSE", "ENDIF", + "DODGY TRUEI", "DODGY FALSEI", + "DODGY IF", "DODGY TRUE", "DODGY FALSE", |