我正在尝试将调试目标添加到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
有什么建议?
最佳答案
您缺少%.o-dbg: %c
中的点。它可能应该改为读取%.o-dbg: %.c
。