diff options
-rw-r--r-- | Documentation/kbuild/modules.txt | 11 | ||||
-rw-r--r-- | Makefile | 66 |
2 files changed, 55 insertions, 22 deletions
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 7e77f93634ea..87d858df4e34 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt | |||
@@ -13,6 +13,7 @@ In this document you will find information about: | |||
13 | --- 2.2 Available targets | 13 | --- 2.2 Available targets |
14 | --- 2.3 Available options | 14 | --- 2.3 Available options |
15 | --- 2.4 Preparing the kernel tree for module build | 15 | --- 2.4 Preparing the kernel tree for module build |
16 | --- 2.5 Building separate files for a module | ||
16 | === 3. Example commands | 17 | === 3. Example commands |
17 | === 4. Creating a kbuild file for an external module | 18 | === 4. Creating a kbuild file for an external module |
18 | === 5. Include files | 19 | === 5. Include files |
@@ -131,6 +132,16 @@ when building an external module. | |||
131 | Therefore a full kernel build needs to be executed to make | 132 | Therefore a full kernel build needs to be executed to make |
132 | module versioning work. | 133 | module versioning work. |
133 | 134 | ||
135 | --- 2.5 Building separate files for a module | ||
136 | It is possible to build single files which is part of a module. | ||
137 | This works equal for the kernel, a module and even for external | ||
138 | modules. | ||
139 | Examples (module foo.ko, consist of bar.o, baz.o): | ||
140 | make -C $KDIR M=`pwd` bar.lst | ||
141 | make -C $KDIR M=`pwd` bar.o | ||
142 | make -C $KDIR M=`pwd` foo.ko | ||
143 | make -C $KDIR M=`pwd` / | ||
144 | |||
134 | 145 | ||
135 | === 3. Example commands | 146 | === 3. Example commands |
136 | 147 | ||
@@ -137,7 +137,7 @@ objtree := $(CURDIR) | |||
137 | src := $(srctree) | 137 | src := $(srctree) |
138 | obj := $(objtree) | 138 | obj := $(objtree) |
139 | 139 | ||
140 | VPATH := $(srctree) | 140 | VPATH := $(srctree):$(KBUILD_EXTMOD) |
141 | 141 | ||
142 | export srctree objtree VPATH TOPDIR | 142 | export srctree objtree VPATH TOPDIR |
143 | 143 | ||
@@ -849,27 +849,6 @@ prepare prepare-all: prepare0 | |||
849 | 849 | ||
850 | export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) | 850 | export 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 | ||
1177 | prepare: ; | ||
1178 | scripts: ; | ||
1195 | endif # KBUILD_EXTMOD | 1179 | endif # KBUILD_EXTMOD |
1196 | 1180 | ||
1197 | # Generate tags for editors | 1181 | # Generate tags for editors |
@@ -1313,6 +1297,44 @@ kernelrelease: | |||
1313 | kernelversion: | 1297 | kernelversion: |
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 | |||
1323 | ifeq ($(KBUILD_EXTMOD),) | ||
1324 | target-dir = $(@D) | ||
1325 | else | ||
1326 | zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) | ||
1327 | target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) | ||
1328 | endif | ||
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 | ||