我有这个hello-world.c
我想编译成hello-world
二进制。但hello-world.c
取决于 and 中定义的一些函数../helpers/a.c
,../helpers/b.c
并且每个助手都分别包括../helpers/a.h
and ../helpers/b.h
。
我当前的 Makefile 看起来像
CC = @gcc
CFLAGS = -g -Wall -Wextra -Werror
CFLAGS +=
LDLIBS =
LDLIBS +=
OBJS = ../helpers/a.o ../helpers/b.o
SOURCES = hello-world.c
DESTS = hello-world
new: clean all
clean:
@rm -rf *.o */*.o $(DESTS)
all: $(OBJS) $(DESTS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%: %.c
$(CC) $(CFLAGS) -o $@ $<
但它不起作用,返回make: *** No rule to make target `../helpers/a.o', needed by `all'. Stop.
我知道 Makefile 似乎没有看到规则%.o
,但我不明白为什么。
编辑:生成文件调试:
alexandernst@stupidbox:/media/sf_procmon/procmon$ make --debug=b
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
Updating goal targets....
File `new' does not exist.
File `clean' does not exist.
Must remake target `clean'.
Successfully remade target file `clean'.
File `all' does not exist.
File `../helpers/a.o' does not exist.
Must remake target `../helpers/a.o'.
make: *** No rule to make target `../helpers/a.o', needed by `all'. Stop.