1dnl Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
2dnl Copyright (c) 1997-2000 Information-technology Promotion Agency, Japan
3dnl Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
4dnl Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology
5dnl All rights reserved
6dnl
7dnl $Id: configure.in,v 1.9 2009/02/11 07:22:45 sumomo Exp $
8dnl
9
10AC_INIT(src/search_bestfirst_main.c)
11AC_CONFIG_HEADER(include/julius/config.h)
12AC_CONFIG_AUX_DIR(../support)
13
14JULIUS_PRODUCTNAME=JuliusLib
15JULIUS_VERSION=4.1.2
16
17dnl Checks for options
18
19dnl pthread support
20AC_ARG_ENABLE(pthread,
21[  --disable-pthread       [debug] do not use pthread for speech input],
22want_pthread=$enableval
23,want_pthread=yes)
24
25dnl easy setup
26AC_ARG_ENABLE(setup,
27[  --enable-setup=...         select algorithm set
28                 standard       high accuracy, slow speed
29                 fast           balanced for both speed and accuracy (default)
30                 v2.1           backward compatible with Rev.2.1],
31easy_setup=$enableval,
32easy_setup=fast
33)
34
35dnl expand easy setup
36if test "$easy_setup" = standard; then
37dnl JULIUS related begin
38    dnl AC_DEFINE(UNIGRAM_FACTORING)
39    want_unigram_factoring=yes
40dnl JULIUS related end
41    dnl AC_DEFINE(PASS1_IWCD)
42    want_pass1_iwcd=yes
43    dnl AC_DEFINE(PASS2_STRICT_IWCD)
44    want_pass2_strict_iwcd=yes
45    dnl AC_DEFINE(GPRUNE_DEFAULT_SAFE)
46    want_gprune_default=safe
47elif test "$easy_setup" = fast; then
48dnl JULIUS related begin
49    dnl AC_DEFINE(UNIGRAM_FACTORING)
50    want_unigram_factoring=yes
51    dnl AC_DEFINE(LOWMEM2)
52    want_lowmem2=yes
53dnl JULIUS related end
54    dnl AC_DEFINE(PASS1_IWCD)
55    want_pass1_iwcd=yes
56    dnl AC_DEFINE(GPRUNE_DEFAULT_BEAM)
57    want_gprune_default=beam
58elif test "$easy_setup" = v2.1; then
59    dnl AC_DEFINE(GPRUNE_DEFAULT_SAFE)
60    want_gprune_default=safe
61fi
62
63dnl multipath version
64dnl AC_ARG_ENABLE(multipath,
65dnl [  --enable-multipath         compile as multipath version],
66dnl want_multipath=$enableval
67dnl ,want_multipath=no)
68
69dnl JULIUS related begin
70
71dnl enable 1-gram factoring
72AC_ARG_ENABLE(factor1,
73[  --enable-factor1           use 1-gram factoring on 1st pass],
74   dnl AC_DEFINE(UNIGRAM_FACTORING)
75   want_unigram_factoring=$enableval)
76AC_ARG_ENABLE(factor2,
77[  --enable-factor2           use 2-gram factoring on 1st pass],
78if test "$enableval" = yes; then
79   want_unigram_factoring=no
80else
81   want_unigram_factoring=yes
82fi)
83
84dnl no linear tree separation
85AC_ARG_ENABLE(lowmem,
86[  --enable-lowmem            all words share a single root on lexicon tree],
87if test "$enableval" = yes; then
88	AC_DEFINE(LOWMEM)
89fi)
90
91dnl linear tree separation for hi-freq words
92AC_ARG_ENABLE(lowmem2,
93[  --enable-lowmem2           separate hi-freq words from lexicon tree],
94   dnl AC_DEFINE(LOWMEM2)
95   want_lowmem2=$enableval)
96
97dnl JULIUS related end
98
99dnl use monophone tree on 1st pass
100AC_ARG_ENABLE(monotree,
101[  --enable-monotree          monophone lexicon on 1st pass (EXPERIMENTAL)],
102if test "$enableval" = yes; then
103	AC_DEFINE(MONOTREE)
104fi)
105
106dnl enable score envelope beaming on 2nd pass forward scan
107AC_ARG_ENABLE(score-beam,
108[  --disable-score-beam       enable score envelope beaming on 2nd pass scan],
109if test "$enableval" = yes; then
110	AC_DEFINE(SCAN_BEAM)
111fi
112,AC_DEFINE(SCAN_BEAM))
113
114dnl enable inter-word context dependency handling on 1st pass
115AC_ARG_ENABLE(iwcd1,
116[  --enable-iwcd1             handle inter-word triphone on 1st pass],
117   dnl AC_DEFINE(PASS1_IWCD)
118   want_pass1_iwcd=$enableval)
119
120dnl enable strict inter-word context handling on 2nd pass (slow)
121AC_ARG_ENABLE(strict-iwcd2,
122[  --enable-strict-iwcd2      strict IWCD scoring on 2nd pass],
123   dnl AC_DEFINE(PASS2_STRICT_IWCD)
124   want_pass2_strict_iwcd=$enableval)
125
126dnl use word-pair approximation on 1st pass
127AC_ARG_ENABLE(wpair,
128[  --enable-wpair             use word-pair approximation on 1st pass],
129if test "$enableval" = yes; then
130	AC_DEFINE(WPAIR)
131fi)
132
133dnl use N-best approximation
134AC_ARG_ENABLE(wpair-nlimit,
135[  --enable-wpair-nlimit      keep only N-best path with wpair (-nlimit)],
136if test "$enableval" = yes; then
137	AC_DEFINE(WPAIR)
138	AC_DEFINE(WPAIR_KEEP_NLIMIT)
139fi)
140
141dnl output word graph on 1st pass (default: trellis)
142AC_ARG_ENABLE(word-graph,
143[  --enable-word-graph        use word graph instead of trellis between passes],
144if test "$enableval" = yes; then
145	AC_DEFINE(WORD_GRAPH)
146fi)
147
148dnl disable confidence measure computation
149AC_ARG_ENABLE(cm,
150[  --disable-cm               disable confidence measure computation],
151use_cm=$enableval
152,use_cm=yes)
153dnl use confidence measure based on N-best candidate
154AC_ARG_ENABLE(cm-nbest,
155[  --enable-cm-nbest          use N-best CM instead of search CM],
156use_cm_nbest=$enableval
157,use_cm_nbest=no)
158dnl for exprtiment: confidence measure output for multiple alphas
159AC_ARG_ENABLE(cm-multiple-alpha,
160[  --enable-cm-multiple-alpha  EXPERIMENTAL: test multi alphas (need much mem)],
161use_cm_multiple_alpha=$enableval
162,use_cm_multiple_alpha=no)
163# disable lmfix
164AC_ARG_ENABLE(lmfix,
165[  --disable-lmfix	      make LM computing compatible with < 3.4],
166if test "$enableval" = yes; then
167	AC_DEFINE(LM_FIX_DOUBLE_SCORING)
168fi
169,AC_DEFINE(LM_FIX_DOUBLE_SCORING))
170
171# enable word graph output from N-best sentences
172AC_ARG_ENABLE(graphout-nbest,
173[  --enable-graphout-nbest    word graph output from N-best sentence],
174use_graphout_nbest=$enableval
175,use_graphout_nbest=no)
176
177# enable pruning by confidence score on 2nd pass
178AC_ARG_ENABLE(cmthres,
179[  --enable-cmthres           enable confidence score based pruning on 2nd pass],
180use_cmthres=$enableval
181,use_cmthres=no)
182
183dnl GMM VAD
184AC_ARG_ENABLE(gmm-vad,
185[  --enable-gmm-vad           enable GMM-based VAD (EXPERIMENTAL)],
186want_gmm_vad=$enableval
187,want_gmm_vad=no
188)
189
190dnl naist spsegment
191AC_ARG_ENABLE(decoder-vad,
192[  --enable-decoder-vad       enable a new decoder-based VAD by NAIST team],
193want_spseg_naist=$enableval
194,want_spseg_naist=no
195)
196
197dnl naist spsegment
198AC_ARG_ENABLE(power-reject,
199[  --enable-power-reject      enable post rejection by power],
200want_power_reject=$enableval
201,want_power_reject=no
202)
203
204dnl plugin support
205AC_ARG_ENABLE(plugin,
206[  --disable-plugin           disable plugin support],
207if test "$enableval" = yes; then
208	AC_DEFINE(ENABLE_PLUGIN)
209fi
210,AC_DEFINE(ENABLE_PLUGIN))
211
212dnl CM options check
213if test "$use_cm" = yes; then
214  AC_DEFINE(CONFIDENCE_MEASURE)
215fi
216if test "$use_cm_nbest" = yes; then
217  if test "$use_cm" = yes; then
218    AC_DEFINE(CM_NBEST)
219  else
220    AC_MSG_ERROR([--disable-cm and --enable-cm-nbest conflicts])
221  fi
222fi
223if test "$use_cm_multiple_alpha" = yes; then
224  if test "$use_cm" = yes; then
225    AC_DEFINE(CM_MULTIPLE_ALPHA)
226  else
227    AC_MSG_ERROR([--disable-cm and --enable-cm-multiple-alpha conflicts])
228  fi
229fi
230if test "$use_cmthres" = yes; then
231  if test "$use_cm" = yes; then
232    if test "$use_cm_nbest" = yes; then
233      AC_MSG_ERROR([--enable-cmthres cannot be used with --enable-cm-nbest])
234    elif test "$use_cm_multiple_alpha" = yes; then
235      AC_MSG_ERROR([--enable-cmthres cannot be used with --enable-cm-multiple-alpha])
236    else
237      AC_DEFINE(CM_SEARCH_LIMIT)
238    fi
239  else
240    AC_MSG_ERROR([--disable-cm and --enable-cmthres conflicts])
241  fi
242fi
243
244dnl graphout option
245if test "$use_graphout_nbest" = no; then
246    AC_DEFINE(GRAPHOUT_DYNAMIC)
247    AC_DEFINE(GRAPHOUT_SEARCH)
248fi
249
250dnl final definition based on easy setup and separate option
251if test ! -z "$want_unigram_factoring"; then
252   if test "$want_unigram_factoring" = yes; then
253      AC_DEFINE(UNIGRAM_FACTORING)
254   fi
255fi
256if test ! -z "$want_pass1_iwcd"; then
257   if test "$want_pass1_iwcd" = yes; then
258      AC_DEFINE(PASS1_IWCD)
259   fi
260fi
261if test ! -z "$want_pass2_strict_iwcd"; then
262   if test "$want_pass2_strict_iwcd" = yes; then
263      AC_DEFINE(PASS2_STRICT_IWCD)
264   fi
265fi
266if test ! -z "$want_lowmem2"; then
267   if test "$want_lowmem2" = yes; then
268      AC_DEFINE(LOWMEM2)
269   fi
270fi
271if test "$want_gprune_default" = safe; then
272   AC_DEFINE(GPRUNE_DEFAULT_SAFE)
273elif test "$want_gprune_default" = beam; then
274   AC_DEFINE(GPRUNE_DEFAULT_BEAM)
275fi
276
277dnl multipath version
278dnl if test "$want_multipath" = yes; then
279dnl	AC_DEFINE(MULTIPATH_VERSION)
280dnl	VERSION="${VERSION}-multipath"
281dnl fi
282
283if test "$want_gmm_vad" = yes; then
284  AC_DEFINE(GMM_VAD)
285  AC_DEFINE(BACKEND_VAD)
286fi
287
288if test "$want_spseg_naist" = yes; then
289  AC_DEFINE(SPSEGMENT_NAIST)
290  AC_DEFINE(BACKEND_VAD)
291fi
292
293if test "$want_power_reject" = yes; then
294  AC_DEFINE(POWER_REJECT)
295fi
296
297dnl -------------------------------------------------------------------
298
299dnl Checks for system.
300AC_CANONICAL_HOST
301
302dnl Checks for optimization flag
303AC_MSG_CHECKING([host-specific optimization flag])
304if test -z "$CFLAGS" ; then
305    OPTFLAG=../support/cflags.${host_cpu}-${host_vendor}-${host_os}
306    if test -f "$OPTFLAG" ; then
307	. $OPTFLAG
308	AC_MSG_RESULT([$OPTFLAG])
309    else
310	AC_MSG_RESULT([no])
311    fi
312else
313    AC_MSG_RESULT([skipped])
314fi
315
316dnl Checks for compiler.
317AC_PROG_CC
318AC_PROG_CPP
319
320dnl Checks for programs.
321AC_PROG_INSTALL
322AC_PATH_PROG(RM, rm)
323AC_PATH_PROG(AR, ar)
324AC_PROG_RANLIB
325
326dnl Checks for libraries.
327dnl add '-lLIBRARY' to LIBS and define 'HAVE_LIBLIBRARY'
328dnl AC_CHECK_LIB(m, log10)
329
330dnl Checks for header files.
331AC_HEADER_STDC
332dnl AC_CHECK_HEADERS(fcntl.h strings.h sys/file.h sys/ioctl.h unistd.h)
333
334dnl Checks for typedefs, structures, and compiler characteristics.
335AC_C_CONST
336dnl AC_TYPE_SIZE_T
337
338dnl Checks for library functions.
339dnl AC_PROG_GCC_TRADITIONAL
340AC_TYPE_SIGNAL
341dnl AC_CHECK_FUNCS(strdup strstr)
342dnl AC_CHECK_FUNC(gethostbyname,,AC_CHECK_LIB(nsl,gethostbyname))
343dnl AC_CHECK_FUNC(connect,,AC_CHECK_LIB(socket, connect))
344AC_CHECK_FUNC(dlopen,,AC_CHECK_LIB(dl, dlopen))
345
346dnl check for POSIX thread support
347if test "$want_pthread" = yes; then
348  case "$host_os" in
349  freebsd*)
350	# FreeBSD
351	AC_MSG_CHECKING([for linking POSIX threaded process])
352 	ac_save_CFLAGS="$CFLAGS"
353 	CFLAGS="$CFLAGS -pthread"
354 	AC_TRY_LINK([#include <pthread.h>],[pthread_equal(NULL,NULL);],
355     	    use_pthread=yes
356     	    AC_DEFINE(HAVE_PTHREAD)
357	    CPPFLAGS="$CPPFLAGS -pthread",
358   	  use_pthread=no
359	)
360	CFLAGS="$ac_save_CFLAGS"
361	;;
362  *)
363	# other with libpthread
364	AC_MSG_CHECKING([for POSIX thread library in -lpthread])
365	ac_save_LIBS_p="$LIBS"
366	LIBS="$LIBS -lpthread"
367	AC_TRY_LINK([#include <pthread.h>],[pthread_equal(NULL,NULL);],
368	    use_pthread=yes
369	    AC_DEFINE(HAVE_PTHREAD),
370	  use_pthread=no
371	  LIBS="$ac_save_LIBS_p"
372	)
373  esac
374  AC_MSG_RESULT("$use_pthread")
375else
376  use_pthread=no
377fi
378
379dnl write names
380AC_DEFINE_UNQUOTED(JULIUS_PRODUCTNAME, "$JULIUS_PRODUCTNAME")
381AC_DEFINE_UNQUOTED(JULIUS_VERSION, "$JULIUS_VERSION")
382AC_DEFINE_UNQUOTED(JULIUS_SETUP, "$easy_setup")
383AC_DEFINE_UNQUOTED(JULIUS_HOSTINFO, "$host")
384AC_SUBST(JULIUS_PRODUCTNAME)
385AC_SUBST(JULIUS_VERSION)
386AC_SUBST(easy_setup)
387
388AC_OUTPUT_COMMANDS(
389[chmod +x libjulius-config libjulius-config-dist
390])
391AC_OUTPUT(Makefile libjulius-config libjulius-config-dist src/version.c doxygen.conf.ver)
392