target: dependencies
action
make(Target) {
foreach Dependency do {
if (IsATarget(Dependency)) {
make(Dependency)
}
}
if (!FileExists(Target) || AnyNewer(Dependencies,Target)) {
DoActions(Target)
}
}
CC = gcc CFLAGS = -O2 -Wall LD = $(CC)
clean:
rm -f *.o *.bak *~
which causes make to delete object files and any backup files (*.bak
and *~) created by other programs such as editors.
Another common target is all that lists all the file targets to build.
To avoid confusion, non-file targets should be listed as .PHONY.
prompt> gcc -c *.c
prompt> ar -rv libmystuff.a *.o
prompt> pwd
/home/geoff/c
prompt> gcc -Wall -o MyMain.out MyMain.c -L/home/geoff/c -lmystuff
all: part1.o part2.o
gcc part1.o part2.o -o whole
part1.o: part1.c part3.o
gcc -c part1.c
gcc part1.o part3.o -o part3.out
part2.o: part2.c
gcc -c part2.c
part3.o: part3.c
gcc -c part3.c
Exam Style Questions