# Makefile --
#
#       FIXME: This file needs a description here.
#
# Copyright (c) 2000-2002 The 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:
#
# A. Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.
# B. 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.
# C. Neither the names of the copyright holders nor the names of its
#    contributors may be used to endorse or promote products derived from this
#    software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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.

include ../../vd.inc

MASH_HOME = ../../../..
TCL_DIR = tcl/vd/qm/utils
HEAD_FILE = tclsh-head.tcl

RM = rm -f
CC = gcc
INCLUDE_DIRS = -I../../../../rtp
CFLAGS = $(INCLUDE_DIRS)


C_TARGETS = getindex gettimes ts_b2a log_b2a ts_fill ts_check ts_old_b2a \
	    getdata old2new log_num add_ssrc log_fullb2a
MASH_TARGETS =
SMASH_TARGETS =
TCLSH_TARGETS = mark2graph switch2graph getcampos range sim2graph mark2state \
		sim2state analyze index2times evaluate evalnonew sim2area \
		mark2area evalarea
ALL_TARGETS = $(MASH_TARGETS) $(SMASH_TARGETS) $(TCLSH_TARGETS) $(C_TARGETS)


default: $(ALL_TARGETS)

sim2graph: sim2graph.tcl
mark2graph: mark2graph.tcl
switch2graph: switch2graph.tcl
getcampos: getcampos.tcl
range: range.tcl
mark2state: mark2state.tcl
sim2state: sim2state.tcl
analyze: analyze.tcl
index2times: index2times.tcl
evaluate: evaluate.tcl
checksame: checksame.tcl
evalnonew: evalnonew.tcl
mark2area: mark2area.tcl
sim2area: sim2area.tcl
evalarea: evalarea.tcl

$(TCLSH_TARGETS):

	cd $(MASH_HOME); \
	$(TCLSH) tcl-expand.tcl $(TCL_DIR)/$(HEAD_FILE) $(TCL_DIR)/$@.tcl $@ > $(TCL_DIR)/$@
	chmod 744 $@

getdata: getdata.o
getindex: getindex.o
gettimes: gettimes.o
ts_b2a: ts_b2a.o
log_b2a: log_b2a.o
ts_fill: ts_fill.o
ts_check: ts_check.o
ts_old_b2a: ts_old_b2a.o
old2new: old2new.o
log_num: log_num.o
add_ssrc: add_ssrc.o
log_fullb2a: log_fullb2a.o

%.o: %.c
	$(CC) $(CFLAGS) -c $<

$(C_TARGETS):
	$(CC) $(CFLAGS) -o $@ $@.o


clean:
	$(RM) *.tmp *.o $(ALL_TARGETS)

BEGIN_INDEX = 16250
END_INDEX = 18000

compare:
	mark2graph log.mark > graph.tmp
	filterrange graph.tmp $(BEGIN_INDEX) $(END_INDEX) > graph.mark
	$(RM) graph.tmp
	log_b2a log.audienceLeft > graph.tmp
	range graph.tmp $(BEGIN_INDEX) $(END_INDEX) > graph.audienceLeft
	$(RM) graph.tmp
	log_b2a log.speaker > graph.tmp
	range graph.tmp $(BEGIN_INDEX) $(END_INDEX) > graph.speaker
	$(RM) graph.tmp
	log_b2a log.audienceRight > graph.tmp
	range graph.tmp $(BEGIN_INDEX) $(END_INDEX) > graph.audienceRight
	$(RM) graph.tmp
	log_b2a log.audienceCenter > graph.tmp
	range graph.tmp $(BEGIN_INDEX) $(END_INDEX) > graph.audienceCenter
	$(RM) graph.tmp
	assembleMarkGraph.tcl graph.mark graph.speaker graph.audienceLeft \
	graph.audienceRight graph.audienceCenter > outfile

