velikiyv4
velikiyv4

Reputation: 31

Make doesn't see rule with % mark

I'm trying to add debugging targets to a project like all-dbg but I receive an error:

    $ make all-dbg
    make: *** No rule to make target 'tted.o-dbg', needed by 'tted-dbg'.  Stop.

Here is the 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

Any suggestions?

Upvotes: 0

Views: 27

Answers (1)

user268396
user268396

Reputation: 11976

You are missing a dot in %.o-dbg: %c. It should probably read %.o-dbg: %.c instead.

Upvotes: 1

Related Questions