Creating rules – targets, dependencies, and actions
A rule consists of one or more targets with one or more dependencies to perform one or more actions:
<target1> <target2> ... : <dependency1> <dependency2> ... <action1> <action2> ...
Yes, that’s a lot of possibilities. However, we will limit ourselves to a single target for each rule. Again, remember that each action line begins with <tab>
.
We can have quite a few dependencies. In our current makefile
, if we change any header file, nothing happens. To fix this, we can make all of the header files dependencies for dealer
. Modify your makefile
to add those dependencies, as follows:
CC = clang CCFLAGS = -Wall -Werror -std=c17 dealer: card.c hand.c deck.c dealer.c card.h hand.h deck.h $(CC) $^ -o $@ $(CCFLAGS)
Save it. In the repository, this makefile is named makefile.4a
. In the terminal...