app: main.o Triangle.o Point.o gcc main.o Triangle.o Point.o -o app main.o: main.c Triangle.h Point.h gcc -c main.c Triangle.o: Triangle.c Triangle.h Point.h gcc -c Triangle.c Point.o: Point.c Point.h gcc -c Point.c ------------------------------------------------------- CC = gcc # the compiler CFLAGS = -Wall # the compiler flags OBJ1 = file1.o utils.o # object files for the first executable OBJ2 = file2.o utils.o # object files for the second executable # the first target. Both executable will be made when 'make' is # invoked with no target all: prog1 prog2 # general rule how to compile a source file and produce an object file .c.o: $(CC) $(CFLAGS) -c $< # linking rule for the first executable prog1: $(OBJ1) $(CC) $(CFLAGS) $(OBJ1) -o prog1 # linking rule for the second executable prog2: $(OBJ2) $(CC) $(CFLAGS) $(OBJ2) -o prog2 depend: echo -e '\n' >> makefile $(CC) -MM *.c >> makefile