我正在使用包含以下命令的构建脚本编译内核模块:
make -C /lib/modules/$(uname -r)/build SUBDIRS=$PWD modules
这曾经有效...但现在失败并出现以下错误:
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-42-generic'
fs/aufs/Makefile:3: fs/aufs/magic.mk: No such file or directory
make[3]: *** No rule to make target 'fs/aufs/magic.mk'. Stop.
scripts/Makefile.clean:67: recipe for target 'fs/aufs' failed
make[2]: *** [fs/aufs] Error 2
Makefile:1738: recipe for target '_clean_fs' failed
make[1]: *** [_clean_fs] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-42-generic'
Makefile:39: recipe for target 'clean' failed
make: *** [clean] Error 2
构建在此停止,没有其他输出。发生了什么?
答案1
重要的线索是无法编译的内核版本:5.4.0-42-generic。
对参数的支持SUBDIRS
是在该版本中删除了支持更新的M
参数和KBUILD_EXTMOD
环境变量。
以前的版本(自11/2018)即使在成功编译时也会打印一条警告,因此根据您更新软件包的频率,这应该已经显示了一段时间:
make[1]: Entering directory '/usr/src/linux-headers-5.3.0-40-generic'
Makefile:227: ================= WARNING ================
Makefile:228: 'SUBDIRS' will be removed after Linux 5.3
Makefile:229:
Makefile:230: If you are building an individual subdirectory
Makefile:231: in the kernel tree, you can do like this:
Makefile:232: $ make path/to/dir/you/want/to/build/
Makefile:233: (Do not forget the trailing slash)
Makefile:234:
Makefile:235: If you are building an external module,
Makefile:236: Please use 'M=' or 'KBUILD_EXTMOD' instead
Makefile:237: ==========================================
不要忽视这些警告!它们几乎总是指示区域技术债务。
您需要更新您的构建才能使用构建外部模块的新方法。