Search code examples
makefile

Why doesn't this makefile pattern rule match?


I have the following structure in my project

project 
 /<source-files>
 /obj
   / <obj-files>

I have following receipe in my Makefile

ALL_OBJ := obj/malloc.o obj/ll.o obj/llist.o obj/socket.o obj/util.o obj/event.o

...

obj/%.o : ./%.c ./%.h
    $(GCC) -g -c -o $@  $< -lpthread $(ALL_INC) $(CFLAGS) ${ADD_CLFAGS}

...

libshmsock.a : $(ALL_OBJ)
    ar rcs libshmsock.a $^  

And it gives me the following error:

make: *** No rule to make target 'obj/llist.o', needed by 'libshmsock.a'.  Stop.

Why doesnt the pattern rule obj/%.o match obj/llist.o?


Solution

  • Ok i got it while i wrote the question, but I thought maybe it helps someone. The Problem was that I didn't have llist.c in my sources directory. I still find the error a bit weird though. I mean: Why doesn't makefile report an error like make: *** No rule to make target 'llist.c', needed by 'obj/llist.o'. Stop.? Would have saved me some hours