Managing and Developing Dynamically Loadable Kernel Modules

Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12 569
Makefile
#
# This makefile needs to be invoked as follows:
#
#make <options>
#
# Here, options include:
#
# all to configure module and create device file
# config to configure the module in target system
# dev to create the necessary device file
# load to load the module
# status to show status of loaded module(s)
# clobber to unconfigure the module and remove device file
#
# CC must be set to the Ansi-C compiler installed on the target
# system, e.g. CC=/opt/ansic/bin/cc
#
#
#Change these 3, and all character and block device
#drivers should work.
#
MODULE=dlclass
DEV_C=/dev/dlclass
DEV_B=
all: config dev
config:mod.o
kminstall -a $(MODULE) 2> /dev/null
config -M $(MODULE) -u 2> /dev/null
dev:config $(DEV_C) $(DEV_B)
#
#If the module requires a block device, this target can be
#used as a template. Replace “DEV_C” with “DEV_B”,
#“Character” with “Block”, and the “c” in the mknod command
#with a “b”.
#
$(DEV_C):
kmadmin -L $(MODULE)