#
#  Copyright (c) 1991-1993 Regents of the University of California.
#  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#	This product includes software developed by the Computer Systems
#	Engineering Group at Lawrence Berkeley Laboratory.
# 4. Neither the name of the University nor of the Laboratory may be used
#    to endorse or promote products derived from this software without
#    specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#) $Header: /work/projects/tove/cvs/src/testing/vat/makefile.vc,v 1.1 1997/12/08 17:22:51 parnanen Exp $ (LBL)
#

ZIP = c:\progra~1\winzip\winzip32 

# Uncomment this line to compile an optimized (with no debug symbols)
# version of the program.
NODEBUG=1

APPVER=4.0
TOOLS32       = c:\msdev
cc32 = $(TOOLS32)\bin\cl -I$(TOOLS32)\include
rc32 = $(TOOLS32)\bin\rc
link32 = $(TOOLS32)\bin\link

!include <ntwin32.mak>

.SUFFIXES: .cc

ALL = vat
all:	$(ALL)

.cc.obj:
	$(cc32) $(cdebug) $(cflags) $(cvars) $(CFLAGS) -o $@ -FR$*.sbr -Tp $<

.c.obj:
	$(cc32) $(cdebug) $(cflags) $(cvars) $(CFLAGS) -o $@ -FR$*.sbr $<

BSC32= bscmake
BSC32_FLAGS=/nologo /n

MKDEP = ./mkdep

INCLUDE_TK = -I../tk4.1/win -I../tk4.1/generic
INCLUDE_TCL = -I../tcl7.5/win -I../tcl7.5/generic
INCLUDE_X11 = -I../tk4.1/xlib
INCLUDE_MISC = 
INCLUDE_GSM = -I../gsm-1.0-pl7/inc

LIB_TK = ../tk4.1/win/tk41.lib
LIB_TCL = ../tcl7.5/win/tcl75.lib
LIB_GSM = ../gsm-1.0-pl7/lib/gsm.lib

LIB_AUDIO = 
INCLUDE_AUDIO = 
OBJ_AUDIO = audio-win32.obj
OBJ_CRYPT = 
SRC_AUDIO = $(OBJ_AUDIO:.o=.cc) 
LIBS = $(LIB_AUDIO) $(LIB_GSM) $(LIB_TK) $(LIB_TCL)
INCLUDES = $(INCLUDE_MISC) $(INCLUDE_AUDIO) $(INCLUDE_TK) $(INCLUDE_TCL) \
	$(INCLUDE_X11) $(MD_INC)
DEFINE = -DSIGRET=void -DSIGARGS=int -DFRAMESIZE=160
BFLAGS = -D_Windows -DVC_EXTRALEAN $(DEFINE) $(INCLUDES)
CFLAGS = $(CCOPT) $(BFLAGS)

#
# Remember to add a dependency if you add any tcl sources here.
#
TCL_VAT = tkerror.tcl entry.tcl ui-main.tcl ui-resource.tcl ui-util.tcl \
	ui-stats.tcl ui-audio.tcl ui-win32.tcl \
	cf-main.tcl cf-network.tcl cf-util.tcl cf-confbus.tcl 

LIBRARY_TK = ../tk4.1/library
LIBRARY_TCL = ../tcl7.5/library
TK_LIBRARY_FILES = \
		$(LIBRARY_TCL)/init.tcl \
		$(LIBRARY_TK)/tk.tcl \
		$(LIBRARY_TK)/button.tcl \
		$(LIBRARY_TK)/dialog.tcl \
		$(LIBRARY_TK)/entry.tcl \
		$(LIBRARY_TK)/focus.tcl \
		$(LIBRARY_TK)/listbox.tcl \
		$(LIBRARY_TK)/menu.tcl \
		$(LIBRARY_TK)/palette.tcl \
		$(LIBRARY_TK)/scale.tcl \
		$(LIBRARY_TK)/tearoff.tcl \
		$(LIBRARY_TK)/text.tcl \
		$(LIBRARY_TK)/optMenu.tcl $(LIBRARY_TK)/scrlbar.tcl

#
# These modules are broken in libg++.  Rather than fix libg++
# every time I install it on a given system, just make them
# here (these sources came from tcl's compat directory)
#
BROKEN_OBJ = 
OBJ0 =	getopt.obj win32.obj win32X.obj
OBJ1 =	inet.obj tonetab.obj adpcm.obj lpc.obj tkStripchart.obj md5c.obj random.obj vat-gsm.obj
OBJ2 =	session.obj session-vat.obj source.obj audio.obj controller.obj \
	crypt.obj crypt-dull.obj filter.obj group-ipc.obj iohandler.obj main.obj \
	net.obj net-ip.obj observe.obj sitebox.obj confbus.obj \
	ss.obj timer.obj idlecallback.obj Tcl.obj Tcl2.obj tkwidget.obj \
	vu.obj wiener.obj media-timer.obj transmitter.obj rate-variable.obj \
	encoder.obj encoder-lpc.obj encoder-adpcm.obj encoder-gsm.obj \
	decoder.obj decoder-lpc.obj decoder-adpcm.obj decoder-gsm.obj
