#
# GRX 2.0 Library Makefile for Turbo C.
# Uses Turbo C Make (v3.7 worked for me)
# Make sure your shell is command.com !
#
.AUTODEPEND

!include "../makedefs.bcc"

# The library may get too complex ...
#LIBPAGE=/P32

# -w-sig : Don't warn "conversion may lose significant digits"
# -DGRX_USE_RAM3x8 : Use planed ram driver for TrueColor modes (24/32bpp)
ADDOPT = -w-sig -DGRX_USE_RAM3x8

!ifdef   DEBUG
ADDOPT = -DDEBUG=$(DEBUG) $(ADDOPT)
!endif

# SMALL_STACK: Turbo-C / Borland-C++ have only a small stack.
#              It's usually better to get memory from heap
#              instead of alloca()-ing it from stack.
ADDOPT = -DSMALL_STACK $(ADDOPT)

GRX20ST = ..\lib\$(GRX_LIB_SUBDIR)\grx20$(MODEL).lib
# Borland make fails on long lines, build lib in stages
GRX20STa= ..\lib\$(GRX_LIB_SUBDIR)\temp1.lib
GRX20STb= ..\lib\$(GRX_LIB_SUBDIR)\temp2.lib
GRX20STc= ..\lib\$(GRX_LIB_SUBDIR)\temp3.lib
TEMP_LIB= ..\lib\$(GRX_LIB_SUBDIR)\temp?.lib

INCDIR= -I. -I./include -I../include -I$(BCCROOT)/include\
	-I./vdrivers
LIBDIR= -L$(BCCROOT)/lib

OP=+
OX=.obj

!include "./stdobjs.mak"

!ifdef   DEBUG
DBG_O = +utils\dbgprint.obj
!else
DBG_O =
!endif

BCCOBJ= +fdrivers\egavga1.obj  \
	+fdrivers\ega4.obj     \
	+fdrivers\herc1.obj    \
	+fdrivers\ram3x8.obj   \
	+fdrivers\svga16.obj   \
	+fdrivers\svga24.obj   \
	+fdrivers\svga32h.obj  \
	+fdrivers\svga32l.obj  \
	+fdrivers\svga4.obj    \
	+fdrivers\svga8.obj    \
	+fdrivers\vga8x.obj    \
	+mouse\dosinput.obj    \
	+mouse\doskeys.obj     \
	+utils\bccarith.obj    \
	+utils\bcccopy.obj     \
	+utils\bccfil08.obj    \
	+utils\bccfil16.obj    \
	+utils\bccfil24.obj    \
	+utils\bccfil32.obj    \
	+vdrivers\ati28800.obj \
	+vdrivers\cl5426.obj   \
	+vdrivers\et4000.obj   \
	+vdrivers\herc.obj     \
	+vdrivers\mach64.obj   \
	+vdrivers\s3.obj       \
	+vdrivers\stdega.obj   \
	+vdrivers\stdvga.obj   \
	+vdrivers\u_egavga.obj \
	+vdrivers\u_vesa.obj   \
	+vdrivers\u_vsvirt.obj \
	+vdrivers\vesa.obj


# Borland make and librarian don't like very long lines ...
LOBJ1=$(STD_1:/=\) $(STD_2:/=\) $(STD_3:/=\) $(STD_4:/=\)
LOBJ2=$(STD_5:/=\) $(STD_6:/=\) $(STD_7:/=\) $(STD_8:/=\)
LOBJ3=$(STD_9:/=\) $(STD_10:/=\)
LOBJ4=$(STD_11:/=\) $(BCCOBJ) $(DBG_O)

all:    config.bcc $(GRX20ST) ..\bin\vesaif16.exe

clean:
	if exist draw\*.obj     del draw\*.obj
	if exist fdrivers\*.obj del fdrivers\*.obj
	if exist fonts\*.obj    del fonts\*.obj
	if exist image\*.obj    del image\*.obj
	if exist mouse\*.obj    del mouse\*.obj
	if exist pattern\*.obj  del pattern\*.obj
	if exist setup\*.obj    del setup\*.obj
	if exist shape\*.obj    del shape\*.obj
	if exist text\*.obj     del text\*.obj
	if exist user\*.obj     del user\*.obj
	if exist utils\*.obj    del utils\*.obj
	if exist vdrivers\*.obj del vdrivers\*.obj
	if exist wideline\*.obj del wideline\*.obj
	if exist ..\addons\*.obj       del ..\addons\*.obj
	if exist ..\addons\print\*.obj del ..\addons\print\*.obj
	if exist ..\addons\bmp\*.obj   del ..\addons\bmp\*.obj
	if exist ..\bin\vesaif16.exe del ..\bin\vesaif16.exe
	if exist config.bcc del config.bcc
	if exist *.asm del *.asm
	if exist *.obj del *.obj
	if exist $(TEMP_LIB) del $(TEMP_LIB)

cleanall: clean
	if exist $(GRX20ST) del $(GRX20ST)

# the & tells TLIB to continue on next line
$(GRX20ST): $(GRX20STa) $(GRX20STb) $(GRX20STc) $(LOBJ4:+=)
	if exist $(GRX20ST) del $(GRX20ST)
	$(TLIB) $(LIBPAGE) /C $(GRX20ST) @&&!
	+$(GRX20STa) &
	+$(GRX20STb) &
	+$(GRX20STc) &
	$(LOBJ4)
!

$(GRX20STa): $(LOBJ1:+=)
	if exist $(GRX20STa) del $(GRX20STa)
	$(TLIB) $(LIBPAGE) /C $(GRX20STa) @&&!
	$(LOBJ1)
!

$(GRX20STb): $(LOBJ2:+=)
	if exist $(GRX20STb) del $(GRX20STb)
	$(TLIB) $(LIBPAGE) /C $(GRX20STb) @&&!
	$(LOBJ2)
!

$(GRX20STc): $(LOBJ3:+=)
	if exist $(GRX20STc) del $(GRX20STc)
	$(TLIB) $(LIBPAGE) /C $(GRX20STc) @&&!
	$(LOBJ3)
!

..\bin\vesaif16.exe: vdrivers\vesainfo.c $(GRX20ST) config.bcc
	$(BCC) +config.bcc -e..\bin\vesaif16 @&&!
	vdrivers\vesainfo.c $(GRX20ST)
!

.c.obj:
	$(BCC) +config.bcc -c -o$*.obj $*.c

.c.asm:
	$(BCC) +config.bcc -S -o$*.asm $*.c


config.bcc: makefile.bcc ../makedefs.bcc
	copy &&!
	 $(CCOPT) $(ADDOPT)
	 $(INCDIR)
	 $(LIBDIR)
! config.bcc

#!include "depend.bcc"
