João Paulo
João Paulo

Reputation: 6690

gmake wildcard function not generating target

I'm using gmake on Windows with MinGW. This is a snippet of the makefile:

SRCS = ..\path\to\srcs\*.c*
SRCS := $(wildcard $(SRCS))
OBJS := $(addsuffix .o,$(basename $(SRCS)))

$(OBJS) : $(SRCS)
    $(CC) $(FLGAS) $(INCLUDES) "$<"

I'm getting the following:

gmake: *** No targets. Stop.

If I define SRCS, for instance, as ..\path\to\srcs\a.c, it works. Am I using wildcard in the correct manner?

I'm using GNU Make 3.81.

Upvotes: 0

Views: 56

Answers (1)

tripleee
tripleee

Reputation: 189679

make doesn't cope well with backslashes; you need to double each, or (better) switch to forward slashes instead.

Your recipe overrides the built-in rules for creating object files from C files with a broken one, though. Your recipe claims that all $(OBJS) will be produced from a single compilation which has all the $(SRCS) as dependencies, but only reads the first one ($< pro $^). It's probably better to just say what you want and let make take it from there.

.PHONY: all
all: $(OBJS)
%.o: ../path/to/srcs/%.c

Upvotes: 1

Related Questions