###########################################################################
##                                                                       ##
##                Centre for Speech Technology Research                  ##
##                     University of Edinburgh, UK                       ##
##                       Copyright (c) 1996,1997                         ##
##                        All Rights Reserved.                           ##
##                                                                       ##
##  Permission is hereby granted, free of charge, to use and distribute  ##
##  this software and its documentation without restriction, including   ##
##  without limitation the rights to use, copy, modify, merge, publish,  ##
##  distribute, sublicense, and/or sell copies of this work, and to      ##
##  permit persons to whom this work is furnished to do so, subject to   ##
##  the following conditions:                                            ##
##   1. The code must retain the above copyright notice, this list of    ##
##      conditions and the following disclaimer.                         ##
##   2. Any modifications must be clearly marked as such.                ##
##   3. Original authors' names are not deleted.                         ##
##   4. The authors' names are not used to endorse or promote products   ##
##      derived from this software without specific prior written        ##
##      permission.                                                      ##
##                                                                       ##
##  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ##
##  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ##
##  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ##
##  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ##
##  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ##
##  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ##
##  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ##
##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ##
##  THIS SOFTWARE.                                                       ##
##                                                                       ##
###########################################################################
##                                                                       ##
##   Automatically constructs init_modules.cc with each modules own      ##
##   initialization routines                                             ##
##                                                                       ##
###########################################################################
TOP=../..
DIRNAME=src/modules
CPPSRCS = 
BASE_DIRS = Lexicon base Duration Intonation Text \
            UniSyn donovan parser UniSyn_diphone
# these last four are potentially optional

LIB_BUILD_DIRS = $(BASE_DIRS)
BUILD_DIRS = $(LIB_BUILD_DIRS)
OPTIONAL = diphone clunits hts_engine java rxp UniSyn_phonology MultiSyn

ALL_DIRS = $(BASE_DIRS) $(OPTIONAL)

OBJS = init_modules.o 

LOCAL_CLEAN = init_modules.cc

LOCAL_INCLUDES = -I./Database

FILES = Makefile $(CPPSRCS) VCLocalRules

INLIB = $(TOP)/src/lib/libFestival.a

ALL = .buildlib 

include $(TOP)/config/common_make_rules

# Builds a call to the int function in each sub-directory
#
#init_modules.cc: utilities Makefile $(TOP)/config/modincludes.inc
#	@ echo "Making init_modules.cc"
#	LD_LIBRARY_PATH='$(EST)/lib:$(LD_LIBRARY_PATH):$(SYSTEM_LD_LIBRARY_PATH)' utilities/find_inits $(LIB_BUILD_DIRS) $(EXTRA_LIB_BUILD_DIRS) > init_modules.cc


init_modules.cc: Makefile $(TOP)/config/modincludes.inc
	@ echo "Making init_modules.cc"
	@ rm -f init_modules.cc
	@ echo >init_modules.cc
	@ echo "/* This file is autogenerated by src/modules/Makefile */" >>init_modules.cc
	@ echo >>init_modules.cc
	@ echo "#include \"EST_unix.h\"" >>init_modules.cc
	@ echo "#include \"stdio.h\"" >>init_modules.cc
	@ echo "#include \"festival.h\"" >>init_modules.cc
	@ echo >>init_modules.cc
	@ for i in $(LIB_BUILD_DIRS) $(EXTRA_LIB_BUILD_DIRS) ; \
	do \
	if [ ! -f "$$i/NoInit" ] ; then \
	   echo "void festival_"$$i"_init(void);" ; \
	fi \
	done >> init_modules.cc
	@ echo >>init_modules.cc
	@ echo "void festival_init_modules(void)" >>init_modules.cc
	@ echo "{" >>init_modules.cc
	@ for i in $(LIB_BUILD_DIRS) $(EXTRA_LIB_BUILD_DIRS) ; \
	do \
	if [ ! -f "$$i/NoInit" ] ; then \
	   echo "   festival_"$$i"_init();" ; \
	fi \
	done >> init_modules.cc
	@ echo "}" >>init_modules.cc
	@ echo >>init_modules.cc









