Makefile Examples
In linux module development you should use the kernel Makefile to compile your source. You have to write a tiny Makefile to do it. Many times the module built from only one source file, but not always. To build a module download the kernel source and use the same toolchain you used in the kernel build process.
One source file (simple.c):
.PHONY: modules all
obj-m := simple.o
KERNELDIR := /path/to/linux/kernel/source
PWD := $(shell pwd)
all: modules
module:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm *.ko *.o
Makefile for many source files module
.PHONY: modules all
obj-m := multi.o
multi-objs := file1.o file2.o file3.o
KERNELDIR := /path/to/linux/kernel/source
PWD := $(shell pwd)
all: modules
module:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm *.ko *.o
Recent Stories
Top DiscoverSDK Experts
Mendy Bennett
Experienced with Ad network & Ad servers.
Mobile | Ad Networks and 1 more
View Profile
Karen Fitzgerald
7 years in Cross-Platform development.
Mobile | Cross Platform Frameworks
View Profile
X
Compare Products
Select up to three two products to compare by clicking on the compare icon () of each product.
{{compareToolModel.Error}}Now comparing:
{{product.ProductName | createSubstring:25}} X
{{CommentsModel.TotalCount}} Comments
Your Comment