aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile53
1 files changed, 28 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index b4019426fa25..131950c02919 100644
--- a/Makefile
+++ b/Makefile
@@ -1275,40 +1275,43 @@ kernelversion:
1275 1275
1276# Single targets 1276# Single targets
1277# --------------------------------------------------------------------------- 1277# ---------------------------------------------------------------------------
1278# The directory part is taken from first prerequisite, so this 1278# Single targets are compatible with:
1279# works even with external modules 1279# - build whith mixed source and output
1280# - build with separate output dir 'make O=...'
1281# - external modules
1282#
1283# target-dir => where to store outputfile
1284# build-dir => directory in kernel source tree to use
1285
1286ifeq ($(KBUILD_EXTMOD),)
1287 build-dir = $(dir $@)
1288 target-dir = $(dir $@)
1289else
1290 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1291 build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1292 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
1293endif
1294
1280%.s: %.c prepare scripts FORCE 1295%.s: %.c prepare scripts FORCE
1281 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) 1296 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1282%.i: %.c prepare scripts FORCE 1297%.i: %.c prepare scripts FORCE
1283 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) 1298 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1284%.o: %.c prepare scripts FORCE 1299%.o: %.c prepare scripts FORCE
1285 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) 1300 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1286%.lst: %.c prepare scripts FORCE 1301%.lst: %.c prepare scripts FORCE
1287 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) 1302 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1288%.s: %.S prepare scripts FORCE 1303%.s: %.S prepare scripts FORCE
1289 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) 1304 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1290%.o: %.S prepare scripts FORCE 1305%.o: %.S prepare scripts FORCE
1291 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) 1306 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1292
1293# For external modules we shall include any directory of the target,
1294# but usual case there is no directory part.
1295# make M=`pwd` module.o => $(dir $@)=./
1296# make M=`pwd` foo/module.o => $(dir $@)=foo/
1297# make M=`pwd` / => $(dir $@)=/
1298
1299ifeq ($(KBUILD_EXTMOD),)
1300 target-dir = $(@D)
1301else
1302 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1303 target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1304endif
1305 1307
1306/ %/: scripts prepare FORCE 1308# Modules
1309/ %/: prepare scripts FORCE
1307 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1310 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1308 $(build)=$(target-dir) 1311 $(build)=$(build-dir)
1309%.ko: scripts FORCE 1312%.ko: prepare scripts FORCE
1310 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1313 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1311 $(build)=$(target-dir) $(@:.ko=.o) 1314 $(build)=$(build-dir) $(@:.ko=.o)
1312 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 1315 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1313 1316
1314# FIXME Should go into a make.lib or something 1317# FIXME Should go into a make.lib or something