I have a directory with 50 .c source files and each one of these .c files depends on a .h file with the same name plus a common header file.
Example:
foo.c depends on foo.h and common.h
bar.c depends on bar.h and common.h
baz.c depends on baz.h and common.h
Is it possible to setup this dependency without having to make a separate target for each .c file?
In case it matters, the ultimate output of this Makefile will be a libfoo.a library containing each of these .o files.
If at all possible I would like to do this with gnu make syntax and not have a target for each file whether or not that target was created manually or by something like makedepend.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With