########################################################-*-mode:Makefile-*-
##                                                                       ##
##  Festival's Local installation's configuration rules                  ##
##                                                                       ##
###########################################################################
##
##  Specific config file for local installation
##
##  This file will be included by all Makefiles in the system
##  The variables TOP, DIRNAME and FILES will always be set
##  when this file is included
##

## Select one of these compilers

COMPILER=GCC
# COMPILER=SUN_CC

## turn on some of these options to control compilation.
## OPTIMISE=4 turns off DEBUG
## DEBUG=fence compiles with the fence debugging malloc library.

OPTIMISE=3
WARN=1
# VERBOSE=1
# DEBUG=1

## NCD's NAS (formerly netaudio) network transparent audio system
## Only needed if your speechtools library is compiled with NAS support
# INCLUDE_NAS=1

## SGI's 16 bit linear audio
## Only needed if your speechtools library is compiled with IRIX audio support
# INCLUDE_IRIX_AUDIO=1

##  The GNU readline library for command line editing and so on
INCLUDE_READLINE=1

##  Support for TCL (used by OGI's CSLU toolkit)
# INCLUDE_TCL=1

## descriptions of different compiling environments. 

ifeq ($(COMPILER),SUN_CC)
	CC = /opt/SUNWspro/bin/cc
	CXX = /opt/SUNWspro/bin/CC 

	CFLAGS =
	CXXFLAGS = -D__svr4__

	DEBUG_CCFLAGS = -g
	DEBUG_CXXFLAGS =  -g
	WARN_CCFLAGS = +w +w2
	WARN_CXXFLAGS = +w +w2
	VERBOSE_CCFLAGS =
	VERBOSE_CXXFLAGS = -ptv
	OPTIMISE_CCFLAGS = -xO$(OPTIMISE)
	OPTIMISE_CXXFLAGS = -O$(OPTIMISE)

        TEMPLATE_ARGS= $(TEMPLATE_DIRS:%=-pti$(TOP)/%) -pti$(TOP)/src/arch/festival  -ptr$(TOP)
	ESTOOLSTEM = $(LIBRARY_TEMPLATE_DIRS:%=-pti$(ESTOOLSDIR)/%) -ptr$(ESTOOLSDIR)

        ESTSTRINGINC = -I$(ESTSTRINGDIR)

	## special ways of doing things, blank means default

	MAKE_DEPEND = $(CXX) $(INCLUDES) $(TEMPLATES) -xM1
	BUILD_LIB = $(CXX) $(TEMPLATES) -xar -o
	INDEX_LIB = \#

	COMPILERLIBS=
else
ifeq ($(COMPILER),GCC)
	CC=gcc
	CXX =gcc -fno-implicit-templates

	CFLAGS  = 
	CXXFLAGS =
	DEBUG_CCFLAGS = -g
	DEBUG_CXXFLAGS =  -g
	WARN_CCFLAGS = -Wall
	WARN_CXXFLAGS =-Wall
	VERBOSE_CCFLAGS =
	VERBOSE_CXXFLAGS =
	OPTIMISE_CCFLAGS = -O$(OPTIMISE)
	OPTIMISE_CXXFLAGS = -O$(OPTIMISE)

        TEMPLATE_SPECIFIC = -DINSTANTIATE_TEMPLATES
	TEMPLATE_ARGS= 
	ESTOOLSTEM = 

	## special ways of doing things, blank means default

	MAKE_DEPEND = 
	BUILD_LIB = 
	INDEX_LIB = 

	COMPILERLIBS= -lstdc++
else
error:
	@echo NO COMPILER SELECTED
	@false
all: error
depend: error
endif
endif

# On Solaris (and other SYSV) use true, while others need the real thing
RANLIB = ranlib
# This is used within CSTR for RCS access, if you wont use RCS leave as is
# this requires GNU test as it supports the -nt (newer than) option
TEST = gnutest

# If you are going to have multiple architectures using the same 
# library directory you should set this, it may already be set anyway
# some environments (note uname wont distinguish between sparcs and i386
# in SunOS)
#OSTYPE=`uname`

# FESTIVAL_DIRECTORY should be set the the top level directory.
# This should be the name of the directory containing lib/ src/ doc/
# examples/ and config/, i.e. ..../festival  note there is no
# trailing slash
# NOTE: the following code doesn't guarantee to get it right (due
# to NFS and automounter magic) so editing the next line is advised.
FESTIVAL_DIRECTORY = $(shell (cd $(TOP); pwd ) )
# But setting it by hand is the best method to get it right
#FESTIVAL_DIRECTORY=/projects/festival#

