My Makefile looks like this:
BIN = bin OBJECTS = object1.o \ object2.o \ object3.o HDR = $(OBJECTS:%.o=%.h) header1.h header2.h MAIN = main.c CC = gcc CFLAGS = -Wall -g -std=c99 -fstack-protector-all LDFLAGS = -lpthread $(BIN): $(OBJECTS) $(MAIN) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ %.o: %.c $(HDR) $(CC) $(CFLAGS) -c $< -o $@ It seems that the %.o: %.c $(HDR) rule is not used. When invoking with option make -r it says that there's no rule to make target object.o. The build of each object file should depend on every header file. What am I missing?
Edit: I should mention that when doing echo $(HDR) than it looks like the variable contains the right values: object1.h object2.h object3.h header1.h header2.h
make -d object.o, and look at the last twenty lines or so?