我尝试将调试目标添加到all-dbg
等项目中,但收到错误消息:
$ make all-dbg
make: *** No rule to make target 'tted.o-dbg', needed by 'tted-dbg'. Stop.
这是Makefile:
TARGET=tted
CC=gcc
CFLAGS=-Wall -std=c99
CFLAGS-dbg=-g
LDFLAGS=-lncurses
all: $(TARGET)
all-dbg: $(TARGET)-dbg
SOURCES=$(wildcard *.c)
HEADERS=$(wildcard *.h)
OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
OBJECTS-dbg=$(patsubst %.c, %.o-dbg, $(SOURCES))
PCHEADERS=$(HEADERS:=.gch)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o-dbg: %c
$(CC) $(CFLAGS) $(CFLAGS-dbg) -c $< -o $@
%.h.gch: %.h
$(CC) $(CFLAGS) $<
$(TARGET): $(PCHEADERS) $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(TARGET)-dbg: $(PCHEADERS) $(OBJECTS-dbg)
$(CC) $(OBJECTS-dbg) $(LDFLAGS) -o $@
clean:
-rm -f *.o
-rm -f *.o-dbg
-rm -f *.h.gch
-rm -f $(TARGET)
-rm -f $(TARGET)-dbg
有什么建议吗?
答案 0 :(得分:1)
您在%.o-dbg: %c
中缺少一个点。它可能应该改为%.o-dbg: %.c
。