Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

makefile - How to "make" existing Linux kernel module driver after modifying the driver source code

I have made some trivial modifications to a Linux USB Wi-Fi card driver to insert some logging (printk statements). I am loosely following a guide on how to recompile/load the module, which states that I need to execute make in order to build the .ko file. There is an existing Makefile in the working directory (/usr/src/linux/drivers/net/wireless/rtl818x/rtl8187/), which reads:

rtl8187-objs        := dev.o rtl8225.o leds.o rfkill.o

obj-$(CONFIG_RTL8187)   += rtl8187.o

ccflags-y += -Idrivers/net/wireless/rtl818x

When I execute make inside this directory, I get:

make: *** No targets.  Stop.

According to this, this means "that some makefile was found, but it didn't contain any default goal and none was given on the command line. GNU make has nothing to do in these situations."

So my question is, what does this mean in the context of what I am trying to do, and how do I go about generating the .ko file which I am purported to need for the next step?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You must run make from the top directory of the Linux source (/usr/src/linux/). Be sure that your driver is included in your /usr/src/linux/.config file. So, build the kernel with your driver. If you don't want to rebuild the entire kernel, read more :)

If you want to re-build all modules inside the directory:

make M=drivers/net/wireless/rtl818x/rtl8187/

If you want to re-build a single module inside the directory:

make M=drivers/net/wireless/rtl818x/ CONFIG_RTL8187=m

The *CONFIG_RTL8187* name can be found in drivers/net/wireless/rtl818x/Kconfig (CONFIG_ + RTL8187)

It should works also this:

make drivers/net/wireless/rtl818x/rtl8187/rtl8187.ko

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...