This Makefile will be used as a way to start new projects with the same
hierarchy. It will also be tightly coupled with the x testing framework
for c (x_tfw4c).
It has targets to setup the source, include, object, and tests
directories using the `make dirs` command.
There is some fun interesting things that I used to get the target to
recompile when the header files are updated using the -MMD and -MP flags
in gcc.
These flags basically allow for the generation of dependencies from each
source file that are exported and then included using the -include
$(DEPENDENCIES) line at the bottem of the Makefile.
Here is a project where I was just trying to figure out the nuances of
different Translation Units and the scope of variables and function.
TLDR: run gcc d.c b.c c.c and see that the linker errors
There is storage duration and linkage that can be specified for vars and
funtions.
There are four different types of Storage Duration
Automatic - which is get initialized when the block starts and dies when
the block ends
Static - which is the entire duration of the program
Thread - which i didn't get into really
Allocated - which is the typical heap allocation thingys
There are three types of linkage. Basically where can you reach a
varibale from
No Linkage - can only be refered to in the block
Internal Linkage - can only be refered to in the same TLU
External Linkage - can be reachable by any TLU in the program
This shows how defining a variable in 1 h file (a.h), which will have
external linkage because it is a file scope variables not declared
static will default to, and then #include-ing the h file in multiple
other files will lead to redefiniation exceptions thrown by the linker.
If confused see more here:
https://en.cppreference.com/w/c/language/storage_class_specifiers.html