1dnl########################################################################
2dnl                                                                      ##
3dnl                 Language Technologies Institute                      ##
4dnl                    Carnegie Mellon University                        ##
5dnl                     Copyright (c) 1999-2008                          ##
6dnl                       All Rights Reserved.                           ##
7dnl                                                                      ##
8dnl Permission is hereby granted, free of charge, to use and distribute  ##
9dnl this software and its documentation without restriction, including   ##
10dnl without limitation the rights to use, copy, modify, merge, publish,  ##
11dnl distribute, sublicense, and/or sell copies of this work, and to      ##
12dnl permit persons to whom this work is furnished to do so, subject to   ##
13dnl the following conditions:                                            ##
14dnl  1. The code must retain the above copyright notice, this list of    ##
15dnl     conditions and the following disclaimer.                         ##
16dnl  2. Any modifications must be clearly marked as such.                ##
17dnl  3. Original authors' names are not deleted.                         ##
18dnl  4. The authors' names are not used to endorse or promote products   ##
19dnl     derived from this software without specific prior written        ##
20dnl     permission.                                                      ##
21dnl                                                                      ##
22dnl CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK         ##
23dnl DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ##
24dnl ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ##
25dnl SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE      ##
26dnl FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ##
27dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ##
28dnl AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ##
29dnl ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ##
30dnl THIS SOFTWARE.                                                       ##
31dnl                                                                      ##
32dnl########################################################################
33AC_INIT(include/flite.h)
34
35AC_CANONICAL_SYSTEM
36AC_PROG_CC
37AC_PROG_RANLIB
38AC_PROG_INSTALL
39AC_CHECK_TOOL(AR, ar)
40AC_C_BIGENDIAN(ENDIANDEFS=-DWORDS_BIGENDIAN=1,,)
41
42if test "x$GCC" = "xyes"; then
43	CFLAGS="$CFLAGS -Wall"
44fi
45AC_ARG_ENABLE( shared,
46               [  --disable-shared     without shared library support],
47	       [case "${enableval}" in
48                 yes) shared=true ;;
49                 no) shared=false ;;
50                 *) AC_MSG_ERROR(bad value ${enableval} for shared options) ;;
51                 esac],
52               [shared=false])
53
54case "$target_cpu" in
55     i386|i486|i586|i686)
56	TARGET_CPU=i386
57     ;;
58     *)
59        TARGET_CPU=$target_cpu
60     ;;
61esac
62TARGET_OS=$target_os
63
64M68KCC=
65M68KCLAGS=
66WINDRES=
67
68CHROMEBIN_PREFIX=
69
70if test "$target_os" = "chrome" ; then
71    case "$TARGET_CPU" in
72	i386*)
73	    CFLAGS="$CFLAGS -m32"
74	    CHROMEBIN_PREFIX=" $CHROME_NDK/toolchain/linux_x86_newlib/bin/i686-nacl"
75	    ;;
76	x86_64*)
77	    CFLAGS="$CFLAGS -m64"
78	    CHROMEBIN_PREFIX=" $CHROME_NDK/toolchain/linux_x86_newlib/bin/x86_64-nacl"
79esac
80fi
81
82case "$target_os" in
83        palmos*)
84		shared=false
85     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS"
86		# PalmOS Apps are always in M68K
87		M68KCC=/usr/m68k-palmos/bin/gcc
88		# Generic build is ARM or M68K (probably ARM though)
89                CC="/usr/$TARGET_CPU-palmos/bin/gcc"
90		if test "$target_cpu" = "arm"
91                then
92                   CC="$CC -fPIC -march=armv4t"
93                fi
94                RANLIB=/usr/$TARGET_CPU-palmos/bin/ranlib
95                AR=/usr/$TARGET_CPU-palmos/bin/ar
96		LEXDEFS="-DCST_NO_STATIC_LEX -DCST_NO_STATIC_LTS_MODEL"
97		VOXDEFS="-DCST_NO_STATIC_VOX"
98        ;;
99dnl         wince*)
100dnl                 # For the GNUWINCE environment
101dnl                 # http://win-ce.voxware.com:28575/Development%20Tools/
102dnl 		shared=false
103dnl      	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -march=armv4 -mapcs-32 -malignment-traps -DNEWLIB -DSARM -DWIN32 -DGNUWINCE"
104dnl                 CC="/usr/local/wince/bin/arm-wince-pe-gcc"
105dnl                 RANLIB=/usr/local/wince/bin/arm-wince-pe-ranlib
106dnl                 AR=/usr/local/wince/bin/arm-wince-pe-ar
107dnl         ;;
108        wince*)
109                # For the CEGCC environment (mingw32ce)
110                # http://cegcc.sourceforge.net/
111		shared=false
112                # cegcc
113     	        # CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_CE -DNEWLIB -DSARM -DWIN32 -DGNUWINCE"
114                # CC="/opt/cegcc/bin/arm-cegcc-gcc"
115                # RANLIB="/opt/cegcc/bin/arm-cegcc-ranlib"
116                # AR="/opt/cegcc/bin/arm-cegcc-ar"
117                # mingw32ce
118     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_CE -DSARM -DWIN32"
119                if test -f "/opt/mingw32ce/bin/arm-mingw32ce-gcc"
120                then
121                    MINGW32CEPREF="/opt/mingw32ce/bin/arm-mingw32ce-"
122                else
123                    MINGW32CEPREF="/opt/mingw32ce/bin/arm-wince-mingw32ce-"
124                fi
125                CC="${MINGW32CEPREF}gcc"
126                RANLIB="${MINGW32CEPREF}ranlib"
127                AR="${MINGW32CEPREF}ar"
128                SIZE="${MINGW32CEPREF}size"
129                STRIP="${MINGW32CEPREF}strip"
130                WINDRES="${MINGW32CEPREF}windres"
131                DLLTOOL="${MINGW32CEPREF}dlltool"
132                DLLWRAP="${MINGW32CEPREF}dllwrap"
133                NM="${MINGW32CEPREF}nm"
134        ;;
135        mingw*)
136                # For the Windows under mingw32 environment
137                # http://www.mingw.org
138		shared=false
139     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared"
140                MINGWPREF="i386-mingw32-"
141                CC="${MINGWPREF}gcc"
142                RANLIB="${MINGWPREF}ranlib"
143                AR="${MINGWPREF}ar"
144                WINDRES="${MINGWPREF}windres"
145                DLLTOOL="${MINGWPREF}dlltool"
146                DLLWRAP="${MINGWPREF}dllwrap"
147                NM="${MINGWPREF}nm"
148        ;;
149        android*)
150                # For Android with Android NDK
151                # http://developer.android.com/sdk/ndk/index.html
152		shared=false
153
154		# We target our compilation to android-14 (4.0) platform
155		ANDROID_NDK_PLATFORM_PATH="$ANDROID_NDK/platforms/android-14"
156
157		ANDROID_GCC_VERSION=4.6
158
159		if test "$target_cpu" = "armeabi"
160                then
161		   ANDROID_TOOLCHAIN="arm-linux-androideabi-$ANDROID_GCC_VERSION"
162		   ANDROID_NDK_SYSROOT="$ANDROID_NDK_PLATFORM_PATH/arch-arm"
163		   ANDROIDBIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-$ANDROID_GCC_VERSION/prebuilt/linux-x86/bin/arm-linux-androideabi"
164      		   CFLAGS="$CFLAGS -fpic -mthumb -O3 -DANDROID --sysroot=$ANDROID_NDK_SYSROOT"
165                fi
166
167		if test "$target_cpu" = "armeabiv7a"
168                then
169		   ANDROID_TOOLCHAIN="arm-linux-androideabi-$ANDROID_GCC_VERSION"
170		   ANDROID_NDK_SYSROOT="$ANDROID_NDK_PLATFORM_PATH/arch-arm"
171		   ANDROIDBIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-$ANDROID_GCC_VERSION/prebuilt/linux-x86/bin/arm-linux-androideabi"
172      		   CFLAGS="$CFLAGS -fpic -march=armv7-a -mfloat-abi=softfp -O3 -DANDROID --sysroot=$ANDROID_NDK_SYSROOT"
173		   LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8"
174                fi
175
176		if test "$target_cpu" = "x86"
177		then
178		   ANDROID_TOOLCHAIN="x86-$ANDROID_GCC_VERSION"
179		   ANDROID_NDK_SYSROOT="$ANDROID_NDK_PLATFORM_PATH/arch-x86"
180		   ANDROIDBIN="$ANDROID_NDK/toolchains/x86-$ANDROID_GCC_VERSION/prebuilt/linux-x86/bin/i686-linux-android"
181      		   CFLAGS="$CFLAGS -fpic -O3 -DANDROID --sysroot=$ANDROID_NDK_SYSROOT"
182		fi
183
184		if test "$target_cpu" = "mips"
185		then
186		   ANDROID_TOOLCHAIN="mipsel-linux-android-$ANDROID_GCC_VERSION"
187		   ANDROID_NDK_SYSROOT="$ANDROID_NDK_PLATFORM_PATH/arch-mips"
188		   ANDROIDBIN="$ANDROID_NDK/toolchains/mipsel-linux-android-$ANDROID_GCC_VERSION/prebuilt/linux-x86/bin/mipsel-linux-android"
189      		   CFLAGS="$CFLAGS -fpic -O3 -DANDROID --sysroot=$ANDROID_NDK_SYSROOT"
190		fi
191
192		# Common to all android variants
193                CC="${ANDROIDBIN}-gcc"
194                RANLIB="${ANDROIDBIN}-ranlib"
195                AR="${ANDROIDBIN}-ar"
196                NM="${ANDROIDBIN}-nm"
197
198        ;;
199        chrome*)
200		shared=false
201		CFLAGS="$CFLAGS -DCST_NO_SOCKETS"
202                CC="${CHROMEBIN_PREFIX}-gcc"
203                RANLIB="${CHROMEBIN_PREFIX}-ranlib"
204                AR="${CHROMEBIN_PREFIX}-ar"
205                NM="${CHROMEBIN_PREFIX}-nm"
206        ;;
207        uclinux*)
208                LDFLAGS="$LDFLAGS -Wl,-elf2flt"
209        ;;
210	darwin*)
211		CFLAGS="$CFLAGS -no-cpp-precomp"
212	;;
213esac
214
215AC_SUBST(TARGET_OS)
216AC_SUBST(TARGET_CPU)
217AC_SUBST(M68KCC)
218AC_SUBST(WINDRES)
219AC_SUBST(SIZE)
220AC_SUBST(STRIP)
221AC_SUBST(DLLTOOL)
222AC_SUBST(DLLWRAP)
223AC_SUBST(NM)
224AC_SUBST(LEXDEFS)
225AC_SUBST(VOXDEFS)
226AC_SUBST(ENDIANDEFS)
227
228case "$host_cpu" in
229     i386|i486|i586|i686)
230	HOST_CPU=i386
231     ;;
232     *)
233        HOST_CPU=$host_cpu
234     ;;
235esac
236HOST_OS=$host_os
237
238AC_SUBST(HOST_OS)
239AC_SUBST(HOST_CPU)
240
241SHFLAGS=
242OTHERLIBS=
243
244dnl For OpenPandora and other (softfloat) ARMs with neon
245if grep -q Pandora /proc/cpuinfo
246then
247   CFLAGS="$CFLAGS -DPANDORA -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
248fi
249
250withpic=false
251AC_ARG_WITH( pic, [  --with-pic           with pic ],
252        withpic=$with_pic )
253if test "x$with_pic" = "xyes"; then
254   case "$target_os" in
255	linux*)
256		CFLAGS="$CFLAGS -fPIC"
257        ;;
258	solaris*)
259		CFLAGS="$CFLAGS -fPIC"
260        ;;
261	*)
262		CFLAGS="$CFLAGS -fPIC"
263	;;
264   esac
265fi
266
267if test "$shared" = true; then
268   case "$target_os" in
269	linux*|k*bsd*-gnu|gnu*)
270		SHFLAGS="-fPIC"
271        ;;
272	solaris*)
273		SHFLAGS="-fPIC"
274		OTHERLIBS="-lsocket -ldl"
275        ;;
276	*)
277	;;
278   esac
279fi
280case "$target_os" in
281     wince*)
282        # cegcc
283        #OTHERLIBS="-lc -lgcc -lwinsock -lcoredll"
284        # mingw32ce
285        OTHERLIBS=
286     ;;
287     *)
288     ;;
289esac
290
291AC_SUBST(OTHERLIBS)
292AC_SUBST(SHFLAGS)
293
294AC_ARG_ENABLE( sockets,
295               [  --disable-sockets     without socket support],
296	       [case "${enableval}" in
297                 yes) sockets=true ;;
298                 no) sockets=false ;;
299                 *) AC_MSG_ERROR(bad value ${enableval} for sockets options) ;;
300                 esac],
301               [sockets=true])
302if test "$sockets" = false; then
303   AC_DEFINE(CST_NO_SOCKETS)
304fi
305
306dnl
307dnl Does this compiler support initialization of unions
308dnl
309AC_TRY_COMPILE([#include <stdio.h>],
310               [ struct a { union { float b; int c; } d; };
311                 const struct a e = { .d={ .b=3.14 } }; ],
312               [unioninit=yes],
313               [unioninit=no])
314if test "$unioninit" = no; then
315   AC_DEFINE(NO_UNION_INITIALIZATION)
316fi
317
318dnl
319dnl Does this platform support mmap(2)
320dnl Note we don't use AC_FUNC_MMAP because we really only care whether
321dnl read-only mappings work.
322dnl
323AC_CHECK_FUNC(mmap,MMAPTYPE=posix)
324
325dnl Force no mmap for chrome
326if test "$target_os" = "chrome"
327then
328    MMAPTYPE=none
329fi
330
331dnl AC_CHECK_FUNC doesn't seem to work for Win32 API calls...
332if test "x$MMAPTYPE" = x; then
333   case "$target_os" in
334	cygwin*|mingw*)
335		MMAPTYPE=win32
336	;;
337	android*)
338		MMAPTYPE=posix
339	;;
340 	*)
341		MMAPTYPE=none
342	;;
343   esac
344fi
345
346dnl
347dnl allow the user to override the one detected above
348dnl
349AC_ARG_WITH( mmap,
350	[  --with-mmap          with specific mmap support (none posix win32) ],
351        MMAPTYPE=$with_mmap )
352
353AC_SUBST(MMAPTYPE)
354
355dnl stdio type, palmos/wince are different
356if test "$target_os" = "palmos"
357then
358    STDIOTYPE=palmos
359else
360   if test "$target_os" = "wince"
361   then
362      STDIOTYPE=wince
363   else
364      STDIOTYPE=stdio
365   fi
366fi
367AC_SUBST(STDIOTYPE)
368
369dnl
370dnl determine audio type or use none if none supported on this platform
371dnl
372AUDIODRIVER=none
373AC_CHECK_HEADER(sys/soundcard.h,
374              [AUDIODRIVER="oss"
375               AUDIODEFS=-DCST_AUDIO_LINUX])
376AC_CHECK_HEADER(machine/soundcard.h,
377              [AUDIODRIVER="oss"
378               AUDIODEFS=-DCST_AUDIO_FREEBSD])
379AC_CHECK_HEADER(sys/audioio.h,
380              [AUDIODRIVER="sun"
381               AUDIODEFS=-DCST_AUDIO_SUNOS])
382# We're going to make alsa the default now, if supported
383AC_CHECK_HEADER(alsa/asoundlib.h,
384              [AUDIODRIVER="alsa"
385	       AUDIODEFS=-DCST_AUDIO_ALSA
386               AUDIOLIBS=-lasound])
387AC_CHECK_HEADER(mmsystem.h,
388	      [AUDIODRIVER="wince"
389	       AUDIODEFS=-DCST_AUDIO_WINCE
390	       AUDIOLIBS=-lwinmm])
391
392dnl I don't care what you ask for, for wince you get wince
393case "$target_os" in
394     wince*)
395        AUDIODRIVER="wince"
396        AUDIODEFS=-DCST_AUDIO_WINCE
397        AUDIOLIBS=
398     ;;
399     mingw*)
400        AUDIODRIVER="none"
401        AUDIODEFS=-DCST_AUDIO_NONE
402        AUDIOLIBS=
403     ;;
404     android*)
405        AUDIODRIVER="none"
406        AUDIODEFS=-DCST_AUDIO_NONE
407        AUDIOLIBS=
408     ;;
409     chrome*)
410	AUDIODRIVER="none"
411	AUDIODEFS=-DCST_AUDIO_NONE
412	AUDIOLIBS=
413     ;;
414     *)
415     ;;
416esac
417
418dnl
419dnl allow the user to override the one detected above
420dnl
421AC_ARG_WITH( audio,
422	[  --with-audio          with specific audio support (none linux freebsd etc) ],
423        AUDIODRIVER=$with_audio
424	AUDIODEFS="" )
425
426if test "x$AUDIODEFS" = x; then
427    case "$AUDIODRIVER" in
428	linux|oss)
429	    AUDIODRIVER=oss
430	    AUDIODEFS=-DCST_AUDIO_LINUX
431	    ;;
432	alsa)
433            AUDIODRIVER="alsa"
434	    AUDIODEFS=-DCST_AUDIO_ALSA
435            AUDIOLIBS=-lasound
436	    ;;
437	pa|pulseaudio)
438            AUDIODRIVER="pulseaudio"
439	    AUDIODEFS=-DCST_AUDIO_PULSEAUDIO
440            AUDIOLIBS='-lpulse-simple -lpulse'
441	    ;;
442	*bsd)
443	    AUDIODRIVER=oss
444	    AUDIODEFS=-DCST_AUDIO_FREEBSD
445	    ;;
446	qnx)
447	    AUDIODRIVER=alsa
448	    AUDIODEFS=-DCST_AUDIO_QNX
449	    ;;
450	none)
451	    AUDIODEFS=-DCST_AUDIO_NONE
452	    ;;
453    esac
454fi
455AC_SUBST(AUDIODRIVER)
456AC_SUBST(AUDIODEFS)
457AC_SUBST(AUDIOLIBS)
458
459dnl
460dnl language/lexicon/voice parameters
461dnl
462AC_ARG_WITH( lang, [  --with-lang           with language ],
463        FL_LANG=$with_lang )
464if test "x$with_lang" = "x"; then
465        FL_LANG="usenglish"
466fi
467AC_SUBST(FL_LANG)
468
469AC_ARG_WITH( vox, [  --with-vox            with vox ],
470        FL_VOX=$with_vox )
471if test "x$with_vox" = "x"; then
472        FL_VOX="cmu_us_kal"
473fi
474AC_SUBST(FL_VOX)
475
476AC_ARG_WITH( lex, [  --with-lex            with lexicon ],
477        FL_LEX=$with_lex )
478if test "x$with_lex" = "x"; then
479        FL_LEX="cmulex"
480fi
481AC_SUBST(FL_LEX)
482AC_SUBST(EXEEXT)
483
484FL_LANGVOX="default"
485AC_ARG_WITH( langvox,
486	[  --with-langvox          with subsets of lang, lex and voices ],
487        FL_LANGVOX=$with_langvox )
488AC_SUBST(FL_LANGVOX)
489
490AC_OUTPUT(config/config config/system.mak)
491