我正在尝试向当前版本添加新功能。要进行编译,我将obj-y + = mynewfeature.c添加到同一目录中的makefile中。但是我仍然需要使用来自同一目录的perl脚本生成头文件。我无法处理的问题是如何从kbuild文件调用此perl脚本。似乎makefile无法找到perl脚本的正确路径。所以我应该在kbuild文件的顶部添加什么以调用此perl脚本文件
谢谢
dir
|- mynewfeature.c
|- generator.pl
|- some_template //perl script will read this file and generate a header file
|- Makefile
Makefile:
code_to_call_perl_script // how to write this line
obj-y += mynewfeature.o
Makefile规则应如下所示:
obj-y += mynewfeature.o
# Add dependency: mynewfeature.o depends on generated header mynewheader.h.
# Note: Generated sources go in $(obj).
$(obj)/mynewfeature.o: $(obj)/mynewheader.h
# Add rule to generate the header file mynewheader.h.
# It depends on the script and the template file.
# Note: Generated sources go in $(obj).
$(obj)/mynewheader.h: $(src)/generator.pl $(src)/some_template
# (I don't know the exact command you use, but here is an example)
$(PERL) -s $(src)/generator.pl $(src)/some_template > $@
# Allow generated header file to be cleaned by "make clean".
clean-files := mynewheader.h
参考:Special Rules中Linux Kernel Makefiles中Kernel Build System中的The Linux Kernel documentation。>
有关具体示例,请参见drivers/scsi/Makefile中“ 53c700_d.h”的生成。