I doubt that you are stupid. make is not easy! People have complained loud and long about make and there have been countless attempts to replace it or cover it up with a gui project manager, but it is like a bad penny; it just won't go away.
If you break it down, a simple rule for make is:
Code:
<target> : <dependency list>
<command list>
The target is a file which should be created when the command list is executed. The dependency list is a list of targets (files) that are required when the command list is executed.
Each rule is reduced by checking the depedency list and the target. If any dependency target is missing, find the rule for that target and reduce it. When all dependencies are present, and the target is present, and the target is older than any of the dependencies, execute the command list. If the target is newer than any dependency, no action is required and the rule is satisfied.
The first rule that is evaluated is the first rule in the make file or the rule for the target specified on the make command ("make all"). The only other rules that are evaluated are targets from that dependency list which in turn may have dependent targets, which in turn...
Most confusion comes from the default rules that are builtins for make. "make -p" will display all of the builtins. For instance, one default is:
Code:
.c.o :
$(CC)$(CFLAGS) -c $<
If xxxx.o is specified as a dependency in a rule that is being evaluated and xxxx.o is not present and there is no rule in the make file for xxxx.o, make will construct the rule:
Code:
xxxx.o : xxxx.c
$(CC) $(CFLAGS) -c xxxx.c
and then evaluate it. Hopefully xxxx.c will exist and the compile will work. If xxxx.c doesn't exist and you haven't written a rule to create xxxx.c, you will probably get the "no rule to make xxxx.c" error and make will quit.
Another default rule is:
Code:
.c :
$(CC)$(CFLAGS) $< -o $@
This builtin will build an executable for a .c file. If you only have one c file, there would be one line in your makefile "all : xxxx". Better yet, you don't even need a makefile. Just do "make xxxx" in the same directory as xxxx.c and get the executable xxxx.
If you think your problem is with the default rules, add this line to your makefile: ".SUFFIXES :". This deletes all suffix rules and only uses the rules from the makefile. "make -r" does the same thing.
Use "make -n" to show the commands that will be executed by make without actually executing the commands.
Use "make -d" to show all of the steps make takes in evaluating the rules and resolving dependencies. This has a lot of output, but it does show exactly what is going on.
mumble, mumble, mumble...