root/rat/trunk/configure.in @ 3000

Revision 3000, 12.8 KB (checked in by ucacoxh, 15 years ago)

- Test for broken X11 headers. Not sure if we should do something gross like

cat broken headers through a sed script that fixes them in local versions.
Certainly sed script works as I've tried it. It's just disgusting.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1dnl UCL RAT configure script.
2dnl $Header$
3dnl
4dnl Process this file with GNU autoconf to generate a configure script.
5
6AC_INIT(converter.c)
7
8AC_CANONICAL_SYSTEM
9
10AC_PROG_CC
11AC_PROG_CPP
12AC_PROG_RANLIB
13
14AC_HEADER_STDC
15AC_C_CONST
16AC_TYPE_SIZE_T
17
18VERSION=`cat VERSION`
19AC_SUBST(VERSION)
20
21OSTYPE=$host_os
22AC_SUBST(OSTYPE)
23
24# The following two macros cause autoconf to complain.
25AC_C_BIGENDIAN
26AC_C_CHAR_UNSIGNED
27
28#------------------------------------------------------------------------------
29# GCC-specific warning flags:  Set these early so all tests use arguments that
30# application builds with.
31#------------------------------------------------------------------------------
32if test "$GCC" = yes
33then
34        CFLAGS="$CFLAGS -W -Wall -Wbad-function-cast -Wmissing-prototypes -Werror"
35        if test -f .devel
36        then
37                CFLAGS="$CFLAGS -Werror"
38        fi
39fi
40
41# Check for various headers                                                 
42AC_CHECK_HEADERS(stdint.h inttypes.h stropts.h sys/filio.h malloc.h bstring.h)
43AC_CHECK_HEADERS(sys/sockio.h)
44
45# Check for missing declarations
46AC_MSG_CHECKING([for kill declaration])
47AC_EGREP_CPP(kill, [#include <signal.h>],
48        AC_MSG_RESULT(present), [
49        AC_MSG_RESULT(missing)
50        AC_DEFINE(KILL_NOT_DECLARED)
51])
52AC_MSG_CHECKING([for gettimeofday declaration])
53AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
54    AC_MSG_RESULT(missing)
55    AC_DEFINE(GETTOD_NOT_DECLARED)
56])
57
58# Check for libraries                                                       
59AC_SEARCH_LIBS(socket, socket)
60AC_SEARCH_LIBS(inet_addr, nsl)
61AC_SEARCH_LIBS(dlopen, dl)
62
63AC_CHECK_FUNC(sin, MATHLIBS="", MATHLIBS="-lm")
64AC_CHECK_LIB(ieee, main, [MATHLIBS="-lieee $MATHLIBS"])
65AC_SUBST(MATHLIBS)
66
67# Check for standard size types.  The defaults are only valid on some systems
68# so we hope that <inttypes.h> exists when they're wrong.                   
69
70AC_CHECK_TYPE(int8_t,  signed char)
71AC_CHECK_TYPE(int16_t, short)
72AC_CHECK_TYPE(int32_t, long)
73AC_CHECK_TYPE(int64_t, long long)
74
75# Some systems have these in <stdint.h>, just to be difficult...
76AC_CACHE_CHECK(for uint8_t in <stdint.h>, ucl_cv_uint8_t_in_stdint_h,
77        AC_EGREP_HEADER(uint8_t,
78                        stdint.h,
79                        ucl_cv_uint8_t_in_stdint_h=yes,
80                        ucl_cv_uint8_t_in_stdint_h=no))
81if test $ucl_cv_uint8_t_in_stdint_h = "no"
82then
83         AC_CHECK_TYPE(uint8_t,  unsigned char)
84fi
85
86AC_CACHE_CHECK(for uint16_t in <stdint.h>, ucl_cv_uint16_t_in_stdint_h,
87        AC_EGREP_HEADER(uint16_t,
88                        stdint.h,
89                        ucl_cv_uint16_t_in_stdint_h=yes,
90                        ucl_cv_uint16_t_in_stdint_h=no))
91if test $ucl_cv_uint16_t_in_stdint_h = "no"
92then
93         AC_CHECK_TYPE(uint16_t,  unsigned short)
94fi
95
96AC_CACHE_CHECK(for uint32_t in <stdint.h>, ucl_cv_uint32_t_in_stdint_h,
97        AC_EGREP_HEADER(uint32_t,
98                        stdint.h,
99                        ucl_cv_uint32_t_in_stdint_h=yes,
100                        ucl_cv_uint32_t_in_stdint_h=no))
101if test $ucl_cv_uint32_t_in_stdint_h = "no"
102then
103         AC_CHECK_TYPE(uint32_t,  unsigned int)
104fi
105
106#
107# The (?which?) library does not work with unsigned characters.
108# Force the compiler to use signed chars.
109if test $ac_cv_c_char_unsigned = yes
110then
111        if test "$GCC" = yes
112        then
113                CFLAGS="$CFLAGS -fsigned-char"
114        else
115                case "$host_os" in
116                # I don't know when "-signed" was added to IRIX CC
117                # so err on the side of using it.
118                irix*)  CFLAGS="$CFLAGS -signed"
119                        ;;
120                # need e.g. --force-signed-chars=-signed
121                *)      AC_MSG_ERROR([I don't know how to force signed chars])
122                        ;;
123                esac
124        fi
125fi
126#  __CHAR_UNSIGNED__ will be defined; hope this is OK.
127
128# Check for missing functions                                               
129EXTRA_OBJ=
130AC_CHECK_FUNC(usleep,,
131        [EXTRAOBJ="$EXTRA_OBJ usleep.o"
132         AC_DEFINE(NEED_USLEEP)])
133
134AC_SUBST(EXTRA_OBJ)
135
136# Audio device selection,  derived from host type.  Could be smart and probe
137# what's there...                                                           
138
139AU_INC=
140AU_LIB=
141AU_OBJ=
142
143case "$target" in
144*solaris*)
145        SUNAUDIOHOME="/usr/demo/SOUND"
146        O1KHOME="/opt/SUNWo1kp"
147        AC_ARG_WITH(sun-audio,    [  --with-sun-audio=DIR    specify Sun audio support home], SUNAUDIOHOME=$withval)
148        AU_INC="$AU_INC -I$SUNAUDIOHOME/include"
149        AU_OBJ="$AU_OBJ auddev_sparc.o"
150        AC_DEFINE(HAVE_SPARC_AUDIO)
151        AC_ARG_WITH(osprey-audio, [  --with-osprey=DIR       specify Osprey (Sunvideo Plus PCI) support home], O1KHOME=$withval)
152        AC_CHECK_HEADER($O1KHOME/include/oti_audio_device.h,
153                [AU_INC="$AU_INC -I$O1KHOME/include"
154                 AU_OBJ="$AU_OBJ auddev_osprey.o"
155                 AC_DEFINE(HAVE_OSPREY_AUDIO)])
156        ;;
157*linux*)
158        AU_OBJ="$AU_OBJ auddev_oss.o"
159        AU_INC="/usr/include/sys"
160        AC_DEFINE(HAVE_OSS_AUDIO)
161        ;;
162*freebsd*)
163        # PC Speaker device on FreeBSD
164        AC_CHECK_HEADERS(machine/pcaudioio.h)
165        # Luigi's driver
166        AU_OBJ="$AU_OBJ auddev_luigi.o"
167        AC_DEFINE(HAVE_LUIGI_AUDIO)
168        ;;
169*netbsd*)
170        AU_OBJ="$AUDIOBJ auddev_netbsd.o"
171        AC_DEFINE(HAVE_NETBSD_AUDIO)
172        ;;
173*irix*)
174        AU_LIB="$AU_LIB -laudio"
175        AU_OBJ="$AU_OBJ auddev_sgi.o"
176        AC_DEFINE(HAVE_SGI_AUDIO)
177        ;;
178*hpux*)
179        AU_LIB="$AU_LIB -lAlib"
180        AU_OBJ="$AU_OBJ auddev_hpux_raw.o"
181        AC_DEFINE(HAVE_HP_AUDIO)
182        ;;
183esac
184
185AC_SUBST(AU_OBJ)
186AC_SUBST(AU_INC)
187AC_SUBST(AU_LIB)
188
189# X
190AC_PATH_XTRA
191AC_SUBST(X_CFLAGS)
192AC_SUBST(X_LIBS)
193AC_SUBST(X_EXTRA_LIBS)
194AC_SUBST(X_PRE_LIBS)
195
196#------------------------------------------------------------------------------
197# Check if X headers are broken.  GCC 2.95 and up reject headers that don't
198# have omit types, X11 headers have implicit int declarations on some systems
199# (e.g. Solaris).
200#------------------------------------------------------------------------------
201AC_MSG_CHECKING(whether X11 headers are broken)
202SAVED_CFLAGS=$CFLAGS
203CFLAGS="$X_CFLAGS $CFLAGS"
204AC_TRY_COMPILE([#include <X11/Xlib.h>
205#include <X11/Xutil.h>],
206        return 0,
207        AC_MSG_RESULT(no),
208        AC_MSG_RESULT(yes))
209CFLAGS=$SAVED_CFLAGS
210
211# TCL/TK
212#------------------------------------------------------------------------------
213# We could be dealing with a source installation or a full installation.
214# Expect a source installation to have headers in TCL8_HOME/generic and libs in
215# TCL8_HOME/unix.  A full installation should have headers in
216# ROOT/include/tcl8.0, or ROOT/include, and have libraries be in ROOT/lib
217#------------------------------------------------------------------------------
218PARENT=`echo $PWD | sed -e 's%/[[^/]]*$%%'`
219TCL_INC=${PARENT}/tcl-8.0
220TCL_LIB=${PARENT}/tcl-8.0
221
222AC_ARG_WITH(tcl,           
223        [  --with-tcl=DIR          specify location of Tcl installation],
224        [TCL_INC=$withval
225         TCL_LIB=$withval])
226
227# Depending on config expect tcl.h to be tcl source dir or include path
228for i in $TCL_INC/generic $TCL_INC/include/tcl8.0 $TCL_INC/include $TCL_INC
229do
230        if test -d $i ; then
231                TCL_INC=$i
232                break
233        fi
234done
235
236AC_CHECK_HEADER(${TCL_INC}/tcl.h,
237        TCL_INC=-I${TCL_INC},
238        TCL_INC=no)
239
240if test "$TCL_INC" = no
241then
242        echo "Could not find tcl.h.  One of the following halted progress:"
243        echo "   (a) Tcl is not installed."
244        echo "   (b) Tcl's location was mis-specified, or not specified (--with-tcl=DIR)."
245        echo "   (c) this script failed to see it (please inform rat-trap@cs.ucl.ac.uk)."
246        exit
247fi
248
249# Guess most probable tcl lib location
250for i in $TCL_LIB/unix $TCL_LIB/lib $TCL_LIB
251do
252        if test -d $i ; then
253                TCL_LIB=$i
254                break
255        fi
256done
257
258SAVED_LIBS=$LIBS
259LIBS=""
260FOUND_TCL_LIB=no
261AC_SEARCH_LIBS(Tcl_Init, tcl8.0 tcl80,
262        FOUND_TCL_LIB=yes,
263        ,
264        -L${TCL_LIB} ${SAVED_LIBS} -lm)
265TCL_LIB="-L${TCL_LIB} $LIBS"
266LIBS=$SAVED_LIBS
267
268if test $FOUND_TCL_LIB = no
269then
270        echo "Could not find Tcl library.  One of the following halted progess:"
271        echo "   (a) Tcl is not installed."
272        echo "   (b) Library is not built or not in expected location (--with-tcl=DIR)."
273        echo "   (c) this script failed to see it (please inform rat-trap@cs.ucl.ac.uk)."
274        exit
275fi
276
277TK_INC=${PARENT}/tk-8.0
278TK_LIB=${PARENT}/tk-8.0
279
280AC_ARG_WITH(tk,           
281        [  --with-tk=DIR          specify location of Tk installation],
282        [TK_INC=$withval
283         TK_LIB=$withval])
284
285# Depending on config expect tk.h to be tk source dir or include path
286# AC_CHECK_HEADER(S) are totally inadequate since it is necessary to
287# include tcl.h, Xlib.h, Xutil.h before tk.h.
288FOUND_TK_INC=0
289for i in $TK_INC/generic $TK_INC/include/tk8.0 $TK_INC/include $TK_INC
290do
291        AC_MSG_CHECKING(for $i/tk.h)
292        if test -r $i/tk.h ; then
293                TK_INC=-I$i
294                FOUND_TK_INC=1
295                AC_MSG_RESULT(yes)
296                break
297        fi
298        AC_MSG_RESULT(no)
299done
300
301if test $FOUND_TK_INC = 0 ; then
302        echo "Could not find tk.h.  One of the following halted progress:"
303        echo "   (a) Tk is not installed."
304        echo "   (b) Tk's location was mis-specified, or not specified (--with-tk=DIR)."
305        echo "   (c) this script failed to see it (please inform rat-trap@cs.ucl.ac.uk)."
306        exit
307fi
308
309# Guess most probable tk lib location
310for i in $TK_LIB/unix $TK_LIB/lib $TK_LIB
311do
312        if test -d $i ; then
313                TK_LIB=$i
314                break
315        fi
316done
317
318SAVED_LIBS=$LIBS
319LIBS=""
320FOUND_TK_LIB=no
321AC_SEARCH_LIBS(Tk_Init, tk8.0 tk80,
322        FOUND_TK_LIB=yes,
323        ,
324        -L${TK_LIB} ${TCL_LIB} $X_LIBS $X_PRE_LIBS  -lXext -lX11 $X_EXTRA_LIBS ${SAVED_LIBS} -lm)
325TK_LIB="-L${TK_LIB} $LIBS"
326LIBS=$SAVED_LIBS
327
328if test $FOUND_TK_LIB = no
329then
330        echo "Could not find Tk library.  One of the following halted progess:"
331        echo "   (a) Tk is not installed."
332        echo "   (b) Library is not built or not in expected location (--with-tk=DIR)."
333        echo "   (c) this script failed to see it (please inform rat-trap@cs.ucl.ac.uk)."
334        exit
335fi
336
337AC_SUBST(TCL_INC)
338AC_SUBST(TCL_LIB)
339AC_SUBST(TK_INC)
340AC_SUBST(TK_LIB)
341
342# XXX Add check for common
343
344COMMON_INC=${PARENT}/common
345COMMON_LIB=${PARENT}/common
346
347AC_ARG_WITH(common,           
348        [  --with-common=DIR       specify location of UCL's common library],
349        [ COMMON_INC=$withval
350          COMMON_LIB=$withval])
351
352FOUND_COMMON_H=no
353for h in ${COMMON_INC} ${COMMON_INC}/include
354do
355AC_CHECK_HEADER($h/mbus.h,
356        [
357                COMMON_INC="-I${h}"
358                FOUND_COMMON_H=yes
359                break
360        ])
361done
362
363if test $FOUND_COMMON_H = no
364then
365        echo "Could not find mbus.h from UCL's common library.  Maybe:"
366        echo "   (a) common library is not installed."
367        echo "   (b) common library's locations was mis/not specified (--with-common=DIR)."
368        echo "   (c) this script failed to see it (please inform rat-trap@cs.ucl.ac.uk)."
369        exit
370fi
371
372# Check if installed it on it's own...
373if test ! -d ${COMMON_LIB}
374then
375        COMMON_LIB=${COMMON_LIB}/lib
376fi
377
378AC_CHECK_LIB(common,
379        mbus_init,
380        [
381                EXTERNAL_DEP="${EXTERNAL_DEP} ${COMMON_LIB}/libcommon.a"
382                COMMON_LIB="-L${COMMON_LIB} -lcommon"
383        ],
384        [
385                echo "Could not find UCL Common library.  One of the following halted progess:"
386                echo "   (a) Common Library is not installed."
387                echo "   (b) Library is not built or not in expected location (--with-common=DIR)."
388                echo "   (c) this script failed to see it (please inform rat-trap@cs.ucl.ac.uk)."
389                exit
390        ],
391        -L${COMMON_LIB})
392
393AC_SUBST(COMMON_INC)
394AC_SUBST(COMMON_LIB)
395AC_SUBST(EXTERNAL_DEP)
396
397# Enable options
398AC_ARG_ENABLE(profile,
399        [  --enable-profile        enable profiling],
400        [if test $enableval = yes
401        then
402                if test "$GCC" = yes
403                then
404                        CFLAGS="$CFLAGS -pg"
405                else
406                        AC_ERROR([Don't know how to enable profiling for $CC])
407                fi
408        fi])
409AC_ARG_ENABLE(bounds,
410        [  --enable-bounds         enable bounds checking],
411        [if test $enableval = yes
412        then
413                if test "$GCC" = yes
414                then
415                        CFLAGS="$CFLAGS -fbounds-checking"
416                        LIBS="$LIBS -lcheck"
417                else
418                        AC_ERROR([Don't know how to enable profiling for $CC])
419                fi
420        fi])
421AC_ARG_ENABLE(debug,
422        [  --enable-debug          enable debug messages and code],
423        [if test $enableval = yes
424        then
425                AC_DEFINE(DEBUG)
426        fi])
427AC_ARG_ENABLE(debug-mem,
428        [  --enable-debug-mem      enable memory debugging code],
429        [if test $enableval = yes
430        then
431                AC_DEFINE(DEBUG_MEM)
432        fi])
433
434
435# GSM flag checks
436#-----------------------------------------------------------------------------
437# Check if Signed arithmetic shift right (SASR).  If SASR then -1 >> 1 == 1.
438# Return value from test program of zero indicates success.
439#-----------------------------------------------------------------------------
440AC_CACHE_CHECK(signed arithmetic shift right, gsm_cv_sasr,
441        AC_TRY_RUN([int main() { return (-1 >> 1) != -1;}],
442                 gsm_cv_sasr=yes,
443                 gsm_cv_sasr=no))
444if test $gsm_cv_sasr = yes ; then
445        AC_DEFINE(SASR)
446fi
447#-----------------------------------------------------------------------------
448# GSM Options, almost certainly not sensible on all platforms, performance
449# tests in a configure script ?
450#-----------------------------------------------------------------------------
451AC_DEFINE(FAST)
452AC_DEFINE(USE_FLOAT_MUL)
453
454AC_CONFIG_HEADER(config.h)
455
456AC_OUTPUT(Makefile)
457
Note: See TracBrowser for help on using the browser.