Howto Install Just A Single Module

来源:互联网 发布:绘制网络拓扑图软件 编辑:程序博客网 时间:2024/06/15 09:56

Let us assume that you already did 'make modules' and 'make modules_install'. And later you did 'make clean' to free up disk space. And now, you want to change a "C" file in one of the modules and want to rebuild just that module and copy the module file to /lib/modules. How do you do it?

You can compile just a single module file (say like foo.o) and install it. For this simply edit the Makefile and change the SUBDIRS to add only those directories you are interested.

For an example, if I am interested in installing only fs/autofs module, then I do the following :

cd /usr/src/linux
cp Makefile Makefile.my
vi Makefile.my
# And comment out the line having 'SUBDIRS' and add the
# directory you are interested, for example like fs/autofs as below :
#SUBDIRS=kernel drivers mm fs net ipc lib abi crypto
SUBDIRS=fs/autofs
# Save the file Makefile.my and give -
make -f Makefile.my modules
# This will create module autofs.o
# Now, copy the module object file to destination /lib/modules
make -f Makefile.my modules_install
# And this will do 'cp autofs.o /lib/modules/2.4.18-19.8.0/kernel/fs/autofs'

Learn more about Makefile and make. See the manual for GNU make at

  • "http://www.gnu.org/manual/make" .

  • University of Utah Makefile "http://www.math.utah.edu/docs/info/make-stds_toc.html"

  • University of Hawaii Makefile "http://www.eng.hawaii.edu/Tutor/Make"

  • In Linux - man make

  • In Linux - info make

Get familiar with the Makefile which makes the modules. The Makefile has module line like

modules: $(patsubst %, _mod_%, $(SUBDIRS))

The patsubst function has the syntax $(patsubst pattern,replacement,text). It uses the percent symbol ([percnt]) the same way pattern rules do - as a string which matches in both the pattern and the replacement text. It searches the text for whitespace-separated words that match the pattern and substitutes the replacement for them.

This makefile includes shell functions as well as standard make functions. The syntax for a shell function is $(shell command). This returns the output of the shell function (stripping new lines).

原创粉丝点击