# History:25,17

.SUFFIXES: .obj .c .asm

AFLAGS = /mx /zi /zd
CFLAGS = -ms -M -G- -O -Z -a -1 -f- -d -w -g12

CC=tcc
ASM=tasm

.c.obj:
	$(CC) $(CFLAGS) -DFOR_GO32=1 -c $*.c

.asm.obj:
	$(ASM) $(AFLAGS) /DFOR_GO32=1 $*;

END =

GRDRIVER = vesadrv.vdr

OBJS =\
	control.obj \
	dalloc.obj \
	doutils.obj \
	dpmi.obj \
	dpmisim.obj \
	event.obj \
	evintr.obj \
	exphdlr.obj \
	extdebug.obj \
	graphics.obj \
	grprot.obj \
	mono.obj \
	mswitch.obj \
	npx.obj \
	paging.obj \
	tables.obj \
	ustat.obj \
	utils.obj \
	valloc.obj \
	vga.obj \
	xms.obj \
	vcpi.obj \
	driver.obj

all : \
	go32t.exe \
	stub.exe \
	coff2exe.exe \
	exe2coff.exe \
	stubedit.exe \
	$(END)

go32t.exe : $(OBJS) stamp.exe
	$(CC) -ls $(CFLAGS) -ego32t.exe *.obj
	stamp go32t.exe

stamp.exe : stamp.c
	tcc stamp.c
	@del stamp.obj

stub.exe: stub.c gotypes.h stubinfo.h fixstub.exe
	$(CC) $(CFLAGS) stub.c
	@del stub.obj
	-tdstrip stub
	fixstub

fixstub.exe : fixstub.c stubinfo.h gotypes.h
	$(CC) $(CFLAGS) fixstub.c
	@del fixstub.obj
	-tdstrip fixstub

coff2exe.exe : coff2exe.c stubbyte.h
	$(CC) $(CFLAGS) coff2exe.c
	@del coff2exe.obj
	-tdstrip coff2exe

stubbyte.h : bin2byte.exe stub.exe
	bin2byte stub.exe stub_bytes stubbyte.h

bin2byte.exe : bin2byte.c
	$(CC) bin2byte.c
	@del bin2byte.obj
	-tdstrip bin2byte

exe2coff.exe : exe2coff.c
	$(CC) $(CFLAGS) exe2coff.c
	@del exe2coff.obj
	-tdstrip exe2coff

stubedit.exe : stubedit.c gotypes.h stubinfo.h
	$(CC) $(CFLAGS) stubedit.c
	@del stubedit.obj

driver.h: $(GRDRIVER) driver.ext bin2byte.exe
	copy /b $(GRDRIVER)+driver.ext driver.tmp
	bin2byte driver.tmp DRIVER_CODE driver.h
	del driver.tmp

clean :
	del *.obj
	del *.map
	del *.exe
	del stubbyte.h
	del driver.h

# DEPENDENCIES

coff2exe.obj : stubbyte.h

control.obj : gotypes.h gdt.h idt.h tss.h valloc.h utils.h graphics.h mono.h vcpi.h paging.h dpmi.h extdebug.h exphdlr.h dalloc.h mswitch.h xms.h npx.h stubinfo.h proginfo.h control.h

dalloc.obj : gotypes.h valloc.h dalloc.h mono.h control.h

driver.obj : driver.h

event.obj : eventque.h

exphdlr.obj : gotypes.h gdt.h idt.h tss.h utils.h paging.h npx.h mono.h vcpi.h graphics.h dpmi.h extdebug.h ustat.h dpmisim.h dalloc.h valloc.h control.h eventque.h

extdebug.obj : gotypes.h aout.h extdebug.h dpmi.h paging.h tss.h exphdlr.h mswitch.h utils.h gdt.h eventque.h

fixstub.obj : gotypes.h stubinfo.h

graphics.obj : gotypes.h paging.h graphics.h tss.h gdt.h grdriver.h

mono.obj : mono.h

paging.obj : gotypes.h paging.h graphics.h tss.h idt.h gdt.h valloc.h dalloc.h utils.h aout.h mono.h vcpi.h dpmi.h extdebug.h exphdlr.h stubinfo.h proginfo.h control.h

stub.obj : gotypes.h stubinfo.h

stubedit.obj : gotypes.h stubinfo.h

ustat.obj : ustat.h

valloc.obj : gotypes.h valloc.h xms.h mono.h vcpi.h utils.h paging.h stubinfo.h proginfo.h control.h mswitch.h

xms.obj : xms.h

utils.obj : gotypes.h tss.h gdt.h utils.h dpmi.h mswitch.h exphdlr.h

doutils.obj : segdefs.inc tss.inc gdt.inc idt.inc

dpmi.obj : segdefs.inc tss.inc

dpmisim.obj : segdefs.inc tss.inc gdt.inc idt.inc

grprot.obj : segdefs.inc tss.inc gdt.inc idt.inc

tables.obj : segdefs.inc tss.inc gdt.inc idt.inc

vcpi.obj : segdefs.inc vcpi.inc

vga.obj : segdefs.inc

mswitch.obj : segdefs.inc tss.inc gdt.inc idt.inc vcpi.inc

npx.obj : segdefs.inc tss.inc gdt.inc idt.inc
