aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 20:45:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 20:45:29 -0500
commit09bd7c75e55cbaa6c731b0c3a5512ad89159f26f (patch)
treea73bd9f94d7661d6ff82f3374d4efea81925f7c8 /scripts
parentfa7f578076a8814caa5371e9f4949e408140766d (diff)
parent7f855fc805cd9c29867aed56cc20f818b36a7b7b (diff)
Merge tag 'kbuild-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: "One of the most remarkable improvements in this cycle is, Kbuild is now able to cache the result of shell commands. Some variables are expensive to compute, for example, $(call cc-option,...) invokes the compiler. It is not efficient to redo this computation every time, even when we are not actually building anything. Kbuild creates a hidden file ".cache.mk" that contains invoked shell commands and their results. The speed-up should be noticeable. Summary: - Fix arch build issues (hexagon, sh) - Clean up various Makefiles and scripts - Fix wrong usage of {CFLAGS,LDFLAGS}_MODULE in arch Makefiles - Cache variables that are expensive to compute - Improve cc-ldopton and ld-option for Clang - Optimize output directory creation" * tag 'kbuild-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits) kbuild: move coccicheck help from scripts/Makefile.help to top Makefile sh: decompressor: add shipped files to .gitignore frv: .gitignore: ignore vmlinux.lds selinux: remove unnecessary assignment to subdir- kbuild: specify FORCE in Makefile.headersinst as .PHONY target kbuild: remove redundant mkdir from ./Kbuild kbuild: optimize object directory creation for incremental build kbuild: create object directories simpler and faster kbuild: filter-out PHONY targets from "targets" kbuild: remove redundant $(wildcard ...) for cmd_files calculation kbuild: create directory for make cache only when necessary sh: select KBUILD_DEFCONFIG depending on ARCH kbuild: fix linker feature test macros when cross compiling with Clang kbuild: shrink .cache.mk when it exceeds 1000 lines kbuild: do not call cc-option before KBUILD_CFLAGS initialization kbuild: Cache a few more calls to the compiler kbuild: Add a cache for generated variables kbuild: add forward declaration of default target to Makefile.asm-generic kbuild: remove KBUILD_SUBDIR_ASFLAGS and KBUILD_SUBDIR_CCFLAGS hexagon/kbuild: replace CFLAGS_MODULE with KBUILD_CFLAGS_MODULE ...
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include106
-rw-r--r--scripts/Makefile.asm-generic3
-rw-r--r--scripts/Makefile.build25
-rw-r--r--scripts/Makefile.headersinst10
-rw-r--r--scripts/Makefile.help3
-rw-r--r--scripts/Makefile.host12
-rw-r--r--scripts/Makefile.lib34
-rw-r--r--scripts/Makefile.modpost3
-rwxr-xr-xscripts/link-vmlinux.sh15
-rwxr-xr-xscripts/mkcompile_h7
-rw-r--r--scripts/selinux/Makefile1
11 files changed, 129 insertions, 90 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 9ffd3dda3889..065324a8046f 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -8,6 +8,8 @@ squote := '
8empty := 8empty :=
9space := $(empty) $(empty) 9space := $(empty) $(empty)
10space_escape := _-_SPACE_-_ 10space_escape := _-_SPACE_-_
11right_paren := )
12left_paren := (
11 13
12### 14###
13# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o 15# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
@@ -80,6 +82,71 @@ cc-cross-prefix = \
80 echo $(c); \ 82 echo $(c); \
81 fi))) 83 fi)))
82 84
85# Tools for caching Makefile variables that are "expensive" to compute.
86#
87# Here we want to help deal with variables that take a long time to compute
88# by making it easy to store these variables in a cache.
89#
90# The canonical example here is testing for compiler flags. On a simple system
91# each call to the compiler takes 10 ms, but on a system with a compiler that's
92# called through various wrappers it can take upwards of 100 ms. If we have
93# 100 calls to the compiler this can take 1 second (on a simple system) or 10
94# seconds (on a complicated system).
95#
96# The "cache" will be in Makefile syntax and can be directly included.
97# Any time we try to reference a variable that's not in the cache we'll
98# calculate it and store it in the cache for next time.
99
100# Include values from last time
101make-cache := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/,$(if $(obj),$(obj)/)).cache.mk
102$(make-cache): ;
103-include $(make-cache)
104
105cached-data := $(filter __cached_%, $(.VARIABLES))
106
107# If cache exceeds 1000 lines, shrink it down to 500.
108ifneq ($(word 1000,$(cached-data)),)
109$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \
110 mv $(make-cache).tmp $(make-cache))
111endif
112
113create-cache-dir := $(if $(KBUILD_SRC),$(if $(cache-data),,1))
114
115# Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios)
116#
117# Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'
118__sanitize-opt = $(subst $$,_,$(subst $(right_paren),_,$(subst $(left_paren),_,$(subst \,_,$(subst =,_,$(subst $(space),_,$(subst $(comma),_,$(subst :,_,$(1)))))))))
119
120# Usage: $(call shell-cached,shell_command)
121# Example: $(call shell-cached,md5sum /usr/bin/gcc)
122#
123# If we've already seen a call to this exact shell command (even in a
124# previous invocation of make!) we'll return the value. If not, we'll
125# compute it and store the result for future runs.
126#
127# This is a bit of voodoo, but basic explanation is that if the variable
128# was undefined then we'll evaluate the shell command and store the result
129# into the variable. We'll then store that value in the cache and finally
130# output the value.
131#
132# NOTE: The $$(2) here isn't actually a parameter to __run-and-store. We
133# happen to know that the caller will have their shell command in $(2) so the
134# result of "call"ing this will produce a reference to that $(2). The reason
135# for this strangeness is to avoid an extra level of eval (and escaping) of
136# $(2).
137define __run-and-store
138ifeq ($(origin $(1)),undefined)
139 $$(eval $(1) := $$(shell $$(2)))
140ifeq ($(create-cache-dir),1)
141 $$(shell mkdir -p $(dir $(make-cache)))
142 $$(eval create-cache-dir :=)
143endif
144 $$(shell echo '$(1) := $$($(1))' >> $(make-cache))
145endif
146endef
147__shell-cached = $(eval $(call __run-and-store,$(1)))$($(1))
148shell-cached = $(call __shell-cached,__cached_$(call __sanitize-opt,$(1)),$(1))
149
83# output directory for tests below 150# output directory for tests below
84TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) 151TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
85 152
@@ -87,30 +154,36 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
87# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 154# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
88# Exit code chooses option. "$$TMP" serves as a temporary file and is 155# Exit code chooses option. "$$TMP" serves as a temporary file and is
89# automatically cleaned up. 156# automatically cleaned up.
90try-run = $(shell set -e; \ 157__try-run = set -e; \
91 TMP="$(TMPOUT).$$$$.tmp"; \ 158 TMP="$(TMPOUT).$$$$.tmp"; \
92 TMPO="$(TMPOUT).$$$$.o"; \ 159 TMPO="$(TMPOUT).$$$$.o"; \
93 if ($(1)) >/dev/null 2>&1; \ 160 if ($(1)) >/dev/null 2>&1; \
94 then echo "$(2)"; \ 161 then echo "$(2)"; \
95 else echo "$(3)"; \ 162 else echo "$(3)"; \
96 fi; \ 163 fi; \
97 rm -f "$$TMP" "$$TMPO") 164 rm -f "$$TMP" "$$TMPO"
165
166try-run = $(shell $(__try-run))
167
168# try-run-cached
169# This works like try-run, but the result is cached.
170try-run-cached = $(call shell-cached,$(__try-run))
98 171
99# as-option 172# as-option
100# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 173# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
101 174
102as-option = $(call try-run,\ 175as-option = $(call try-run-cached,\
103 $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) 176 $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
104 177
105# as-instr 178# as-instr
106# Usage: cflags-y += $(call as-instr,instr,option1,option2) 179# Usage: cflags-y += $(call as-instr,instr,option1,option2)
107 180
108as-instr = $(call try-run,\ 181as-instr = $(call try-run-cached,\
109 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) 182 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
110 183
111# __cc-option 184# __cc-option
112# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) 185# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
113__cc-option = $(call try-run,\ 186__cc-option = $(call try-run-cached,\
114 $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) 187 $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
115 188
116# Do not attempt to build with gcc plugins during cc-option tests. 189# Do not attempt to build with gcc plugins during cc-option tests.
@@ -130,23 +203,23 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\
130 203
131# cc-option-yn 204# cc-option-yn
132# Usage: flag := $(call cc-option-yn,-march=winchip-c6) 205# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
133cc-option-yn = $(call try-run,\ 206cc-option-yn = $(call try-run-cached,\
134 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) 207 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
135 208
136# cc-disable-warning 209# cc-disable-warning
137# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) 210# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
138cc-disable-warning = $(call try-run,\ 211cc-disable-warning = $(call try-run-cached,\
139 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 212 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
140 213
141# cc-name 214# cc-name
142# Expands to either gcc or clang 215# Expands to either gcc or clang
143cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) 216cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
144 217
145# cc-version 218# cc-version
146cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 219cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
147 220
148# cc-fullversion 221# cc-fullversion
149cc-fullversion = $(shell $(CONFIG_SHELL) \ 222cc-fullversion = $(call shell-cached,$(CONFIG_SHELL) \
150 $(srctree)/scripts/gcc-version.sh -p $(CC)) 223 $(srctree)/scripts/gcc-version.sh -p $(CC))
151 224
152# cc-ifversion 225# cc-ifversion
@@ -159,22 +232,23 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo
159 232
160# cc-ldoption 233# cc-ldoption
161# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) 234# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
162cc-ldoption = $(call try-run,\ 235cc-ldoption = $(call try-run-cached,\
163 $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) 236 $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
164 237
165# ld-option 238# ld-option
166# Usage: LDFLAGS += $(call ld-option, -X) 239# Usage: LDFLAGS += $(call ld-option, -X)
167ld-option = $(call try-run,\ 240ld-option = $(call try-run-cached,\
168 $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) 241 $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \
242 $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
169 243
170# ar-option 244# ar-option
171# Usage: KBUILD_ARFLAGS := $(call ar-option,D) 245# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
172# Important: no spaces around options 246# Important: no spaces around options
173ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) 247ar-option = $(call try-run-cached, $(AR) rc$(1) "$$TMP",$(1),$(2))
174 248
175# ld-version 249# ld-version
176# Note this is mainly for HJ Lu's 3 number binutil versions 250# Note this is mainly for HJ Lu's 3 number binutil versions
177ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) 251ld-version = $(call shell-cached,$(LD) --version | $(srctree)/scripts/ld-version.sh)
178 252
179# ld-ifversion 253# ld-ifversion
180# Usage: $(call ld-ifversion, -ge, 22252, y) 254# Usage: $(call ld-ifversion, -ge, 22252, y)
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
index 524eeedc8d25..32ad8e93fbe1 100644
--- a/scripts/Makefile.asm-generic
+++ b/scripts/Makefile.asm-generic
@@ -6,6 +6,9 @@
6# and for each file listed in this file with generic-y creates 6# and for each file listed in this file with generic-y creates
7# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) 7# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src))
8 8
9PHONY := all
10all:
11
9kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild 12kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
10-include $(kbuild-file) 13-include $(kbuild-file)
11 14
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e63af4e19382..f171225383cc 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -65,15 +65,6 @@ ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(h
65include scripts/Makefile.host 65include scripts/Makefile.host
66endif 66endif
67 67
68ifneq ($(KBUILD_SRC),)
69# Create output directory if not already present
70_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
71
72# Create directories for object files if directory does not exist
73# Needed when obj-y := dir/file.o syntax is used
74_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
75endif
76
77ifndef obj 68ifndef obj
78$(warning kbuild: Makefile.build is included improperly) 69$(warning kbuild: Makefile.build is included improperly)
79endif 70endif
@@ -563,7 +554,7 @@ $(multi-used-m): FORCE
563$(call multi_depend, $(multi-used-m), .o, -objs -y -m) 554$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
564 555
565targets += $(multi-used-y) $(multi-used-m) 556targets += $(multi-used-y) $(multi-used-m)
566 557targets := $(filter-out $(PHONY), $(targets))
567 558
568# Descending 559# Descending
569# --------------------------------------------------------------------------- 560# ---------------------------------------------------------------------------
@@ -584,13 +575,23 @@ FORCE:
584# optimization, we don't need to read them if the target does not 575# optimization, we don't need to read them if the target does not
585# exist, we will rebuild anyway in that case. 576# exist, we will rebuild anyway in that case.
586 577
587targets := $(wildcard $(sort $(targets))) 578cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
588cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
589 579
590ifneq ($(cmd_files),) 580ifneq ($(cmd_files),)
591 include $(cmd_files) 581 include $(cmd_files)
592endif 582endif
593 583
584ifneq ($(KBUILD_SRC),)
585# Create directories for object files if they do not exist
586obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
587# If cmd_files exist, their directories apparently exist. Skip mkdir.
588exist-dirs := $(sort $(patsubst %/,%, $(dir $(cmd_files))))
589obj-dirs := $(strip $(filter-out $(exist-dirs), $(obj-dirs)))
590ifneq ($(obj-dirs),)
591$(shell mkdir -p $(obj-dirs))
592endif
593endif
594
594# Declare the contents of the .PHONY variable as phony. We keep that 595# Declare the contents of the .PHONY variable as phony. We keep that
595# information in a variable se we can use it in if_changed and friends. 596# information in a variable se we can use it in if_changed and friends.
596 597
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 99967948d764..d5e131471131 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,11 +27,11 @@ subdirs := $(patsubst $(srcdir)/%/,%,\
27# Recursion 27# Recursion
28__headers: $(subdirs) 28__headers: $(subdirs)
29 29
30.PHONY: $(subdirs) 30PHONY += $(subdirs)
31$(subdirs): 31$(subdirs):
32 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@ 32 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@
33 33
34# Skip header install/check for include/uapi and arch/$(hdr-arch)/include/uapi. 34# Skip header install/check for include/uapi and arch/$(SRCARCH)/include/uapi.
35# We have only sub-directories there. 35# We have only sub-directories there.
36skip-inst := $(if $(filter %/uapi,$(obj)),1) 36skip-inst := $(if $(filter %/uapi,$(obj)),1)
37 37
@@ -115,9 +115,8 @@ $(check-file): scripts/headers_check.pl $(output-files) FORCE
115 115
116endif 116endif
117 117
118targets := $(wildcard $(sort $(targets)))
119cmd_files := $(wildcard \ 118cmd_files := $(wildcard \
120 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 119 $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
121 120
122ifneq ($(cmd_files),) 121ifneq ($(cmd_files),)
123 include $(cmd_files) 122 include $(cmd_files)
@@ -125,6 +124,7 @@ endif
125 124
126endif # skip-inst 125endif # skip-inst
127 126
128.PHONY: $(PHONY)
129PHONY += FORCE 127PHONY += FORCE
130FORCE: ; 128FORCE: ;
129
130.PHONY: $(PHONY)
diff --git a/scripts/Makefile.help b/scripts/Makefile.help
deleted file mode 100644
index d03608f5db04..000000000000
--- a/scripts/Makefile.help
+++ /dev/null
@@ -1,3 +0,0 @@
1
2checker-help:
3 @echo ' coccicheck - Check with Coccinelle.'
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 10e5c3cb89dc..e6dc6ae2d7c4 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -49,15 +49,6 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
49host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) 49host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
50host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) 50host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
51 51
52# output directory for programs/.o files
53# hostprogs-y := tools/build may have been specified.
54# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation
55host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs))
56
57host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
58
59
60__hostprogs := $(addprefix $(obj)/,$(__hostprogs))
61host-csingle := $(addprefix $(obj)/,$(host-csingle)) 52host-csingle := $(addprefix $(obj)/,$(host-csingle))
62host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) 53host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
63host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) 54host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
@@ -67,9 +58,6 @@ host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
67host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) 58host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
68host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) 59host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
69host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) 60host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
70host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
71
72obj-dirs += $(host-objdirs)
73 61
74##### 62#####
75# Handle options to gcc. Support building with separate output directory 63# Handle options to gcc. Support building with separate output directory
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 2278405cbc80..08eb40a7729f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -5,24 +5,25 @@ ccflags-y += $(EXTRA_CFLAGS)
5cppflags-y += $(EXTRA_CPPFLAGS) 5cppflags-y += $(EXTRA_CPPFLAGS)
6ldflags-y += $(EXTRA_LDFLAGS) 6ldflags-y += $(EXTRA_LDFLAGS)
7 7
8# 8# flags that take effect in current and sub directories
9# flags that take effect in sub directories 9KBUILD_AFLAGS += $(subdir-asflags-y)
10export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y) 10KBUILD_CFLAGS += $(subdir-ccflags-y)
11export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
12 11
13# Figure out what we need to build from the various variables 12# Figure out what we need to build from the various variables
14# =========================================================================== 13# ===========================================================================
15 14
16# When an object is listed to be built compiled-in and modular, 15# When an object is listed to be built compiled-in and modular,
17# only build the compiled-in version 16# only build the compiled-in version
18
19obj-m := $(filter-out $(obj-y),$(obj-m)) 17obj-m := $(filter-out $(obj-y),$(obj-m))
20 18
21# Libraries are always collected in one lib file. 19# Libraries are always collected in one lib file.
22# Filter out objects already built-in 20# Filter out objects already built-in
23
24lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) 21lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
25 22
23# Determine modorder.
24# Unfortunately, we don't have information about ordering between -y
25# and -m subdirs. Just put -y's first.
26modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
26 27
27# Handle objects in subdirs 28# Handle objects in subdirs
28# --------------------------------------------------------------------------- 29# ---------------------------------------------------------------------------
@@ -30,12 +31,6 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
30# and add the directory to the list of dirs to descend into: $(subdir-y) 31# and add the directory to the list of dirs to descend into: $(subdir-y)
31# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 32# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
32# and add the directory to the list of dirs to descend into: $(subdir-m) 33# and add the directory to the list of dirs to descend into: $(subdir-m)
33
34# Determine modorder.
35# Unfortunately, we don't have information about ordering between -y
36# and -m subdirs. Just put -y's first.
37modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
38
39__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) 34__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
40subdir-y += $(__subdir-y) 35subdir-y += $(__subdir-y)
41__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) 36__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
@@ -44,10 +39,9 @@ obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
44obj-m := $(filter-out %/, $(obj-m)) 39obj-m := $(filter-out %/, $(obj-m))
45 40
46# Subdirectories we need to descend into 41# Subdirectories we need to descend into
47
48subdir-ym := $(sort $(subdir-y) $(subdir-m)) 42subdir-ym := $(sort $(subdir-y) $(subdir-m))
49 43
50# if $(foo-objs) exists, foo.o is a composite object 44# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object
51multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 45multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
52multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m)))) 46multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
53multi-used := $(multi-used-y) $(multi-used-m) 47multi-used := $(multi-used-y) $(multi-used-m)
@@ -57,15 +51,11 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
57# objects depend on those (obviously) 51# objects depend on those (obviously)
58multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) 52multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
59multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) 53multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
60multi-objs := $(multi-objs-y) $(multi-objs-m)
61 54
62# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to 55# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
63# tell kbuild to descend 56# tell kbuild to descend
64subdir-obj-y := $(filter %/built-in.o, $(obj-y)) 57subdir-obj-y := $(filter %/built-in.o, $(obj-y))
65 58
66# $(obj-dirs) is a list of directories that contain object files
67obj-dirs := $(dir $(multi-objs) $(obj-y))
68
69# Replace multi-part objects by their individual parts, look at local dir only 59# Replace multi-part objects by their individual parts, look at local dir only
70real-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-y) 60real-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-y)
71real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) 61real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
@@ -93,11 +83,9 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
93multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) 83multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
94multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) 84multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
95subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 85subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
96obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
97 86
98# These flags are needed for modversions and compiling, so we define them here 87# These flags are needed for modversions and compiling, so we define them here
99# already 88# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
100# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
101# end up in (or would, if it gets compiled in) 89# end up in (or would, if it gets compiled in)
102# Note: Files that end up in two or more modules are compiled without the 90# Note: Files that end up in two or more modules are compiled without the
103# KBUILD_MODNAME definition. The reason is that any made-up name would 91# KBUILD_MODNAME definition. The reason is that any made-up name would
@@ -107,10 +95,10 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
107modname_flags = $(if $(filter 1,$(words $(modname))),\ 95modname_flags = $(if $(filter 1,$(words $(modname))),\
108 -DKBUILD_MODNAME=$(call name-fix,$(modname))) 96 -DKBUILD_MODNAME=$(call name-fix,$(modname)))
109 97
110orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ 98orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
111 $(ccflags-y) $(CFLAGS_$(basetarget).o) 99 $(ccflags-y) $(CFLAGS_$(basetarget).o)
112_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 100_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
113orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ 101orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
114 $(asflags-y) $(AFLAGS_$(basetarget).o) 102 $(asflags-y) $(AFLAGS_$(basetarget).o)
115_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags)) 103_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
116_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) 104_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 991db7d6e4df..df4174405feb 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -143,8 +143,7 @@ FORCE:
143# optimization, we don't need to read them if the target does not 143# optimization, we don't need to read them if the target does not
144# exist, we will rebuild anyway in that case. 144# exist, we will rebuild anyway in that case.
145 145
146targets := $(wildcard $(sort $(targets))) 146cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
147cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
148 147
149ifneq ($(cmd_files),) 148ifneq ($(cmd_files),)
150 include $(cmd_files) 149 include $(cmd_files)
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index e6818b8e7141..c0d129d7f430 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -188,10 +188,8 @@ sortextable()
188# Delete output files in case of error 188# Delete output files in case of error
189cleanup() 189cleanup()
190{ 190{
191 rm -f .old_version
192 rm -f .tmp_System.map 191 rm -f .tmp_System.map
193 rm -f .tmp_kallsyms* 192 rm -f .tmp_kallsyms*
194 rm -f .tmp_version
195 rm -f .tmp_vmlinux* 193 rm -f .tmp_vmlinux*
196 rm -f built-in.o 194 rm -f built-in.o
197 rm -f System.map 195 rm -f System.map
@@ -239,12 +237,12 @@ esac
239 237
240# Update version 238# Update version
241info GEN .version 239info GEN .version
242if [ ! -r .version ]; then 240if [ -r .version ]; then
243 rm -f .version; 241 VERSION=$(expr 0$(cat .version) + 1)
244 echo 1 >.version; 242 echo $VERSION > .version
245else 243else
246 mv .version .old_version; 244 rm -f .version
247 expr 0$(cat .old_version) + 1 >.version; 245 echo 1 > .version
248fi; 246fi;
249 247
250# final build of init/ 248# final build of init/
@@ -332,6 +330,3 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
332 exit 1 330 exit 1
333 fi 331 fi
334fi 332fi
335
336# We made a new kernel - delete old version file
337rm -f .old_version
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 959199c3147e..87f1fc9801d7 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -28,12 +28,7 @@ LC_ALL=C
28export LC_ALL 28export LC_ALL
29 29
30if [ -z "$KBUILD_BUILD_VERSION" ]; then 30if [ -z "$KBUILD_BUILD_VERSION" ]; then
31 if [ -r .version ]; then 31 VERSION=$(cat .version 2>/dev/null || echo 1)
32 VERSION=`cat .version`
33 else
34 VERSION=0
35 echo 0 > .version
36 fi
37else 32else
38 VERSION=$KBUILD_BUILD_VERSION 33 VERSION=$KBUILD_BUILD_VERSION
39fi 34fi
diff --git a/scripts/selinux/Makefile b/scripts/selinux/Makefile
index e8049da1831f..b3048b894a39 100644
--- a/scripts/selinux/Makefile
+++ b/scripts/selinux/Makefile
@@ -1,2 +1 @@
1subdir-y := mdp genheaders subdir-y := mdp genheaders
2subdir- += mdp genheaders