我试图在Arch Linux上编译示例内核模块(test.c),只需在带有source和Makefile的目录中键入 make 。
它将创建一个空文件夹 .tmp_versions 和一个空文件 Module.symvers 和 modules.order ,但没有一个 .ko
我也尝试使用Ubuntu在虚拟机下编译它,但输出却完全相同。样本来自互联网(2个)。
我还应该做些什么来编译它?
Makefile:
obj−m += test.o
default:
$(MAKE) -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
但这显示了我
make -C /lib/modules/4.18.14-arch1-1-ARCH/build SUBDIRS=/home/hime/Documents/module modules
make[1]: Entering directory '/usr/lib/modules/4.18.14-arch1-1-ARCH/build'
Building modules, stage 2.
MODPOST 0 modules
make[1]: Leaving directory '/usr/lib/modules/4.18.14-arch1-1-ARCH/build'
或(详细):
make -C "/lib/modules/4.18.14-arch1-1-ARCH/build" SUBDIRS="/home/hime/Documents/module" modules V=1
make[1]: Entering directory '/usr/lib/modules/4.18.14-arch1-1-ARCH/build'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo >&2 ; \
/bin/false)
mkdir -p /home/hime/Documents/module/.tmp_versions ; rm -f /home/hime/Documents/module/.tmp_versions/*
make -f ./scripts/Makefile.build obj=/home/hime/Documents/module
(cat /dev/null; ) > /home/hime/Documents/module/modules.order
make -f ./scripts/Makefile.modpost
find /home/hime/Documents/module/.tmp_versions -name '*.mod' | xargs -r grep -h '\.ko$' | sort -u | sed 's/\.ko$/.o/' | scripts/mod/modpost -m -a -i ./Module.symvers -I /home/hime/Documents/module/Module.symvers -o /home/hime/Documents/module/Module.symvers -S -w -s -T -
make[1]: Leaving directory '/usr/lib/modules/4.18.14-arch1-1-ARCH/build'