1dnl Welcome to the Sphinx-3 automated build system.
2dnl try not to hurt yourself ;)
3
4AC_INIT(configure.in)
5AM_INIT_AUTOMAKE(sphinx3,0.8)
6
7CFLAGS=${CFLAGS:--g -O2 -Wall}
8
9AC_CANONICAL_HOST
10
11dnl
12dnl Set proper compiler flags and such for some platforms
13dnl
14case $host in
15     *apple*)
16        LIBS="$LIBS -framework CoreAudio -framework AudioToolbox"
17        ;;
18     *)
19     ;;
20esac
21
22AC_ISC_POSIX
23AC_PROG_CC
24AM_PROG_CC_STDC
25AC_C_BIGENDIAN
26AC_HEADER_STDC
27
28AC_C_CONST
29AC_TYPE_SIZE_T
30AC_CHECK_FUNCS(memmove bcopy)
31
32AC_TYPE_SIGNAL
33
34
35dnl
36dnl Check whether visibility is supported
37dnl
38AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
39	tmp_CFLAGS=$CFLAGS
40	CFLAGS="$CFLAGS -fvisibility=hidden"
41
42	AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))],
43		[cc_cv_attribute_visibility],
44		[AC_COMPILE_IFELSE([
45			void __attribute__((visibility("default"))) visibility_function() { }
46			],
47			[cc_cv_attribute_visibility=yes],
48			[cc_cv_attribute_visibility=no])
49		])
50
51	CFLAGS=$tmp_CFLAGS
52
53	if test "x$cc_cv_attribute_visibility" = "xyes"; then
54		AC_DEFINE([HAVE_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.])
55		CFLAGS="$CFLAGS -fvisibility=hidden"
56		$1
57	else
58		true
59		$2
60	fi
61])
62
63CC_ATTRIBUTE_VISIBILITY
64
65epdata=`ls -1 $srcdir/model/ep | egrep -v '(Makefile|CVS)'`
66epdata=`echo $epdata`
67
68hmmdata=`ls -1 $srcdir/model/hmm/hub4_cd_continuous_8gau_1s_c_d_dd | egrep -v '(Makefile|CVS)'`
69hmmdata=`echo $hmmdata`
70
71tidigitsdata=`(cd $srcdir/model/hmm/tidigits && find . -type f -print | egrep -v '(Makefile|CVS|\.svn)')`
72tidigitsdata=`echo $tidigitsdata`
73
74lmdata=`ls -1 $srcdir/model/lm/an4 | egrep -v '(Makefile|CVS)' | sed 's/\.in//g'`
75lmdata=`echo $lmdata`
76
77docdata=`ls -1 $srcdir/doc | egrep -v '(Makefile|CVS)'`
78docdata=`echo $docdata`
79
80dnl
81dnl Get SphinxBase source from command line if given
82dnl
83AC_ARG_WITH(sphinxbase,
84	AS_HELP_STRING([--with-sphinxbase=DIRECTORY],
85			[look for SphinxBase source files in DIRECTORY]),
86			sphinxbase=$withval)
87
88dnl
89dnl Get SphinxBase build directory from command line if given
90dnl
91AC_ARG_WITH(sphinxbase-build,
92	AS_HELP_STRING([--with-sphinxbase-build=DIRECTORY],
93			[look for SphinxBase object files in DIRECTORY]),
94	sphinxbasebuild=$withval)
95
96dnl
97dnl Check for installed SphinxBase
98dnl FIXME: How do we find the installed headers robustly?
99dnl
100AC_CHECK_HEADER(sphinxbase/sphinx_config.h,
101CPPFLAGS="-I/usr/include/sphinxbase -I/usr/local/include/sphinxbase",[
102if test x$sphinxbase = x; then
103   # Look for sphinxbase in the parent directory
104   for sb in ../sphinxbase*; do
105       AC_MSG_CHECKING([for sphinxbase in $sb])
106       if test -f "$sb/include/prim_type.h"; then
107          sphinxbase="`pwd`/$sb"
108	  AC_MSG_RESULT(yes)
109       else
110	  AC_MSG_RESULT(no)
111       fi
112   done
113fi
114])
115
116
117dnl
118dnl Now verify SphinxBase if defined
119dnl Sadly, this doesn't work when cross-compiling (for some dumb reason...)
120dnl
121: ${sphinxbasebuild=$sphinxbase}
122if test x$sphinxbase != x && test x$cross_compiling = xyes; then
123   CPPFLAGS="-I$sphinxbase/include -I$sphinxbasebuild/include $CPPFLAGS"
124   LDFLAGS="$LDFLAGS -L$sphinxbasebuild/src/libsphinxfe -L$sphinxbasebuild/src/libsphinxad \
125		     -L$sphinxbasebuild/src/libsphinxbase"
126fi
127if test x$sphinxbase != x && test x$cross_compiling != xyes; then
128   AC_CHECK_FILE($sphinxbase/include/prim_type.h,CPPFLAGS="-I$sphinxbase/include $CPPFLAGS",
129   AC_ERROR(
130[SphinxBase headers not found in $sphinxbase.  Please use the
131--with-sphinxbase option to `configure' to specify the location of
132SphinxBase.  Run $0 --help for more information.]))
133fi
134if test x$sphinxbasebuild != x && test x$cross_compiling != xyes; then
135   AC_CHECK_FILE($sphinxbasebuild/src/libsphinxbase/libsphinxbase.la,
136[CPPFLAGS="-I$sphinxbasebuild/include $CPPFLAGS"
137LDFLAGS="$LDFLAGS -L$sphinxbasebuild/src/libsphinxfe -L$sphinxbasebuild/src/libsphinxad \
138		  -L$sphinxbasebuild/src/libsphinxbase"],
139		   AC_ERROR(
140[SphinxBase libraries were not found in $sphinxbasebuild.
141Use the --with-sphinxbase-build option to `configure' to specify
142the build directory for SphinxBase.  Run $0 --help for more information.]))
143fi
144
145AC_PATH_PROG(PERL,perl)
146AC_PATH_PROG(CSH,csh)
147AC_SUBST(sphinxbase)
148AC_SUBST(docdata)
149AC_SUBST(epdata)
150AC_SUBST(hmmdata)
151AC_SUBST(lmdata)
152AC_SUBST(tidigitsdata)
153AC_SUBST(ad_files)
154AC_SUBST(ad_libs)
155AC_SUBST(ad_backend)
156AC_SUBST(PERL)
157AC_SUBST(CSH)
158
159AM_PROG_LIBTOOL
160
161AC_OUTPUT([
162sphinx3.pc
163Makefile
164src/Makefile
165src/libs3decoder/Makefile
166src/libs3decoder/libAPI/Makefile
167src/libs3decoder/libam/Makefile
168src/libs3decoder/libconfidence/Makefile
169src/libs3decoder/libcommon/Makefile
170src/libs3decoder/libdict/Makefile
171src/libs3decoder/libep/Makefile
172src/libs3decoder/liblm/Makefile
173src/libs3decoder/libsearch/Makefile
174src/libs3decoder/libcfg/Makefile
175src/programs/Makefile
176src/tests/Makefile
177src/tests/performance/Makefile
178src/tests/performance/an4/Makefile
179src/tests/performance/hub4/Makefile
180src/tests/performance/rm1/Makefile
181src/tests/performance/wsj20k/Makefile
182src/tests/performance/wsj5k/Makefile
183src/tests/performance/tidigits/Makefile
184src/tests/performance/ti46/Makefile
185src/tests/performance/Communicator/Makefile
186src/tests/performance/ICSI/Makefile
187src/tests/performance/spoke3/Makefile
188src/tests/regression/Makefile
189src/tests/regression/checkStyle.sh
190src/tests/regression/testfuncs.sh
191src/tests/unit_tests/Makefile
192src/tests/unit_tests/test_logs3/Makefile
193scripts/Makefile
194scripts/sphinx3-simple
195model/Makefile
196model/ep/Makefile
197model/hmm/Makefile
198model/hmm/hub4_cd_continuous_8gau_1s_c_d_dd/Makefile
199model/hmm/tidigits/Makefile
200model/hmm/RM1_cd_semi/Makefile
201model/lm/Makefile
202model/lm/an4/Makefile
203model/lm/an4/args.an4
204model/lm/an4/args.an4.test
205model/lm/an4/args.an4.test.cls
206model/lm/an4/args.an4.test.mllr
207model/lm/an4/args.an4.test.fsg
208model/lm/an4/an4.ug.cls.lmctl
209include/Makefile
210doc/Makefile])
211
212chmod +x scripts/sphinx3-simple
213chmod +x src/tests/regression/*.sh
214