Documente Academic
Documente Profesional
Documente Cultură
gcc c list.c
gcc c string.c
gcc c main.c
MAKEFILES
MAKEFILES
A dependency specifies
target : source1 source2 ...
e.g.
eva1: eval.o tokens.o stack1.o
EXAMPLE MAKEFILE
game : main.o list.o string.o
gcc -o game main.o list.o string.o -lm
main.o : main.c list.h string.h
gcc -Wall -Werror O -c main.c
list.o : list.c list.h
gcc -Wall -Werror O -c list.c
string.o : string.c
gcc -Wall -Werror O -c string.c
clean :
rm -f *.o core
clobber : clean
rm -f game
main.o
$(CC)
list.o
$(CC)
Etc
RUNNING MAKE
To build the first target in the makefile just type
make
If make arguments are targets, build just those
targets:
make world.o
make clean
make clobber
# COMP1927 lab02
CC=gcc
CFLAGS=-Wall -Werror -O
.PHONY: clean clobber
# indicates the two targets dont create any file
all: testStack testArrayQueue testListQueue
# indicates files created
testStack: testStack.o arrayStack.o
$(CC) -o testStack arrayStack.o testStack.o
testStack.o: testStack.c Stack.h Item.h
$(CC) -c $(CFLAGS) testStack.c
arrayStack.o: arrayStack.c Stack.h Item.h
$(CC) -c $(CFLAGS) arrayStack.c
testArrayQueue: testQueue.o arrayQueue.o
$(CC) -o testArrayQueue arrayQueue.o testQueue.o
testListQueue: testQueue.o listQueue.o
$(CC) -o testListQueue listQueue.o testQueue.o
arrayQueue.o: arrayQueue.c Queue.h Item.h
$(CC) -c $(CFLAGS) arrayQueue.c
listQueue.o: listQueue.c Queue.h Item.h
$(CC) -c $(CFLAGS) listQueue.c
testQueue.o: testQueue.c Queue.h Item.h
$(CC) -c $(CFLAGS) testQueue.c
clean:
rm -f *.o
clobber: clean
rm testStack testListQueue testArrayQueue