# Makefile for nasm assembly code (and corresponding C code)

all: hello.out printf1.out printf2.out \
     intarith.out fltarith.out

hello.out: hello.asm
	nasm -f elf -l hello.lst  hello.asm
	gcc -o hello  hello.o
	hello > hello.out

printf1.out: printf1.asm printf1.c
	nasm -f elf -l printf1.lst  printf1.asm
	gcc -o printf1  printf1.o
	printf1 > printf1.out
	gcc printf1.c
	a.out > printf1.outc
	rm -f a.out

printf2.out: printf2.asm printf2.c
	nasm -f elf -l printf2.lst  printf2.asm
	gcc -o printf2  printf2.o
	printf2 > printf2.out
	gcc printf2.c
	a.out > printf2.outc
	rm -f a.out

intarith.out: intarith.asm intarith.c
	nasm -f elf -l intarith.lst  intarith.asm
	gcc -o intarith  intarith.o
	intarith > intarith.out
	gcc intarith.c
	a.out > intarith.outc
	rm -f a.out

fltarith.out: fltarith.asm fltarith.c
	nasm -f elf -l fltarith.lst  fltarith.asm
	gcc -o fltarith  fltarith.o
	fltarith > fltarith.out
	gcc fltarith.c
	a.out > fltarith.outc
	rm -f a.out

recompile:
	rm -f *.out
	rm -f *.outc
	make all

clean:  # for moving to another platform, keeping results
	rm -f hello
	rm -f printf1
	rm -f printf2
	rm -f intarith
	rm -f fltarith
	rm -f a.out
	rm -f *~
	rm -f core*
	rm -f *.o

initial:
	rm -f *.out
	rm -f *.outc
	rm -f *.lst
	rm -f *.s
	make clean

web:
	chgrp cseeweb *
	chmod go+rx *
	chmod g+w *