aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile197
1 files changed, 99 insertions, 98 deletions
diff --git a/Makefile b/Makefile
index 14781f36e327..7bc2f4ad8093 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,7 @@ ifdef O
95endif 95endif
96 96
97# That's our default target when none is given on the command line 97# That's our default target when none is given on the command line
98.PHONY: _all 98PHONY := _all
99_all: 99_all:
100 100
101ifneq ($(KBUILD_OUTPUT),) 101ifneq ($(KBUILD_OUTPUT),)
@@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
106$(if $(KBUILD_OUTPUT),, \ 106$(if $(KBUILD_OUTPUT),, \
107 $(error output directory "$(saved-output)" does not exist)) 107 $(error output directory "$(saved-output)" does not exist))
108 108
109.PHONY: $(MAKECMDGOALS) 109PHONY += $(MAKECMDGOALS)
110 110
111$(filter-out _all,$(MAKECMDGOALS)) _all: 111$(filter-out _all,$(MAKECMDGOALS)) _all:
112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ 112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
@@ -123,7 +123,7 @@ ifeq ($(skip-makefile),)
123 123
124# If building an external module we do not care about the all: rule 124# If building an external module we do not care about the all: rule
125# but instead _all depend on modules 125# but instead _all depend on modules
126.PHONY: all 126PHONY += all
127ifeq ($(KBUILD_EXTMOD),) 127ifeq ($(KBUILD_EXTMOD),)
128_all: all 128_all: all
129else 129else
@@ -137,7 +137,7 @@ objtree := $(CURDIR)
137src := $(srctree) 137src := $(srctree)
138obj := $(objtree) 138obj := $(objtree)
139 139
140VPATH := $(srctree) 140VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
141 141
142export srctree objtree VPATH TOPDIR 142export srctree objtree VPATH TOPDIR
143 143
@@ -151,7 +151,7 @@ export srctree objtree VPATH TOPDIR
151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ 151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
152 -e s/arm.*/arm/ -e s/sa110/arm/ \ 152 -e s/arm.*/arm/ -e s/sa110/arm/ \
153 -e s/s390x/s390/ -e s/parisc64/parisc/ \ 153 -e s/s390x/s390/ -e s/parisc64/parisc/ \
154 -e s/ppc.*/powerpc/ ) 154 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
155 155
156# Cross compiling and selecting different set of gcc/bin-utils 156# Cross compiling and selecting different set of gcc/bin-utils
157# --------------------------------------------------------------------------- 157# ---------------------------------------------------------------------------
@@ -258,38 +258,6 @@ endif
258 258
259export quiet Q KBUILD_VERBOSE 259export quiet Q KBUILD_VERBOSE
260 260
261######
262# cc support functions to be used (only) in arch/$(ARCH)/Makefile
263# See documentation in Documentation/kbuild/makefiles.txt
264
265# as-option
266# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
267
268as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
269 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
270 else echo "$(2)"; fi ;)
271
272# cc-option
273# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
274
275cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
276 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
277
278# cc-option-yn
279# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
280cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
281 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
282
283# cc-option-align
284# Prefix align with either -falign or -malign
285cc-option-align = $(subst -functions=0,,\
286 $(call cc-option,-falign-functions=0,-malign-functions=0))
287
288# cc-version
289# Usage gcc-ver := $(call cc-version $(CC))
290cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
291 $(if $(1), $(1), $(CC)))
292
293 261
294# Look for make include files relative to root of kernel src 262# Look for make include files relative to root of kernel src
295MAKEFLAGS += --include-dir=$(srctree) 263MAKEFLAGS += --include-dir=$(srctree)
@@ -369,14 +337,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
369# Rules shared between *config targets and build targets 337# Rules shared between *config targets and build targets
370 338
371# Basic helpers built in scripts/ 339# Basic helpers built in scripts/
372.PHONY: scripts_basic 340PHONY += scripts_basic
373scripts_basic: 341scripts_basic:
374 $(Q)$(MAKE) $(build)=scripts/basic 342 $(Q)$(MAKE) $(build)=scripts/basic
375 343
376# To avoid any implicit rule to kick in, define an empty command. 344# To avoid any implicit rule to kick in, define an empty command.
377scripts/basic/%: scripts_basic ; 345scripts/basic/%: scripts_basic ;
378 346
379.PHONY: outputmakefile 347PHONY += outputmakefile
380# outputmakefile generate a Makefile to be placed in output directory, if 348# outputmakefile generate a Makefile to be placed in output directory, if
381# using a seperate output directory. This allows convinient use 349# using a seperate output directory. This allows convinient use
382# of make in output directory 350# of make in output directory
@@ -452,7 +420,7 @@ ifeq ($(KBUILD_EXTMOD),)
452# Additional helpers built in scripts/ 420# Additional helpers built in scripts/
453# Carefully list dependencies so we do not try to build scripts twice 421# Carefully list dependencies so we do not try to build scripts twice
454# in parrallel 422# in parrallel
455.PHONY: scripts 423PHONY += scripts
456scripts: scripts_basic include/config/MARKER 424scripts: scripts_basic include/config/MARKER
457 $(Q)$(MAKE) $(build)=$(@) 425 $(Q)$(MAKE) $(build)=$(@)
458 426
@@ -504,13 +472,6 @@ else
504CFLAGS += -O2 472CFLAGS += -O2
505endif 473endif
506 474
507#Add align options if CONFIG_CC_* is not equal to 0
508add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1)))
509CFLAGS += $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions)
510CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels)
511CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
512CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
513
514ifdef CONFIG_FRAME_POINTER 475ifdef CONFIG_FRAME_POINTER
515CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) 476CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
516else 477else
@@ -756,7 +717,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
756# make menuconfig etc. 717# make menuconfig etc.
757# Error messages still appears in the original language 718# Error messages still appears in the original language
758 719
759.PHONY: $(vmlinux-dirs) 720PHONY += $(vmlinux-dirs)
760$(vmlinux-dirs): prepare scripts 721$(vmlinux-dirs): prepare scripts
761 $(Q)$(MAKE) $(build)=$@ 722 $(Q)$(MAKE) $(build)=$@
762 723
@@ -809,10 +770,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full)
809# version.h and scripts_basic is processed / created. 770# version.h and scripts_basic is processed / created.
810 771
811# Listed in dependency order 772# Listed in dependency order
812.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 773PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
813 774
814# prepare-all is deprecated, use prepare as valid replacement 775# prepare-all is deprecated, use prepare as valid replacement
815.PHONY: prepare-all 776PHONY += prepare-all
816 777
817# prepare3 is used to check if we are building in a separate output directory, 778# prepare3 is used to check if we are building in a separate output directory,
818# and if so do: 779# and if so do:
@@ -853,27 +814,6 @@ prepare prepare-all: prepare0
853 814
854export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) 815export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
855 816
856# Single targets
857# ---------------------------------------------------------------------------
858
859%.s: %.c scripts FORCE
860 $(Q)$(MAKE) $(build)=$(@D) $@
861%.i: %.c scripts FORCE
862 $(Q)$(MAKE) $(build)=$(@D) $@
863%.o: %.c scripts FORCE
864 $(Q)$(MAKE) $(build)=$(@D) $@
865%.ko: scripts FORCE
866 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) $(@:.ko=.o)
867 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
868%/: scripts prepare FORCE
869 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
870%.lst: %.c scripts FORCE
871 $(Q)$(MAKE) $(build)=$(@D) $@
872%.s: %.S scripts FORCE
873 $(Q)$(MAKE) $(build)=$(@D) $@
874%.o: %.S scripts FORCE
875 $(Q)$(MAKE) $(build)=$(@D) $@
876
877# FIXME: The asm symlink changes when $(ARCH) changes. That's 817# FIXME: The asm symlink changes when $(ARCH) changes. That's
878# hard to detect, but I suppose "make mrproper" is a good idea 818# hard to detect, but I suppose "make mrproper" is a good idea
879# before switching between archs anyway. 819# before switching between archs anyway.
@@ -914,7 +854,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE
914 854
915# --------------------------------------------------------------------------- 855# ---------------------------------------------------------------------------
916 856
917.PHONY: depend dep 857PHONY += depend dep
918depend dep: 858depend dep:
919 @echo '*** Warning: make $@ is unnecessary now.' 859 @echo '*** Warning: make $@ is unnecessary now.'
920 860
@@ -929,21 +869,21 @@ all: modules
929 869
930# Build modules 870# Build modules
931 871
932.PHONY: modules 872PHONY += modules
933modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) 873modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
934 @echo ' Building modules, stage 2.'; 874 @echo ' Building modules, stage 2.';
935 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 875 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
936 876
937 877
938# Target to prepare building external modules 878# Target to prepare building external modules
939.PHONY: modules_prepare 879PHONY += modules_prepare
940modules_prepare: prepare scripts 880modules_prepare: prepare scripts
941 881
942# Target to install modules 882# Target to install modules
943.PHONY: modules_install 883PHONY += modules_install
944modules_install: _modinst_ _modinst_post 884modules_install: _modinst_ _modinst_post
945 885
946.PHONY: _modinst_ 886PHONY += _modinst_
947_modinst_: 887_modinst_:
948 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ 888 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
949 echo "Warning: you may need to install module-init-tools"; \ 889 echo "Warning: you may need to install module-init-tools"; \
@@ -970,7 +910,7 @@ depmod_opts :=
970else 910else
971depmod_opts := -b $(INSTALL_MOD_PATH) -r 911depmod_opts := -b $(INSTALL_MOD_PATH) -r
972endif 912endif
973.PHONY: _modinst_post 913PHONY += _modinst_post
974_modinst_post: _modinst_ 914_modinst_post: _modinst_
975 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi 915 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
976 916
@@ -1013,7 +953,7 @@ clean: rm-dirs := $(CLEAN_DIRS)
1013clean: rm-files := $(CLEAN_FILES) 953clean: rm-files := $(CLEAN_FILES)
1014clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) 954clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
1015 955
1016.PHONY: $(clean-dirs) clean archclean 956PHONY += $(clean-dirs) clean archclean
1017$(clean-dirs): 957$(clean-dirs):
1018 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 958 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1019 959
@@ -1031,7 +971,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
1031mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 971mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1032mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) 972mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
1033 973
1034.PHONY: $(mrproper-dirs) mrproper archmrproper 974PHONY += $(mrproper-dirs) mrproper archmrproper
1035$(mrproper-dirs): 975$(mrproper-dirs):
1036 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 976 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1037 977
@@ -1041,7 +981,7 @@ mrproper: clean archmrproper $(mrproper-dirs)
1041 981
1042# distclean 982# distclean
1043# 983#
1044.PHONY: distclean 984PHONY += distclean
1045 985
1046distclean: mrproper 986distclean: mrproper
1047 @find $(srctree) $(RCS_FIND_IGNORE) \ 987 @find $(srctree) $(RCS_FIND_IGNORE) \
@@ -1057,12 +997,10 @@ distclean: mrproper
1057# rpm target kept for backward compatibility 997# rpm target kept for backward compatibility
1058package-dir := $(srctree)/scripts/package 998package-dir := $(srctree)/scripts/package
1059 999
1060.PHONY: %-pkg rpm
1061
1062%pkg: FORCE 1000%pkg: FORCE
1063 $(Q)$(MAKE) -f $(package-dir)/Makefile $@ 1001 $(Q)$(MAKE) $(build)=$(package-dir) $@
1064rpm: FORCE 1002rpm: FORCE
1065 $(Q)$(MAKE) -f $(package-dir)/Makefile $@ 1003 $(Q)$(MAKE) $(build)=$(package-dir) $@
1066 1004
1067 1005
1068# Brief documentation of the typical targets used 1006# Brief documentation of the typical targets used
@@ -1094,13 +1032,11 @@ help:
1094 @echo ' kernelversion - Output the version stored in Makefile' 1032 @echo ' kernelversion - Output the version stored in Makefile'
1095 @echo '' 1033 @echo ''
1096 @echo 'Static analysers' 1034 @echo 'Static analysers'
1097 @echo ' buildcheck - List dangling references to vmlinux discarded sections'
1098 @echo ' and init sections from non-init sections'
1099 @echo ' checkstack - Generate a list of stack hogs' 1035 @echo ' checkstack - Generate a list of stack hogs'
1100 @echo ' namespacecheck - Name space analysis on compiled kernel' 1036 @echo ' namespacecheck - Name space analysis on compiled kernel'
1101 @echo '' 1037 @echo ''
1102 @echo 'Kernel packaging:' 1038 @echo 'Kernel packaging:'
1103 @$(MAKE) -f $(package-dir)/Makefile help 1039 @$(MAKE) $(build)=$(package-dir) help
1104 @echo '' 1040 @echo ''
1105 @echo 'Documentation targets:' 1041 @echo 'Documentation targets:'
1106 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp 1042 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
@@ -1149,11 +1085,12 @@ else # KBUILD_EXTMOD
1149 1085
1150# We are always building modules 1086# We are always building modules
1151KBUILD_MODULES := 1 1087KBUILD_MODULES := 1
1152.PHONY: crmodverdir 1088PHONY += crmodverdir
1153crmodverdir: 1089crmodverdir:
1090 $(Q)rm -rf $(MODVERDIR)
1154 $(Q)mkdir -p $(MODVERDIR) 1091 $(Q)mkdir -p $(MODVERDIR)
1155 1092
1156.PHONY: $(objtree)/Module.symvers 1093PHONY += $(objtree)/Module.symvers
1157$(objtree)/Module.symvers: 1094$(objtree)/Module.symvers:
1158 @test -e $(objtree)/Module.symvers || ( \ 1095 @test -e $(objtree)/Module.symvers || ( \
1159 echo; \ 1096 echo; \
@@ -1162,7 +1099,7 @@ $(objtree)/Module.symvers:
1162 echo ) 1099 echo )
1163 1100
1164module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) 1101module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1165.PHONY: $(module-dirs) modules 1102PHONY += $(module-dirs) modules
1166$(module-dirs): crmodverdir $(objtree)/Module.symvers 1103$(module-dirs): crmodverdir $(objtree)/Module.symvers
1167 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) 1104 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1168 1105
@@ -1170,13 +1107,32 @@ modules: $(module-dirs)
1170 @echo ' Building modules, stage 2.'; 1107 @echo ' Building modules, stage 2.';
1171 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 1108 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1172 1109
1173.PHONY: modules_install 1110PHONY += modules_install
1174modules_install: 1111modules_install: _emodinst_ _emodinst_post
1112
1113install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1114PHONY += _emodinst_
1115_emodinst_:
1116 $(Q)rm -rf $(MODLIB)/$(install-dir)
1117 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1175 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst 1118 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
1176 1119
1120# Run depmod only is we have System.map and depmod is executable
1121quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1122 cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
1123 $(DEPMOD) -ae -F System.map \
1124 $(if $(strip $(INSTALL_MOD_PATH)), \
1125 -b $(INSTALL_MOD_PATH) -r) \
1126 $(KERNELRELEASE); \
1127 fi
1128
1129PHONY += _emodinst_post
1130_emodinst_post: _emodinst_
1131 $(call cmd,depmod)
1132
1177clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) 1133clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1178 1134
1179.PHONY: $(clean-dirs) clean 1135PHONY += $(clean-dirs) clean
1180$(clean-dirs): 1136$(clean-dirs):
1181 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1137 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1182 1138
@@ -1196,6 +1152,11 @@ help:
1196 @echo ' modules_install - install the module' 1152 @echo ' modules_install - install the module'
1197 @echo ' clean - remove generated files in module directory only' 1153 @echo ' clean - remove generated files in module directory only'
1198 @echo '' 1154 @echo ''
1155
1156# Dummies...
1157PHONY += prepare scripts
1158prepare: ;
1159scripts: ;
1199endif # KBUILD_EXTMOD 1160endif # KBUILD_EXTMOD
1200 1161
1201# Generate tags for editors 1162# Generate tags for editors
@@ -1296,17 +1257,13 @@ versioncheck:
1296 -name '*.[hcS]' -type f -print | sort \ 1257 -name '*.[hcS]' -type f -print | sort \
1297 | xargs $(PERL) -w scripts/checkversion.pl 1258 | xargs $(PERL) -w scripts/checkversion.pl
1298 1259
1299buildcheck:
1300 $(PERL) $(srctree)/scripts/reference_discarded.pl
1301 $(PERL) $(srctree)/scripts/reference_init.pl
1302
1303namespacecheck: 1260namespacecheck:
1304 $(PERL) $(srctree)/scripts/namespace.pl 1261 $(PERL) $(srctree)/scripts/namespace.pl
1305 1262
1306endif #ifeq ($(config-targets),1) 1263endif #ifeq ($(config-targets),1)
1307endif #ifeq ($(mixed-targets),1) 1264endif #ifeq ($(mixed-targets),1)
1308 1265
1309.PHONY: checkstack 1266PHONY += checkstack
1310checkstack: 1267checkstack:
1311 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1268 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1312 $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1269 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
@@ -1317,6 +1274,44 @@ kernelrelease:
1317kernelversion: 1274kernelversion:
1318 @echo $(KERNELVERSION) 1275 @echo $(KERNELVERSION)
1319 1276
1277# Single targets
1278# ---------------------------------------------------------------------------
1279# The directory part is taken from first prerequisite, so this
1280# works even with external modules
1281%.s: %.c prepare scripts FORCE
1282 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1283%.i: %.c prepare scripts FORCE
1284 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1285%.o: %.c prepare scripts FORCE
1286 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1287%.lst: %.c prepare scripts FORCE
1288 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1289%.s: %.S prepare scripts FORCE
1290 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1291%.o: %.S prepare scripts FORCE
1292 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1293
1294# For external modules we shall include any directory of the target,
1295# but usual case there is no directory part.
1296# make M=`pwd` module.o => $(dir $@)=./
1297# make M=`pwd` foo/module.o => $(dir $@)=foo/
1298# make M=`pwd` / => $(dir $@)=/
1299
1300ifeq ($(KBUILD_EXTMOD),)
1301 target-dir = $(@D)
1302else
1303 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1304 target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1305endif
1306
1307/ %/: scripts prepare FORCE
1308 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1309 $(build)=$(target-dir)
1310%.ko: scripts FORCE
1311 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1312 $(build)=$(target-dir) $(@:.ko=.o)
1313 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1314
1320# FIXME Should go into a make.lib or something 1315# FIXME Should go into a make.lib or something
1321# =========================================================================== 1316# ===========================================================================
1322 1317
@@ -1351,4 +1346,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1351 1346
1352endif # skip-makefile 1347endif # skip-makefile
1353 1348
1349PHONY += FORCE
1354FORCE: 1350FORCE:
1351
1352
1353# Declare the contents of the .PHONY variable as phony. We keep that
1354# information in a variable se we can use it in if_changed and friends.
1355.PHONY: $(PHONY)