makefile

PROGRAM=hw5
CC=gcc
CFLAGS=-m32
ASM=nasm
ASMFLAGS=-f elf

default: $(PROGRAM)

$(PROGRAM): $(PROGRAM)_ex1.o $(PROGRAM)_ex2.o $(PROGRAM)_ex3.o driver.o asm_io.o
	$(CC) $(CFLAGS) $(PROGRAM)_ex1.o driver.o asm_io.o -o $(PROGRAM)_ex1
	$(CC) $(CFLAGS) $(PROGRAM)_ex2.o driver.o asm_io.o -o $(PROGRAM)_ex2
	$(CC) $(CFLAGS) $(PROGRAM)_ex3.o driver.o asm_io.o -o $(PROGRAM)_ex3

$(PROGRAM)_ex1.o: $(PROGRAM)_ex1.asm
	$(ASM) $(ASMFLAGS) $(PROGRAM)_ex1.asm -o $(PROGRAM)_ex1.o

$(PROGRAM)_ex2.o: $(PROGRAM)_ex2.asm
	$(ASM) $(ASMFLAGS) $(PROGRAM)_ex2.asm -o $(PROGRAM)_ex2.o

$(PROGRAM)_ex3.o: $(PROGRAM)_ex3.asm
	$(ASM) $(ASMFLAGS) $(PROGRAM)_ex3.asm -o $(PROGRAM)_ex3.o

asm_io.o: asm_io.asm
	$(ASM) $(ASMFLAGS) -d ELF_TYPE asm_io.asm -o asm_io.o

driver.o: driver.c
	$(CC) $(CFLAGS) -c driver.c -o driver.o

clean:
	/bin/rm -f *.o $(PROGRAM)_ex1 $(PROGRAM)_ex2 $(PROGRAM)_ex3
Valid HTML 4.01 Valid CSS