dnl Copyright (c) 1991-2002 Kyoto University
dnl Copyright (c) 2000-2002 NAIST
dnl All rights reserved
dnl
dnl $Id: configure.in,v 1.7 2002/09/11 22:02:33 ri Exp $
dnl

AC_INIT(search_bestfirst_main.c)
AC_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR(../support)

dnl Checks for options
dnl easy setup
AC_ARG_ENABLE(setup,
[  --enable-setup=...         select algorithm set
                 standard       high accuracy, slow speed
                 fast           balanced for both speed and accuracy (default)
                 v2.1           backward compatible with Rev.2.1],
easy_setup=$enableval,
easy_setup=fast
)

dnl JULIUS related begin
# -DUNIGRAM_FACTORING
AC_ARG_ENABLE(factor1,
[  --enable-factor1           use 1-gram factoring on 1st pass (def: 2-gram)],
if test $enableval = yes; then
	AC_DEFINE(UNIGRAM_FACTORING)
fi)
# low mem
AC_ARG_ENABLE(lowmem,
[  --enable-lowmem            all words share a single root on lexicon tree],
if test $enableval = yes; then
	AC_DEFINE(LOWMEM)
fi)
AC_ARG_ENABLE(lowmem2,
[  --enable-lowmem2           separate hi-freq words from lexicon tree],
if test $enableval = yes; then
	AC_DEFINE(LOWMEM2)
fi)
dnl JULIUS related end
# use monophone tree on 1st pass
AC_ARG_ENABLE(monotree,
[  --enable-monotree          monophone lexicon on 1st pass (EXPERIMENTAL)],
if test $enableval = yes; then
	AC_DEFINE(MONOTREE)
fi)
# -DSCAN_BEAM
AC_ARG_ENABLE(score-beam,
[  --disable-score-beam       enable score envelope beaming on 2nd pass scan],
if test $enableval = yes; then
	AC_DEFINE(SCAN_BEAM)
fi
,AC_DEFINE(SCAN_BEAM))
# inter-word context dependency handling
# default: pass1=no, pass2=normal(=backscan)
# pass1=approx.
AC_ARG_ENABLE(iwcd1,
[  --enable-iwcd1             handle inter-word triphone on 1st pass],
if test $enableval = yes; then
	AC_DEFINE(PASS1_IWCD)
fi)
# pass2=strict(=nextscan)
AC_ARG_ENABLE(strict-iwcd2,
[  --enable-strict-iwcd2      strict IWCD scoring on 2nd pass],
if test $enableval = yes; then
	AC_DEFINE(PASS2_STRICT_IWCD)
fi)
# -DWPAIR
AC_ARG_ENABLE(wpair,
[  --enable-wpair             use word-pair approximation on 1st pass],
if test $enableval = yes; then
	AC_DEFINE(WPAIR)
fi)
# -DWPAIR_KEEP_NLIMIT
AC_ARG_ENABLE(wpair-nlimit,
[  --enable-wpair-nlimit      keep only N-best path with wpair (-nlimit)],
if test $enableval = yes; then
	AC_DEFINE(WPAIR)
	AC_DEFINE(WPAIR_KEEP_NLIMIT)
fi)
# -DWORD_GRAPH
AC_ARG_ENABLE(word-graph,
[  --enable-word-graph        generate word graph on 1st pass],
if test $enableval = yes; then
	AC_DEFINE(WORD_GRAPH)
fi)
# sourt pause segmentation 
AC_ARG_ENABLE(sp-segment,
[  --enable-sp-segment        enable progressive decoding with short pause segmentation],
if test $enableval = yes; then
	AC_DEFINE(SP_BREAK_CURRENT_FRAME)
fi)

OUTPUT_LIST="Makefile"
dnl JULIAN related begin
dnl JULIUS related begin
# Julian
AC_ARG_ENABLE(julian,
[  --enable-julian            compile as Julian],
dnl JULIUS related end
	EXECNAME=julian
	PRODUCTNAME=Julian
	VERSION=3.3-multipath
	AC_DEFINE(USE_DFA)
	AC_DEFINE(CATEGORY_TREE)
dnl JULIUS related begin
	,
dnl JULIAN related end
	EXECNAME=julius
	PRODUCTNAME=Julius
	VERSION=3.3-multipath
dnl JULIAN related begin
	)
dnl JULIAN related end
dnl JULIUS related end

dnl EXPAND EASY SETUP 
if test $easy_setup = standard; then
dnl JULIUS related begin
	AC_DEFINE(UNIGRAM_FACTORING)
dnl JULIUS related end
	AC_DEFINE(PASS1_IWCD)
	AC_DEFINE(PASS2_STRICT_IWCD)
	AC_DEFINE(GPRUNE_DEFAULT_SAFE)
elif test $easy_setup = fast; then
dnl JULIUS related begin
	AC_DEFINE(UNIGRAM_FACTORING)
	AC_DEFINE(LOWMEM2)
dnl JULIUS related end
	AC_DEFINE(PASS1_IWCD)
	AC_DEFINE(GPRUNE_DEFAULT_BEAM)
elif test $easy_setup = v2.1; then
	AC_DEFINE(GPRUNE_DEFAULT_SAFE)
fi

dnl Checks for system.
AC_CANONICAL_HOST

dnl Checks for optimization flag
AC_MSG_CHECKING([default optimization flag])
if test -z "$CFLAGS" ; then
    OPTFLAG=../support/cflags.${host_cpu}-${host_vendor}-${host_os}
    if test -f $OPTFLAG ; then
	. $OPTFLAG
	AC_MSG_RESULT([$OPTFLAG])
    else
	AC_MSG_RESULT([no])
    fi
else
    AC_MSG_RESULT([skipped])
fi

dnl Checks for compiler.
AC_PROG_CC
AC_PROG_CPP

dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_AWK
AC_PATH_PROG(RM, rm)

dnl Checks for libraries.
dnl add '-lLIBRARY' to LIBS and define 'HAVE_LIBLIBRARY'
dnl AC_CHECK_LIB(m, log10)
if test -n "$enable_trevis" ; then
    if test $enable_trevis = yes ; then
	AC_PATH_XTRA
	if test -z "$no_x" ; then
dnl		AC_CHECK_LIB(X11,XOpenDisplay)
		XLIB="-lX11"
		AC_SUBST(XLIB)
	fi
    fi
fi

dnl Checks for header files.
AC_HEADER_STDC
dnl AC_CHECK_HEADERS(fcntl.h strings.h sys/file.h sys/ioctl.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
dnl AC_TYPE_SIZE_T

dnl Checks for library functions.
dnl AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
dnl AC_CHECK_FUNCS(strdup strstr)
dnl AC_CHECK_FUNC(gethostbyname,,AC_CHECK_LIB(nsl,gethostbyname))
dnl AC_CHECK_FUNC(connect,,AC_CHECK_LIB(socket, connect))

dnl write names
AC_DEFINE_UNQUOTED(EXECNAME, "$EXECNAME")
AC_DEFINE_UNQUOTED(PRODUCTNAME, "$PRODUCTNAME")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_DEFINE_UNQUOTED(SETUP, "$easy_setup")
AC_SUBST(EXECNAME)

AC_OUTPUT($OUTPUT_LIST)