# Festival run time library directory, for lisp files etc
FTLIBDIR = -DFTLIBDIR=\"$(FESTIVAL_DIRECTORY)/lib/\"

# If you want to run the binary on Solaris 2.4 at all, define the
# following to get round some string lib bugs and avoid loading libucb.a
#SOL_COMPAT = -Dsolaris_2_4_compat
# Readline-2.0 on at least some versions SGI IRIX incorrectly uses
# setmask, define the following to fix this
#READLINE_FIX = -Dsigmask_fix

# Under solaris you need the following (maybe other SYSV too ??)
# SOCKET_LIBS = -lsocket -lnsl -ldl

# If you have src/modules/diphone/di_psolaTM.cc in your distribution
# uncomment the following to get PSOLA support
#PSOLA_DEFS = -DHAVE_DI_PSOLA_TM

## Speech Tools Library
ESTOOLSDIR = $(TOP)/../speech_tools
ESTOOLSINC = -I$(ESTOOLSDIR)/include
ESTOOLSLIB = -L$(ESTOOLSDIR)/lib -lestools -leststring
ESTOOLSLIBS = $(ESTOOLSDIR)/lib/libestools.a $(ESTOOLSDIR)/lib/libeststring.a
ifeq ($(COMPILER),SUN_CC)
include $(ESTOOLSDIR)/make.include
endif

## For various optional sub-systems
EXTRA_LIBS=
## GNU readline includes and libraries
ifdef INCLUDE_READLINE
ifneq ($(INCLUDE_READLINE),0)
	RLDIR =/usr/local/readline
	RLINC = -I$(RLDIR)/include
	RLLIB = -L$(RLDIR)/lib -lreadline -ltermcap
        EXTRA_LIBS += $(RLLIB)
else
	RLINC = -DNO_READLINE
	RLLIB =
endif
else
	RLINC = -DNO_READLINE
	RLLIB =
endif

## NCD's NAS (formerly netaudio) network transparent audio system
## Only needed if your speechtools library is compiled with NAS support
ifdef INCLUDE_NAS
ifneq ($(INCLUDE_NAS),0)
	XAUTH=-L/usr/X11R6/lib -lXau
        NADIR = /usr/local
	NALIB = -L$(NADIR)/lib -laudio $(XAUTH) $(SOCKET_LIBS)
        EXTRA_LIBS += $(NALIB)
endif
endif

## SGI's 16 bit linear audio
## Only needed if your speechtools library is compiled with IRIX audio support
ifdef INCLUDE_IRIX_AUDIO
ifneq ($(INCLUDE_IRIX_AUDIO),0)
        EXTRA_LIBS += -laudio
endif
endif

## Windows (95 or NT) mplayer application
ifdef INCLUDE_MPLAYER
ifneq ($(INCLUDE_MPLAYER),0)

endif
endif
## Windows (95 or NT) direct audio
ifdef INCLUDE_WIN32AUDIO
ifneq ($(INCLUDE_WIN32AUDIO),0)
      EXTRA_LIBS += -lwinmm
endif
endif

## Support so that festival may eval TCL commands and TCL may eval
## festival commands.  This was added to support the CSLU toolkit but
## others may want it too.
ifdef INCLUDE_TCL
ifneq ($(INCLUDE_TCL),0)
        TCLINC = -I/usr/local/include
	TCLLIB = -L/usr/local/lib -ltcl7.6
        EXTRA_LIBS+= $(TCLLIB)
endif
endif

# Add other libs here as required for your system
OTHER_LIBS = $(SOCKET_LIBS)

#  Main libraries
FESTLIB = $(TOP)/src/lib/libFestival.a

FTLIBS = $(FESTLIB)

ifdef DEBUG
ifeq ($(DEBUG),fence)
	DEBUG_LIBS = -L/usr/local/lib -lefence
endif
endif

## Note LOCAL_INCLUDES is set on a per Makefile basis and should not
## be reset here.
INCLUDES = $(LOCAL_INCLUDES) -I$(TOP)/src/include $(ESTOOLSINC) 
TEMPLATES = $(LOCAL_TEMPLATES) $(TEMPLATE_ARGS) $(ESTOOLSTEM) 
LIBS = $(FTLIBS) $(ESTOOLSLIB) $(EXTRA_LIBS) $(DEBUG_LIBS) $(OTHER_LIBS) -lm $(COMPILERLIBS) 


