尝试编写通用的Makefile,但隐式规则搜索尚未完成

时间:2020-09-17 01:11:09

标签: makefile

嗨,我正在尝试编写一个通用的(基本)Makefile来编译基本的c程序。 我有一个正在练习c编程的src目录。我的目录结构如下所示:

practice/src/ex1.c
             ex2.c
             ex3.c
practice/build

我的Makefile看起来像这样:

blddir = ./build
srcdir = ./src

# RM="find $(blddir) -maxdepth 1 -executable -type f -name 'ex*' -delete"

CFLAGS=-Wall -g

$(csrc): %.c
   $(CC) -o $(blddir)/$@  $(srcdir)/$^ # all prereqs

clean:
   find $(blddir) -maxdepth 1 -executable -type f -name 'ex*' -delete

当我跑步:make ex6时,我受到欢迎:make: *** No rule to make target 'ex6'. Stop. 当我跑步时:make -p ex6 | less ...然后搜索ex6,我看到了:

.DEFAULT_GOAL := src/ex6.c

src/ex6.c: %.c
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.
#  recipe to execute (from 'Makefile', line 15):
    $(CC) -o $(blddir)/$@  $(srcdir)/$^ # all prereqs

我想念什么?

谢谢!

...更多阅读更多测试,新增Makefile:

blddir = ./build
srcdir = ./src

CFLAGS=-Wall -g

% : $(srcdir)/%.c
   $(CC) -o $(blddir)/$@  $^ # all prereqs

制作ex6 ...并且有效

0 个答案:

没有答案