#############################################################################
#
#                   Copyright (C) 1993 Kendall Bennett.
#                           All rights reserved.
#
# Descripton:   Makefile for the SuperVGA test library.
#               MSDOS version for Borland C++ 3.0
#
# $Id: makefile 1.2 1993/03/03 10:24:27 kjb Exp $
#
#############################################################################

# Turn on autodependency checking

.AUTODEPEND

# Let make know where to find all the appropriate files

.PATH.asm       = .
.PATH.lib       = .
.PATH.obj       = .
.PATH.exe       = .

CC              = bcc               # Name of C compiler
ASM             = tasm              # Name of assembler
LINK            = tlink             # Name of linker
LIB             = tlib              # Name of librarian
LIB_FLAGS       = /C /E

!if $d(debug)
CC_DOPT         = -v                # Turn on debugging for C compiler
ASM_DOPT        = /ZI               # Turn on debugging for assembler
LINK_OPT        = /v /m /s          # Turn on debugging for linker, and mapfile
DEBUG           = -Ddebug
!endif

# We must assemble the test programs in the large memory model

MODEL           = l
ASM_MODEL       = /d__LARGE__

ASM_FLAGS       = /MX /m /i$(.PATH.asm) $(ASM_DOPT) $(ASM_MODEL)
CC_FLAGS        = -m$(MODEL) $(CC_DOPT)

# Implicit rules to make the object files for the test code

.c.obj:
    $(CC) $(CC_FLAGS) -c {$< }

.asm.obj:
	$(ASM) $(ASM_FLAGS) $<, $(.PATH.obj)\$&

# Object files required to build the libraries

OBJECTS         = modes.obj names.obj common.obj getopt.obj detectgr.obj cpu.obj
SVGA16OBJ       = svga16c.obj $(OBJECTS) svga16.obj
SVGA256OBJ      = svga256c.obj $(OBJECTS) svga256.obj
SVGA32KOBJ      = svga32kc.obj $(OBJECTS) svga32k.obj
SVGA16MOBJ      = svga16mc.obj $(OBJECTS) svga16m.obj
UVESAOBJ        = univesa.obj uvesa.obj $(OBJECTS)

all: test16.exe test256.exe test32k.exe test16m.exe univesa.exe

libs: svga16.lib svga256.lib svga32k.lib svga16m.lib

test16.exe: test16.obj svga16.lib
    $(CC) $(CC_FLAGS) -e$< test16.obj svga16.lib

test256.exe: test256.obj svga256.lib
    $(CC) $(CC_FLAGS) -e$< test256.obj svga256.lib

test32k.exe: test32k.obj svga32k.lib
    $(CC) $(CC_FLAGS) -e$< test32k.obj svga32k.lib

test16m.exe: test16m.obj svga16m.lib
    $(CC) $(CC_FLAGS) -e$< test16m.obj svga16m.lib

univesa.exe: $(UVESAOBJ)
    $(LINK) $(LINK_OPT) @univesa.rsp

# Targets to make each of the individual library files

svga16.lib: $(SVGA16OBJ)
    buildrsp &&!|
    $(SVGA16OBJ)
!   > temp.rsp
    $(LIB) $(LIB_FLAGS) $< @temp.rsp
    del temp.rsp

svga256.lib: $(SVGA256OBJ)
    buildrsp &&!|
    $(SVGA256OBJ)
!   > temp.rsp
    $(LIB) $(LIB_FLAGS) $< @temp.rsp
    del temp.rsp

svga32k.lib: $(SVGA32KOBJ)
    buildrsp &&!|
    $(SVGA32KOBJ)
!   > temp.rsp
    $(LIB) $(LIB_FLAGS) $< @temp.rsp
    del temp.rsp

svga16m.lib: $(SVGA16MOBJ)
    buildrsp &&!|
    $(SVGA16MOBJ)
!   > temp.rsp
    $(LIB) $(LIB_FLAGS) $< @temp.rsp
    del temp.rsp

# Move files from mgraph directory into the correct place for compilation

MGRAPH_STUFF    = detectgr.asm mgraph.equ mgraph.var modes.c modes.inc  \
                  sv_ports.asm sv_maxpg.asm model.mac drivers.h names.c

mgraph:
    cd ..
    copy $(MGRAPH_STUFF) drivers
    cd drivers

killmgraph:
    move $(MGRAPH_STUFF) ..

# Clean up directory removing all files not needed to make the library

clean:
    @del *.sym *.bak *.tdk *.map *.dsk
    except (uni0.obj) del *.obj

realclean:  clean
    @del *.exe *.lib

stamp:
    @foreach "rcs -N$(VERSION): -srelease" files.lst

rcsclean:
    @foreach rcsclean files.lst

# Check in the latest revisions of source files with RCS

ci:
    @foreach "ci -q -u $(RCSOPT)" files.lst

# Check out the latest revisions of source files from RCS

co:
    @foreach "co -q $(RCSOPT)" files.lst

