试图编写一个通用的Makefile,我发现隐式规则搜索还没有完成
您好,我正在尝试编写一个通用(基本)Makefile来编译基本的、实践的c程序。 我有一个src目录,我正在其中练习c编程。我的目录结构如下所示:试图编写一个通用的Makefile,我发现隐式规则搜索还没有完成,makefile,Makefile,您好,我正在尝试编写一个通用(基本)Makefile来编译基本的、实践的c程序。 我有一个src目录,我正在其中练习c编程。我的目录结构如下所示: practice/src/ex1.c ex2.c ex3.c practice/build blddir = ./build srcdir = ./src # RM="find $(blddir) -maxdepth 1 -executable -type f -name 'ex*'
practice/src/ex1.c
ex2.c
ex3.c
practice/build
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
我的Makefile如下所示:
practice/src/ex1.c
ex2.c
ex3.c
practice/build
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
当我运行:makeex6
时,我会遇到:make:**没有规则将目标设置为“ex6”。停止。
当我运行时:make-pex6 | 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
我错过了什么
谢谢
…更多阅读更多测试,新(er)生成文件:
blddir = ./build
srcdir = ./src
CFLAGS=-Wall -g
% : $(srcdir)/%.c
$(CC) -o $(blddir)/$@ $^ # all prereqs
制造ex6
…并且它可以工作请检查Makefile:它不包括csrc的定义请检查Makefile:它不包括csrc的定义