[prev] [index] [next]

Exercise: MyInt module (cont)

Can generalise the Makefile by defining and using variables

Can also add a target to clean up directory

Example:

CC=gcc
CFLAGS=-Wall -Werror

tester: tester.o MyInt.o
	$(CC) $(CFLAGS) -o tester tester.o MyInt.o

tester.o: tester.c MyInt.h
	$(CC) $(CFLAGS) -c tester.c

MyInt.o: MyInt.c MyInt.h
	$(CC) $(CFLAGS) MyInt.c

clean:
	rm -f tester tester.o MyInt.o core