OBJ3 =	tabmulaw.obj tabmix.obj tabsmix.obj tabmulawx.obj
OBJ4 =	$(TCL_VAT:.tcl=.obj) tk.obj version.obj
SRC =	$(OBJ1:.obj=.c) $(OBJ2:.obj=.cc) $(OBJ_ARCH:.obj=.cc) $(OBJ_AUDIO:.obj=.cc) \
	$(OBJ_CRYPT:.obj=.cc)
OBJ =	$(OBJ0) $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ_ARCH) $(BROKEN_OBJ) \
	$(OBJ_AUDIO) $(OBJ_CRYPT)
SRC3 =	$(OBJ3:.obj=.c)
SBR =	$(OBJ:.obj=.sbr)

#vat: vat.exe vat.bsc
vat: vat.exe

vat.exe: $(OBJ)
	$(link32) $(linkdebug) /warn:3 $(guilflags) $(OBJ) $(LIBS)\
		$(guilibs) wsock32.lib winmm.lib /out:$@

vat.bsc : $(OUTDIR)  $(SBR)
    $(BSC32) @<<
  $(BSC32_FLAGS) /o$@ $(SBR)
<<

#
# pass-1 embedded tcl files
#
tk.obj: $(TK_LIBRARY_FILES) tcl2c++.exe
	-del $@
	.\tcl2c++ 1 $(TK_LIBRARY_FILES) > tk.cc
	$(cc32) $(cdebug) $(cflags) $(cvars) -o $@ -FR$*.sbr -c $(CFLAGS) -Tp $(@:.obj=).cc
	del $(@:.obj=).cc

#
# pass-2 embedded tcl files
#
$(TCL_VAT:.tcl=.obj): tcl2c++.exe
	-del $@
	.\tcl2c++ 2 $(@:.obj=).tcl > $(@:.obj=).cc
	$(cc32) $(cdebug) $(cflags) $(cvars) -o $@ -FR$*.sbr -c $(CFLAGS) -Tp $(@:.obj=).cc
	del $(@:.obj=).cc

tkerror.obj: tkerror.tcl
entry.obj: entry.tcl
ui-main.obj: ui-main.tcl
ui-audio.obj: ui-audio.tcl
ui-util.obj: ui-util.tcl
ui-win32.obj: ui-win32.tcl
ui-stats.obj: ui-stats.tcl
ui-resource.obj: ui-resource.tcl
cf-main.obj: cf-main.tcl
cf-network.obj: cf-network.tcl
cf-util.obj: cf-util.tcl
cf-confbus.obj: cf-confbus.tcl

mkversion.exe: mkversion.obj
	-del $@
	$(cc32) /nologo -o $@ $(CFLAGS) mkversion.obj

version.c: mkversion.exe VERSION
	-del version.c
	.\mkversion < VERSION > version.c

version.mak: mkversion.exe VERSION
	-del version.mak
	.\mkversion VATVERSION=%%s < VERSION > version.mak

$(OBJ3): $(SRC3)
	$(cc32) $(cdebug) $(cflags) $(cvars) $(RFLAG) -o $@ -FR$*.sbr $*.c

mktab.exe: mktab.obj getopt.obj
	-del $@
	$(cc32) /nologo -o $@ $(CFLAGS) mktab.obj getopt.obj

$(SRC3): mktab.exe
	-del $(SRC3)
	.\mktab -mulaw > tabmulaw.c
	.\mktab -sum > tabmix.c
	.\mktab -scale > tabsmix.c
	.\mktab -muX > tabmulawx.c
	-del mktab

vat-gsm.obj: vat-gsm.c
	$(cc32) $(cdebug) $(cflags) $(cvars) $(INCLUDE_GSM) $(CFLAGS) -o $@ -FR$*.sbr $*.c

install: vat.exe
	-mkdir "\Program Files\MBone"
	copy vat.exe "\Program Files\MBone\vat.exe"

tar:	vat.exe Changes.html README version.mak
	type makefile.vc >> version.mak
	nmake -f version.mak vatzip
	-del version.mak

vatzip:
	-del Changes.htm
	-del Readme.txt
	copy Changes.html Changes.htm
	copy README Readme.txt
	-del vatbin-$(VATVERSION)-win95.zip
	$(ZIP) -a c:.\vatbin-$(VATVERSION)-win95.zip Readme.txt Changes.htm vat.exe
	-del Changes.htm
	-del Readme.txt

clean:
	-del *.obj
	-del *.sbr
	-del tcl2c++.exe
	-del mktab.exe
	-del mkversion.exe
	-del version.c
	-del tabmix.c
	-del tabmulaw.c
	-del tabmulawx.c
	-del tabsmix.c
		
depend:
	$(MKDEP) $(INCLUDES) $(DEFINE) $(INCLUDE_GSM) $(SRC)
