openwrt添加内核模块

时间:2022-12-07 02:51:09

进行目录package/kernel

mkdir url-redirect

cd url-redirect

[zzh@KD1 url-redirect]$ tree
.
|-- Makefile
`-- src
|-- Makefile
|-- line.c
|-- line.h
|-- proc.c
|-- proc.h
|-- redirect.c
`-- redirect.h directory, files
[zzh@KD1 url-redirect]$ cat Makefile
#
# Copyright (C) - OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=url-redirect
PKG_RELEASE:= include $(INCLUDE_DIR)/package.mk define KernelPackage/url-redirect
SUBMENU:=Other modules
DEPENDS:=@!LINUX_3_3
TITLE:=Lester's Test
FILES:=$(PKG_BUILD_DIR)/url-redirect.ko
AUTOLOAD:=$(call AutoLoad,,url-redirect,)
KCONFIG:=
endef define KernelPackage/url-redirect/description
This is a url redirect model
endef MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)" define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef $(eval $(call KernelPackage,url-redirect))
[zzh@KD1 url-redirect]$ cat src/Makefile
obj-m := url-redirect.o
url-redirect-objs := proc.o line.o redirect.o

cd ../../../

make menuconfig

Kernel modules  --->  Other modules  --->  <M> kmod-url-redirect.......................................... Lester's Test

make V=99 -j 12