Makefile: Efficient way to make all '.c' files depend on a header file with the same name?
As far as I know this should suffice.
%.o: %.c %.h common.h
\tgcc -c $<
\t
is a tab, and the gcc -c $<
is of course just an example.
OBJECTS = $(patsubst %.c,%.o,$(wildcard *.c))
%.o: %.c %.h common.h
gcc -c $< -o $@
libfoo.a: $(OBJECTS)
ar rcs $@ $^