all: emu emu.athlon test.or32 rom.or32 dhry.or32 at.or32 test1.or32 test1

test1: test1.c
	gcc -DREPORT -o test1 test1.c

emu: or1kemulator.c memory.h
	egcs -O2 -mpentium -march=pentium -fomit-frame-pointer -fcse-follow-jumps \
	-fschedule-insns2 -fexpensive-optimizations -fcse-skip-blocks -o $@ $<

emu.dbg: or1kemulator.c memory.h
	egcs -g -o $@ $<

emu.w: or1kemulator.w.c memory.h
	egcs -O2 -mpentium -march=pentium -fomit-frame-pointer -fcse-follow-jumps \
	-fschedule-insns2 -fexpensive-optimizations -fcse-skip-blocks -o $@ $<

emu.athlon: or1kemulator.c memory.h
	/usr/local/pgcc/bin/gcc -O3 -mcpu=i486 -march=i486 -fomit-frame-pointer \
	-fcse-follow-jumps -fschedule-insns2 -fexpensive-optimizations \
	-fcse-skip-blocks -o $@ $<

%.or32: start.o %.o libc.o
	or32-coff-ld -o $@.coff $^
	or32-coff-objcopy -O binary $@.coff $@

%.o: %.c
	or32-coff-gcc -DOR1K -mhard-div -c -o $@ $< 

clean:
	rm -f emu emu.athlon ll lll *.o *.or32.coff *.or32

rom.or32: rom.S
	or32-coff-as -o $@.coff $^
	or32-coff-objcopy -O binary $@.coff $@

at.or32: at.S
	or32-coff-as -o $@.coff $^
	or32-coff-objcopy -O binary $@.coff $@

.SECONDARY: start.o test.o dhry.o libc.o test1.o
