【发布时间】:2019-02-07 13:51:46
【问题描述】:
我正在学习一些关于将一些 C 代码编译成特定程序集的课程。我决定应该手动检查生成的程序集,所以我想出了less something.s 作为“测试”规则。
作为 Make 的粉丝但新手,我编写了这个 Makefile:
CODES := a
LESS ?= less
CODES_TEST := $(patsubst %,%-test,${CODES})
.PHONY: all test ${CODES_TEST} clean
all: $(patsubst %,%.s,${CODES})
test: all
%-test: %.s
${LESS} $^
%.s: %.c
${CC} ${CFLAGS} -S -o $@ $^
clean:
rm -f *.o *.s
我有这个最小的a.c 文件:
int asdfg(void) { return 54321; }
然后我在 Bash 中输入 make a-test,期待 less 出现 a.s 的内容,结果却被告知:
make: Nothing to be done for 'a-test'.
无论a.s 是否存在,我都会收到上述响应,如果我执行make a.s 或只是make(隐式运行第一条规则,all),则会正常生成。
我检查了我的 Makefile,我认为我没有犯错字或其他简单的错误。
- 上述
Makefile遗漏了什么? - 当我运行
make a-test时,如何让 Make 执行less a.s?
【问题讨论】: