バイナリhello-world.c
にコンパイルしたいこれがあります。hello-world
ただし、およびでhello-world.c
定義されたいくつかの関数に依存し、これらのヘルパーにはそれぞれおよびが含まれます。../helpers/a.c
../helpers/b.c
../helpers/a.h
../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
、その理由はわかりません。
編集: Makefile デバッグ:
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.