CC = gcc.exe
CFLAGS = -Wall -O2

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

.o.emx:
	$(CC) -o $*.emx $<


DPMI = dpmi.o dpmi10.o

all: dpmiinfo.emx dpmifun.emx

dpmi.o: \rsx\source\asm32\dpmi.c
	$(CC) $(CFLAGS) -c -I.. -o dpmi.o \rsx\source\asm32\dpmi.c
dpmi10.o: \rsx\source\asm32\dpmi10.S
	$(CC) $(CFLAGS) -c -x assembler-with-cpp -o dpmi10.o \rsx\source\asm32\dpmi10.s


dpmiinfo.emx: dpmiinfo.o $(DPMI)
	$(CC) -o dpmiinfo.emx dpmiinfo.o $(DPMI)

dpmifun.emx: dpmifun.o dpmifun2.o dpmifun.h input.o $(DPMI)
	$(CC) -o dpmifun.emx dpmifun.o dpmifun2.o input.o $(DPMI)
dpmifun2.o: dpmifun2.s
	as -o dpmifun2.o dpmifun2.s
dpmifun.o: dpmifun.c dpmifun.h
	$(CC) $(CFLAGS) -c dpmifun.c


# distribution

STUB	= \rsx\bin\emxldpmi.exe

dpmifun.exe: dpmifun.emx \rsx\bin\emxldpmi.exe
	emxbind -b -s $(STUB) dpmifun.emx \rsx\bin\dpmifun.exe

dpmiinfo.exe: dpmiinfo.emx \rsx\bin\emxldpmi.exe
	emxbind -b -s $(STUB) dpmiinfo.emx \rsx\bin\dpmiinfo.exe
