调试 makefile

发布于 2024-08-15 13:39:40 字数 1167 浏览 4 评论 0原文

我有一个 makefile,其中包含如下语句:

TOPICS = dmic
SRV_MODE =
ifeq "$(SRV_FLAG)"   "ON"
        SRV_MODE =  2
endif
vpath d%_srv.h $(CNT_PATH)

USER_PRE_TARGETS := $(foreach topic,$(TOPICS),$(topic)_srv.h)

dmic_srcs = $(wildcard $(CCWSCA)/dmic/src/*.c) \
              $(wildcard $(CCWSCA)/dmic/src/*.ppc)

dmic_srv.h: $(dmic_srcs)
        srvgen dmic $(SRV_MODE)

users_topic =
users_topic := $(shell ls -tr $(CCWPA)/$(CCBB)/Makefile.pre* | \
        tail -1 | awk 'BEGIN{FS="Makefile.pre."}{printf("%s\n", $$2);}')

USER_PRE_TARGETS := $(foreach topic,$(users_topic),d$(topic)_srv.h)

运行构建后,我收到如下消息:

gmake: Entering directory `/veluser2/vel/abp/bvijays/proj/c9mi790V64OG/cmi9dl'
echo dmic
dmic
srvgen dmic 2
Working on directory : /veluser2/vel/abp/bvijays/bb/cmi9dl/v79_0/dmic/src
Working on directory : /velhome/vel/ccvel/ccvel/bb/cmi9dl/v79_0/dmic/src
foreach: No match.
gmake: *** [ddmic_srv.h] Error 1
gmake: Target `pre' not remade because of errors.
gmake: Leaving directory `/veluser2/vel/abp/bvijays/proj/c9mi790V64OG/cmi9dl'

那么发出的 foreach 命令似乎存在一些问题? 由于我是这些 makefile 的新手,有人可以建议如何调试 makefile 吗?

I have a makefile which has statements like below:

TOPICS = dmic
SRV_MODE =
ifeq "$(SRV_FLAG)"   "ON"
        SRV_MODE =  2
endif
vpath d%_srv.h $(CNT_PATH)

USER_PRE_TARGETS := $(foreach topic,$(TOPICS),$(topic)_srv.h)

dmic_srcs = $(wildcard $(CCWSCA)/dmic/src/*.c) \
              $(wildcard $(CCWSCA)/dmic/src/*.ppc)

dmic_srv.h: $(dmic_srcs)
        srvgen dmic $(SRV_MODE)

users_topic =
users_topic := $(shell ls -tr $(CCWPA)/$(CCBB)/Makefile.pre* | \
        tail -1 | awk 'BEGIN{FS="Makefile.pre."}{printf("%s\n", $2);}')

USER_PRE_TARGETS := $(foreach topic,$(users_topic),d$(topic)_srv.h)

After I run the build, I get messages like the ones below:

gmake: Entering directory `/veluser2/vel/abp/bvijays/proj/c9mi790V64OG/cmi9dl'
echo dmic
dmic
srvgen dmic 2
Working on directory : /veluser2/vel/abp/bvijays/bb/cmi9dl/v79_0/dmic/src
Working on directory : /velhome/vel/ccvel/ccvel/bb/cmi9dl/v79_0/dmic/src
foreach: No match.
gmake: *** [ddmic_srv.h] Error 1
gmake: Target `pre' not remade because of errors.
gmake: Leaving directory `/veluser2/vel/abp/bvijays/proj/c9mi790V64OG/cmi9dl'

So it seems like there is some issue with the foreach command issued?
As I am new to these makefiles, could anybody please suggest how to debug the makefile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眉目亦如画i 2024-08-22 13:39:40

这有点混乱,如果不了解更多关于它运行的环境,就很难诊断。但让我们了解一些基础知识:

  • 您只在目标 (dmic_srv.h) 上进行了定义,因此当您运行不带参数的 GNU make 时,它​​将使用该目标。
  • 让标头依赖于源文件是非常不寻常的,我怀疑这就是你想要做的事情。但是你正在做代码生成,所以你没问题。
  • GNU make 中有两种不同类型的赋值。普通 = 具有延迟求值,但 := 强制立即求值。这会影响 $(foreach ) 的运行环境。
  • 您有两个 USER_PRE_TARGETS 定义,但切勿在任何地方使用它。 已添加:鉴于所有 $(foreach ) 命令都存在于这些定义中,您可以删除这些命令,看看它是否会变得更好。

This is a bit of a mess, and it is hard to diagnose without knowing more about the environment it is running it. But lets go with a few basics:

  • You have only defined on target (dmic_srv.h), so when you run GNU make without arguments it will use that target.
  • Making the header depend on the source files is very unusual, I doubt that is what you want this to do. but you're doing code generation, so you are OK there.
  • There are two different kinds of assignment in GNU make. Plain = has lazy evaulation, but := forces immediate evaluation. This effects the environment in which you $(foreach )'s are running.
  • You have two definitions of USER_PRE_TARGETS, but never use it anywhere. Added: Given that the all the $(foreach ) commands exist in these definitions, you might just remove these and see if it get better.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文