aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2006-01-25 01:13:18 -0500
committerSam Ravnborg <sam@mars.ravnborg.org>2006-02-19 03:51:17 -0500
commit06300b21f4c79fd1578f4b7ca4b314fbab61a383 (patch)
tree9b9506e34286f0333ed747c47ec03fd5559f5b71 /Makefile
parentbd71c2b17468a2531fb4c81ec1d73520845e97e1 (diff)
kbuild: support building individual files for external modules
Support building individual files when dealing with separate modules. So say you have a module named "foo" which consist of two .o files bar.o and fun.o. You can then do: make -C $KERNELSRC M=`pwd` bar.o make -C $KERNELSRC M=`pwd` bar.lst make -C $KERNELSRC M=`pwd` bar.i make -C $KERNELSRC M=`pwd` / <= will build all .o files and link foo.o make -C $KERNELSRC M=`pwd` foo.ko <= will build the module and do the modpost step to create foo.ko The above will also work if the external module is placed in a subdirectory using a hirachy of kbuild files. Thanks to Andreas Gruenbacher <agruen@suse.de> for initial feature request / bug report. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile66
1 files changed, 44 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 77a448c8e776..639d8a48bbde 100644
--- a/Makefile
+++ b/Makefile
@@ -137,7 +137,7 @@ objtree := $(CURDIR)
137src := $(srctree) 137src := $(srctree)
138obj := $(objtree) 138obj := $(objtree)
139 139
140VPATH := $(srctree) 140VPATH := $(srctree):$(KBUILD_EXTMOD)
141 141
142export srctree objtree VPATH TOPDIR 142export srctree objtree VPATH TOPDIR
143 143
@@ -849,27 +849,6 @@ prepare prepare-all: prepare0
849 849
850export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) 850export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
851 851
852# Single targets
853# ---------------------------------------------------------------------------
854
855%.s: %.c scripts FORCE
856 $(Q)$(MAKE) $(build)=$(@D) $@
857%.i: %.c scripts FORCE
858 $(Q)$(MAKE) $(build)=$(@D) $@
859%.o: %.c scripts FORCE
860 $(Q)$(MAKE) $(build)=$(@D) $@
861%.ko: scripts FORCE
862 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) $(@:.ko=.o)
863 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
864%/: scripts prepare FORCE
865 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
866%.lst: %.c scripts FORCE
867 $(Q)$(MAKE) $(build)=$(@D) $@
868%.s: %.S scripts FORCE
869 $(Q)$(MAKE) $(build)=$(@D) $@
870%.o: %.S scripts FORCE
871 $(Q)$(MAKE) $(build)=$(@D) $@
872
873# FIXME: The asm symlink changes when $(ARCH) changes. That's 852# FIXME: The asm symlink changes when $(ARCH) changes. That's
874# hard to detect, but I suppose "make mrproper" is a good idea 853# hard to detect, but I suppose "make mrproper" is a good idea
875# before switching between archs anyway. 854# before switching between archs anyway.
@@ -1192,6 +1171,11 @@ help:
1192 @echo ' modules_install - install the module' 1171 @echo ' modules_install - install the module'
1193 @echo ' clean - remove generated files in module directory only' 1172 @echo ' clean - remove generated files in module directory only'
1194 @echo '' 1173 @echo ''
1174
1175# Dummies...
1176.PHONY: prepare scripts
1177prepare: ;
1178scripts: ;
1195endif # KBUILD_EXTMOD 1179endif # KBUILD_EXTMOD
1196 1180
1197# Generate tags for editors 1181# Generate tags for editors
@@ -1313,6 +1297,44 @@ kernelrelease:
1313kernelversion: 1297kernelversion:
1314 @echo $(KERNELVERSION) 1298 @echo $(KERNELVERSION)
1315 1299
1300# Single targets
1301# ---------------------------------------------------------------------------
1302# The directory part is taken from first prerequisite, so this
1303# works even with external modules
1304%.s: %.c scripts FORCE
1305 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1306%.i: %.c scripts FORCE
1307 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1308%.o: %.c scripts FORCE
1309 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1310%.lst: %.c scripts FORCE
1311 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1312%.s: %.S scripts FORCE
1313 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1314%.o: %.S scripts FORCE
1315 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1316
1317# For external modules we shall include any directory of the target,
1318# but usual case there is no directory part.
1319# make M=`pwd` module.o => $(dir $@)=./
1320# make M=`pwd` foo/module.o => $(dir $@)=foo/
1321# make M=`pwd` / => $(dir $@)=/
1322
1323ifeq ($(KBUILD_EXTMOD),)
1324 target-dir = $(@D)
1325else
1326 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1327 target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1328endif
1329
1330/ %/: scripts prepare FORCE
1331 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1332 $(build)=$(target-dir)
1333%.ko: scripts FORCE
1334 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1335 $(build)=$(target-dir) $(@:.ko=.o)
1336 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1337
1316# FIXME Should go into a make.lib or something 1338# FIXME Should go into a make.lib or something
1317# =========================================================================== 1339# ===========================================================================
1318 1340