I’m currently writing small simple C programs. As of now my Makefiles have consisted of text something along the lines of:
program_name:
clang -o program_name program_name.c
Is this all I need? I wasn’t sure if I needed to establish dependencies between .o and .h files, even if they don’t necessarily exist in my project.
You are working too hard. You should simplify your Makefile to 2 lines:
There is no need to specify the dependency on
program_name.oorprogram_name.c, since those are implied. There is also no need to give the rule explicitly, since you are using the default rule. Dependencies on header files do need to be spelled out, however.