# Makefile for sample AVI capture drivers based on the C&T 9001 Chip
#
# make clean	deletes files that can be regenerated by rebuilding 

# Use names below to build Truevision Bravado driver
NAME       = BRAVADO
MODNAME    = AVIBRAV
DLLNAME    = VW

# Use names below to build Creative Labs VideoBlaster driver
#NAME      = VBLASTER
#MODNAME   = AVIVBLST
#DLLNAME   = PCVIDEO

# Common section
EXT     = drv
OBJ1    = libinit.obj 
OBJ2    = drvproc.obj initc.obj inita.obj vmsg.obj
OBJ3    = flat.obj mapa.obj mapc.obj ctdev.obj
OBJ4    = cap.obj muldiv.obj config.obj isr.obj rect.obj yuv.obj
OBJ     = $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4)

LIBS    = $(DLLNAME) libw mmsystem mdllcew ver

!if "$(DEBUG)" == "NO"
CLOPT   = -Oxw
MASMOPT =
LINKOPT =
!else
CLOPT   = -Oxw -Zid -Fc -DDEBUG
MASMOPT = -Zi -DDEBUG
LINKOPT = /CO/LI
!endif

CC      = cl -I. -c -nologo -Alnw -G2s -Zp -W3 $(CLOPT) -D_$(NAME)
ASM     = masm -Mx -t -D?QUIET $(MASMOPT)
LINK    = link /NOPACKC/NOD/NOE/MAP/ALIGN:16 $(LINKOPT)

goal:  $(NAME).sym $(NAME).DRV
    @echo ***** finished making $(NAME) *****
    copy $(NAME).drv ..\..\bin

############## clean ##############

clean:
    -@del *.drv
    -@del *.res
    -@del *.sym
    -@del *.map
    -@del *.obj
    -@del *.err
    -@del *.cod

###################################

$(NAME).$(EXT) $(MODNAME).map: $(OBJ) $(NAME).def $(NAME).res
    @$(LINK) @<<
$(OBJ),
$(NAME).$(EXT),
$(MODNAME).map,
$(LIBS),
$(NAME).def
<<
        rc -t -31 $(NAME).res $(NAME).$(EXT)
        -cvpack -p $(NAME).$(EXT)

$(NAME).sym:    $(MODNAME).map
        -mapsym /n $(MODNAME).map
        copy $(MODNAME).sym $(NAME).sym

$(NAME).rc:    vidsrc.dlg config.h vidfmt.dlg vidfmt.dlg config.dlg\
        viddsp.dlg ct.rcv

$(NAME).res:    $(NAME).rc ct.rcv 
        @rc $(RDEBUG) -I. -r -z $(NAME).rc


########### segmentation ##########
#
#   INIT is the init/exit time segment
#   VCAP is the random segment
#   _TEXT is the interrupt time fixed segment

SEGC = $(CC) -NT TSEG  $*.c
SEGA = $(ASM) -DSEGNAME=TSEG  $*.asm;

initc.obj   : initc.c ; $(SEGC:TSEG=INIT)
libinit.obj : libinit.asm ; $(SEGA:TSEG=INIT)
inita.obj   : inita.asm ; $(SEGA:TSEG=INIT)

cap.obj     : cap.c ; $(SEGC:TSEG=_TEXT)
isr.obj     : isr.asm ; $(SEGA:TSEG=_TEXT)
mapa.obj    : mapa.asm ; $(SEGA:TSEG=_TEXT)
drvproc.obj : drvproc.c ; $(SEGC:TSEG=_TEXT)
vmsg.obj    : vmsg.c ; $(SEGC:TSEG=_TEXT)
yuv.obj     : yuv.c ; $(SEGC:TSEG=_TEXT)
muldiv.obj  : muldiv.asm ; $(SEGA:TSEG=_TEXT)
ctdev.obj   : ctdev.c ; $(SEGC:TSEG=_TEXT)

config.obj  : config.c ; $(SEGC:TSEG=VCAP)
mapc.obj    : mapc.c ; $(SEGC:TSEG=VCAP)
flat.obj    : flat.asm ; $(SEGA:TSEG=VCAP)
rect.obj    : rect.c ; $(SEGC:TSEG=VCAP)

############# depend ##############
# START Dependencies 
cap.obj: cap.c ct.h

config.obj: config.c config.h ct.h

ctdev.obj: ctdev.c ct.h 

convert.obj: convert.asm pcvideo.inc

drvproc.obj: drvproc.c config.h ct.h debug.h

initc.obj: initc.c ct.h debug.h

inita.obj: inita.asm vcap.inc

flat.obj: flat.asm vcap.inc

mapc.obj: mapc.c ct.h

mapa.obj: mapa.asm

libinit.obj: libinit.asm

isr.obj: isr.asm vcap.inc

rect.obj: rect.c ct.h

muldiv.obj: muldiv.asm

vmsg.obj: vmsg.c config.h ct.h

yuv.obj: yuv.c ct.h

# END Dependencies 
