diff options
Diffstat (limited to 'Documentation/kbuild/modules.txt')
-rw-r--r-- | Documentation/kbuild/modules.txt | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index c91caf7eb30..7e77f93634e 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt @@ -18,6 +18,7 @@ In this document you will find information about: === 5. Include files --- 5.1 How to include files from the kernel include dir --- 5.2 External modules using an include/ dir + --- 5.3 External modules using several directories === 6. Module installation --- 6.1 INSTALL_MOD_PATH --- 6.2 INSTALL_MOD_DIR @@ -38,7 +39,7 @@ included in the kernel tree. What is covered within this file is mainly information to authors of modules. The author of an external modules should supply a makefile that hides most of the complexity so one only has to type -'make' to buld the module. A complete example will be present in +'make' to build the module. A complete example will be present in chapter ¤. Creating a kbuild file for an external module". @@ -69,7 +70,7 @@ when building an external module. --- 2.2 Available targets - $KDIR refers to path to kernel source top-level directory + $KDIR refers to the path to the kernel source top-level directory make -C $KDIR M=`pwd` Will build the module(s) located in current directory. @@ -87,11 +88,11 @@ when building an external module. make -C $KDIR M=$PWD modules_install Install the external module(s). Installation default is in /lib/modules/<kernel-version>/extra, - but may be prefixed with INSTALL_MOD_PATH - see separate chater. + but may be prefixed with INSTALL_MOD_PATH - see separate chapter. make -C $KDIR M=$PWD clean Remove all generated files for the module - the kernel - source directory is not moddified. + source directory is not modified. make -C $KDIR M=`pwd` help help will list the available target when building external @@ -99,7 +100,7 @@ when building an external module. --- 2.3 Available options: - $KDIR refer to path to kernel src + $KDIR refers to the path to the kernel source top-level directory make -C $KDIR Used to specify where to find the kernel source. @@ -206,11 +207,11 @@ following files: KERNELDIR := /lib/modules/`uname -r`/build all:: - $(MAKE) -C $KERNELDIR M=`pwd` $@ + $(MAKE) -C $(KERNELDIR) M=`pwd` $@ # Module specific targets genbin: - echo "X" > 8123_bini.o_shipped + echo "X" > 8123_bin.o_shipped endif @@ -341,13 +342,52 @@ directory and therefore needs to deal with this in their kbuild file. EXTRA_CFLAGS := -Iinclude 8123-y := 8123_if.o 8123_pci.o 8123_bin.o - Note that in the assingment there is no space between -I and the path. - This is a kbuild limitation and no space must be present. - + Note that in the assignment there is no space between -I and the path. + This is a kbuild limitation: there must be no space present. + +--- 5.3 External modules using several directories + + If an external module does not follow the usual kernel style but + decide to spread files over several directories then kbuild can + support this too. + + Consider the following example: + + | + +- src/complex_main.c + | +- hal/hardwareif.c + | +- hal/include/hardwareif.h + +- include/complex.h + + To build a single module named complex.ko we then need the following + kbuild file: + + Kbuild: + obj-m := complex.o + complex-y := src/complex_main.o + complex-y += src/hal/hardwareif.o + + EXTRA_CFLAGS := -I$(src)/include + EXTRA_CFLAGS += -I$(src)src/hal/include + + + kbuild knows how to handle .o files located in another directory - + although this is NOT reccommended practice. The syntax is to specify + the directory relative to the directory where the Kbuild file is + located. + + To find the .h files we have to explicitly tell kbuild where to look + for the .h files. When kbuild executes current directory is always + the root of the kernel tree (argument to -C) and therefore we have to + tell kbuild how to find the .h files using absolute paths. + $(src) will specify the absolute path to the directory where the + Kbuild file are located when being build as an external module. + Therefore -I$(src)/ is used to point out the directory of the Kbuild + file and any additional path are just appended. === 6. Module installation -Modules which are included in the kernel is installed in the directory: +Modules which are included in the kernel are installed in the directory: /lib/modules/$(KERNELRELEASE)/kernel @@ -365,7 +405,7 @@ External modules are installed in the directory: => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel INSTALL_MOD_PATH may be set as an ordinary shell variable or as in the - example above be specified on the commandline when calling make. + example above be specified on the command line when calling make. INSTALL_MOD_PATH has effect both when installing modules included in the kernel as well as when installing external modules. @@ -384,7 +424,7 @@ External modules are installed in the directory: === 7. Module versioning -Module versioning are enabled by the CONFIG_MODVERSIONS tag. +Module versioning is enabled by the CONFIG_MODVERSIONS tag. Module versioning is used as a simple ABI consistency check. The Module versioning creates a CRC value of the full prototype for an exported symbol and |