【发布时间】:2021-01-09 20:18:21
【问题描述】:
所以我在以下 Makefile 中有点挣扎:
src := $(wildcard *.c)
bin := $(src:%.c=out/%)
.PHONY: all
all: $(bin)
.PHONY: clean
clean:
rm -r out
out:
mkdir $@
$(bin): $(src) | out
$(CC) -Iincludes/ -Wall $< -o $@
假设我有以下目录:
$ ls
includes/ Makefile test1.c test2.c
那么我希望发生以下情况:
$ make
mkdir out
cc -Iincludes/ -Wall test1.c -o out/test2
cc -Iincludes/ -Wall test2.c -o out/test1
但实际发生了什么:
$ make
mkdir out
cc -Iincludes/ -Wall test2.c -o out/test2
cc -Iincludes/ -Wall test2.c -o out/test1
我有点不想在其他解决方案中移动文件suggest
我很确定这一定很容易,但我迷路了。感谢您的帮助。
【问题讨论】:
-
查看我刚刚给stackoverflow.com/questions/65647943/…的答案;这是同一个问题
标签: makefile