Short answer : this syntax does not work the way you want. The right way to do what you want in GNU, to do the syntax, is to use template rules:
public%.o: public%.c hashtable.h $(CC) $(CFLAGS) -c $< public%: public%.o $(CC) -o $@ $<
Long answer : This:
public*.o: public*.c hashtable.h
doesn't mean what you want it to mean. Assuming you have several public01.c files, etc., and without public01.o files, etc., at the beginning of your build, this syntax is equivalent to this:
public*.o: public01.c public02.c public03.c ... hashtable.h
That is, if public01.o , etc. does not exist, then make will use the literal string public*.o as the file name. If some of the .o files exist, then this syntax is equivalent to this:
public01.o public02.o ...: public01.c public02.c ... hashtable.h
It seems that you want the right? But this is a common misunderstanding with make, because in fact this line is exactly the same:
public01.o: public01.c public02.c ... hashtable.h public02.o: public01.c public02.c ... hashtable.h
That is, each .o file has a dependency on each .c ! The right way to do what you want is to use a template rule as shown above.
source share