diff options
Diffstat (limited to 'Documentation/kbuild')
-rw-r--r-- | Documentation/kbuild/modules.txt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 1c0db652b366..7e77f93634ea 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt | |||
@@ -18,6 +18,7 @@ In this document you will find information about: | |||
18 | === 5. Include files | 18 | === 5. Include files |
19 | --- 5.1 How to include files from the kernel include dir | 19 | --- 5.1 How to include files from the kernel include dir |
20 | --- 5.2 External modules using an include/ dir | 20 | --- 5.2 External modules using an include/ dir |
21 | --- 5.3 External modules using several directories | ||
21 | === 6. Module installation | 22 | === 6. Module installation |
22 | --- 6.1 INSTALL_MOD_PATH | 23 | --- 6.1 INSTALL_MOD_PATH |
23 | --- 6.2 INSTALL_MOD_DIR | 24 | --- 6.2 INSTALL_MOD_DIR |
@@ -344,6 +345,45 @@ directory and therefore needs to deal with this in their kbuild file. | |||
344 | Note that in the assignment there is no space between -I and the path. | 345 | Note that in the assignment there is no space between -I and the path. |
345 | This is a kbuild limitation: there must be no space present. | 346 | This is a kbuild limitation: there must be no space present. |
346 | 347 | ||
348 | --- 5.3 External modules using several directories | ||
349 | |||
350 | If an external module does not follow the usual kernel style but | ||
351 | decide to spread files over several directories then kbuild can | ||
352 | support this too. | ||
353 | |||
354 | Consider the following example: | ||
355 | |||
356 | | | ||
357 | +- src/complex_main.c | ||
358 | | +- hal/hardwareif.c | ||
359 | | +- hal/include/hardwareif.h | ||
360 | +- include/complex.h | ||
361 | |||
362 | To build a single module named complex.ko we then need the following | ||
363 | kbuild file: | ||
364 | |||
365 | Kbuild: | ||
366 | obj-m := complex.o | ||
367 | complex-y := src/complex_main.o | ||
368 | complex-y += src/hal/hardwareif.o | ||
369 | |||
370 | EXTRA_CFLAGS := -I$(src)/include | ||
371 | EXTRA_CFLAGS += -I$(src)src/hal/include | ||
372 | |||
373 | |||
374 | kbuild knows how to handle .o files located in another directory - | ||
375 | although this is NOT reccommended practice. The syntax is to specify | ||
376 | the directory relative to the directory where the Kbuild file is | ||
377 | located. | ||
378 | |||
379 | To find the .h files we have to explicitly tell kbuild where to look | ||
380 | for the .h files. When kbuild executes current directory is always | ||
381 | the root of the kernel tree (argument to -C) and therefore we have to | ||
382 | tell kbuild how to find the .h files using absolute paths. | ||
383 | $(src) will specify the absolute path to the directory where the | ||
384 | Kbuild file are located when being build as an external module. | ||
385 | Therefore -I$(src)/ is used to point out the directory of the Kbuild | ||
386 | file and any additional path are just appended. | ||
347 | 387 | ||
348 | === 6. Module installation | 388 | === 6. Module installation |
349 | 389 | ||