Makefile 将变量定义拆分为不同的行

Makefile 将变量定义拆分为不同的行,makefile,Makefile,好吧,我想这是愚蠢的(过去也做过),但我真的不记得是怎么做的 我有一个变量,比如: GCC = gcc 到目前为止一切都很好 现在,如果我的变量定义太长并希望将其拆分为不同的行,使其看起来美观且易于管理,该怎么办 D_FILES = main console globals components/program components/statement components/statements components/assignment components/loop compone

好吧,我想这是愚蠢的(过去也做过),但我真的不记得是怎么做的

我有一个变量,比如:

GCC = gcc
到目前为止一切都很好

现在,如果我的变量定义太长并希望将其拆分为不同的行,使其看起来美观且易于管理,该怎么办

D_FILES     = main console globals components/program components/statement components/statements components/assignment components/loop components/block components/library components/argument components/expression components/expressions components/functionDecl components/ruleDecl components/functionCall components/functionCallSt components/returnSt components/outSt components/inSt

我想你可以这样做

CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
        -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
        -DDEFBLOCKING=$(DEFBLOCKING)

在和处放置反斜杠,并以
选项卡开始的新行

我不知道为什么使用反斜杠会有问题,但您可以这样做:

D_FILES = main console globals components/program components/statement
D_FILES += components/statements components/assignment components/loop
D_FILES += components/block components/library components/argument
# and so on

像这样,在放入任意数量的值后插入一个反斜杠,后面是换行符、制表符,然后是更多的值(反斜杠、换行符、制表符、再次添加值…)@devnull尝试了那个值(我实际尝试的第一个值),但无论出于何种原因,它似乎正在中断…:无论出于何种原因,稳定部队似乎正在崩溃,但这并不是一个我们可以做任何事情的问题描述。如果它不起作用,问这个问题,并提供一个例子(剪切粘贴,而不是解释!)说明你做了什么,以及你得到了什么错误消息。无需以
TAB
开头(这只会在CFLAGS的定义中嵌入
TAB
s)。我建议用两个空格缩进。缩进显示结构,并保留
TAB
s以供配方中使用。