我对make缺乏经验,我希望复制由第三方SDK提供的构建结构,并使其适应我自己的编译器和项目。
问题是,我发现一些规则是使用makefile作为先决条件生成的,如下所示:
...
$(eval $(1): Makefile | $(dir $(1)).) \
...或
$(OUTPUT_DIRECTORY)/%.inc: Makefile | $(OUTPUT_DIRECTORY)
$(info Generating $@)
$(NO_ECHO)$(call dump, $(call target_specific, INC_PATHS, $*)) > $@最初,他们的makefile是大写的(makefile),而我正在做的是小写(Makefile)。无论如何,当我尝试当前更改时,会出现以下错误:
*** No rule to make target 'Makefile', needed by '...'我认为这是由于大写,所以在两个地方都改为小写,然后再试一次,但这次错误是makefile被当作C文件处理(这是我的猜测.)
"makefile", line 1: error #171: expected a declaration
-include makefile.local
^
"makefile", line 67: error #8: missing closing quote
${CG_TOOL_ROOT}/include"
^
"makefile", line 99: error #10: "#" not expected here
.SUFFIXES: # ignore built-in rules
^
"makefile", line 100: error #10: "#" not expected here
%.d: # don't try to make .d files
^
"makefile", line 100: error #8: missing closing quote
%.d: # don't try to make .d files这里有什么问题?我遗漏了什么吗?
编辑1:这些是我正在尝试使用的文件。
北欧提供这些作为其SDK的一部分,用于开发,使用arm-gcc作为ARM平台。每个项目都有一个Makefile,主Makefile中包含一个Makefile.common。
另一方面,我试图理解和复制相同的内容,但对于另一个具有不同选项和语法的专有编译器(TI的cl430 for MSP430平台)。从最初的Makefile.common中,我删除了对gnu-arm套件的一些引用,并用适当的编译工具替换它。在makefile中,我还试图复制原始的相同结构,但使用我的源和选项。
为了说明清楚,原件是大写的,我的是小写的。
编辑2:
在运行make --debug --print-data-base之后,我发现了以下内容:
在第一次尝试生成文件时会出现此错误:
Updating goal targets....
File 'default' does not exist.
File 'test_project' does not exist.
File '_build/test_project.out' does not exist.
File '_build/test_project/<SOURCE_FILE>.c.o' does not exist.
Must remake target '_build/test_project/<SOURCE_FILE>.c.o'.
Building file: "makefile"
Invoking: MSP430 Compiler
"cl430" -vmspx --use_hw_mpy=F5 <... a lot of options ...> --obj_directory="./_build" "makefile"
"makefile", line 1: error #171: expected a declaration
-include makefile.local
^
[ ... more errors ...]但是,从调试和DB信息中,我发现源文件规则确实需要makefile,而且makefile不是目标,但它试图构建它:
# Not a target:
makefile:
# Implicit rule search has been done.
# Last modified 2020-02-25 11:43:33.609423171
# File has been updated.
# Successfully updated.
_build/test_project/<SOURCE_FILE>.c.o: makefile | _build/test_project/.
# Implicit rule search has been done.
# Implicit/static pattern stem: '_build/test_project/<SOURCE_FILE>'
# Modification time never checked.
# File has been updated.
# Failed to be updated.
# automatic
# @ := _build/test_project/<SOURCE_FILE>.c.o
# automatic
# % :=
# automatic
# * := _build/test_project/<SOURCE_FILE>
# automatic
# + := makefile
# automatic
# | := _build/test_project/.
# automatic
# < := makefile
# automatic
# ^ := makefile
# automatic
# ? := makefile
# variable set hash-table stats:
# Load=8/32=25%, Rehash=0, Collisions=1/30=3%
# recipe to execute (from 'makefile.common', line 192):
@echo 'Building file: "$<"'
@echo 'Invoking: MSP430 Compiler'
"${CG_TOOL_ROOT}/bin/cl430" -vmspx --use_hw_mpy=F5 <... a lot of options ...> "$(shell echo $<)"
@echo 'Finished building: "$<"'
@echo ' '发布于 2020-02-24 17:37:28
对Makefile的依赖是为了确保当Makefile被更改时,它会重新构建。例如,如果您将CFLAGS中的Makefile或规则更改为编译或链接,则此依赖项将触发重新构建(提供的对象文件依赖于Makefile,这是它们应该做的)。如果没有对Makefile的依赖,这些更改将不会导致重建。
"makefile", line 1: error #171: expected a declaration形式的错误消息表明,makefile作为源文件传递给生成错误消息的C编译器。
规则最有可能是针对$(filter-out Makefile,$^)的。您需要将所有出现的Makefile替换为makefile。
*** No rule to make target 'Makefile', needed by '...'意味着Makefile仍然是某些目标的先决条件。通过将--debug --print-data-base命令行选项传递给make,可以找到这些目标是什么。
https://stackoverflow.com/questions/60380543
复制相似问题