Makefile hello module ko
2022/03/04 11:32
瀏覽73
迴響0
推薦0
引用0
令人迷惑的Makefile
產出module ko, 有2種方式
kernel build, menuconfig select M
Single build.
---
若,single buid, make指令有帶4個參數
CROSS_COMPILE=
ARCH=
-C "..."
M="..."
Makefile內容,只要
obj-m:=demo.o
狀況類似 kernel build with M.
-----------------
若,single build,make指令不帶參數
Makefile內容,就要複雜點了
make前要export ARCH 及 CROSS_COMPILE
---
ifneq ($(KERNELRELEASE),)
obj-m:=demo.o
else
KSRC="/home/ai7688/0221/openwrt-b4d7885/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/linux-5.4.154"
modules:
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KSRC) M=$(shell pwd) modules
clean:
rm -rf *.o *.ko *~ *.mod.c *.order *.symvers
endif
產出module ko, 有2種方式
kernel build, menuconfig select M
Single build.
---
若,single buid, make指令有帶4個參數
CROSS_COMPILE=
ARCH=
-C "..."
M="..."
Makefile內容,只要
obj-m:=demo.o
狀況類似 kernel build with M.
-----------------
若,single build,make指令不帶參數
Makefile內容,就要複雜點了
make前要export ARCH 及 CROSS_COMPILE
---
ifneq ($(KERNELRELEASE),)
obj-m:=demo.o
else
KSRC="/home/ai7688/0221/openwrt-b4d7885/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/linux-5.4.154"
modules:
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KSRC) M=$(shell pwd) modules
clean:
rm -rf *.o *.ko *~ *.mod.c *.order *.symvers
endif
自訂分類:linux_cc
上一則: warnning of " this statement may fall through [-Wimplicit-fallthrough=]" 下一則: Unknown symbol
你可能會有興趣的文章:
限會員,要發表迴響,請先登入

