Merged revisions 49714-49715 via svnmerge from
[asterisk/asterisk.git] / acinclude.m4
1 # AST_GCC_ATTRIBUTE([attribute name])
2
3 AC_DEFUN([AST_GCC_ATTRIBUTE],
4 [
5 AC_MSG_CHECKING(for compiler 'attribute $1' support)
6 AC_COMPILE_IFELSE(
7         AC_LANG_PROGRAM([static int __attribute__(($1)) test(void) {}],
8                         []),
9         AC_MSG_RESULT(yes)
10         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
11         AC_MSG_RESULT(no))
12 ])
13
14 # AST_EXT_LIB_SETUP([package symbol name], [package friendly name], [package option name], [additional help text])
15
16 AC_DEFUN([AST_EXT_LIB_SETUP],
17 [
18 $1_DESCRIP="$2"
19 $1_OPTION="$3"
20 AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
21 case ${withval} in
22      n|no)
23      USE_$1=no
24      ;;
25      y|ye|yes)
26      ac_mandatory_list="${ac_mandatory_list} $1"
27      ;;
28      *)
29      $1_DIR="${withval}"
30      ac_mandatory_list="${ac_mandatory_list} $1"
31      ;;
32 esac
33 ])
34 PBX_$1=0
35 AC_SUBST([$1_LIB])
36 AC_SUBST([$1_INCLUDE])
37 AC_SUBST([PBX_$1])
38 ])
39
40 # Check whether any of the mandatory modules are not present, and
41 # print error messages in case.
42
43 AC_DEFUN([AST_CHECK_MANDATORY],
44 [
45         AC_MSG_CHECKING([for mandatory modules: ${ac_mandatory_list}])
46         err=0;
47         for i in ${ac_mandatory_list}; do
48                 eval "a=\${PBX_$i}"
49                 if test "x${a}" = "x1" ; then continue; fi
50                 if test ${err} = "0" ; then AC_MSG_RESULT(fail) ; fi
51                 AC_MSG_RESULT()
52                 eval "a=\${${i}_OPTION}"
53                 AC_MSG_NOTICE([***])
54                 AC_MSG_NOTICE([*** The $i installation appears to be missing or broken.])
55                 AC_MSG_NOTICE([*** Either correct the installation, or run configure])
56                 AC_MSG_NOTICE([*** including --without-${a}.])
57                 err=1
58         done
59         if test $err = 1 ; then exit 1; fi
60         AC_MSG_RESULT(ok)
61 ])
62
63 #-- The following two tests are only performed if PBX_$1 != 1,
64 #   so you can use multiple tests and stop at the first matching one.
65 #   On success, set PBX_$1 = 1, and also #define HAVE_$1 1
66 #   and #define HAVE_$1_VERSION ${last_argument} so you can tell which
67 #   test succeeded.
68 #   They should be called after AST_EXT_LIB_SETUP($1, ...)
69
70 # Check if a given macro is defined in a certain header.
71
72 # AST_C_DEFINE_CHECK([package symbol name], [macro name], [header file], [version])
73 AC_DEFUN([AST_C_DEFINE_CHECK],
74 [
75     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
76         AC_MSG_CHECKING([for $2 in $3])
77         saved_cppflags="${CPPFLAGS}"
78         if test "x${$1_DIR}" != "x"; then
79             $1_INCLUDE= "-I${$1_DIR}/include"
80         fi
81         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
82
83         AC_COMPILE_IFELSE(
84             [ AC_LANG_PROGRAM( [#include <$3>], [int foo = $2;]) ],
85             [   AC_MSG_RESULT(yes)
86                 PBX_$1=1
87                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
88                 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
89             ],
90             [       AC_MSG_RESULT(no) ] 
91         )
92         CPPFLAGS="${saved_cppflags}"
93     fi
94 ])
95
96
97 # Check for existence of a given package ($1), either looking up a function
98 # in a library, or, if no function is supplied, only check for the
99 # existence of the header files.
100
101 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data], [version])
102 AC_DEFUN([AST_EXT_LIB_CHECK],
103 [
104 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
105    pbxlibdir=""
106    if test "x${$1_DIR}" != "x"; then
107       if test -d ${$1_DIR}/lib; then
108          pbxlibdir="-L${$1_DIR}/lib"
109       else
110          pbxlibdir="-L${$1_DIR}"
111       fi
112    fi
113    pbxfuncname="$3"
114    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
115       AST_$1_FOUND=yes
116    else
117       AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
118    fi
119
120    if test "${AST_$1_FOUND}" = "yes"; then
121       $1_LIB="-l$2 $5"
122       $1_HEADER_FOUND="1"
123       if test "x${$1_DIR}" != "x"; then
124          $1_LIB="${pbxlibdir} ${$1_LIB}"
125          $1_INCLUDE="-I${$1_DIR}/include"
126          saved_cppflags="${CPPFLAGS}"
127          CPPFLAGS="${CPPFLAGS} -I${$1_DIR}/include"
128          if test "x$4" != "x" ; then
129             AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
130          fi
131          CPPFLAGS="${saved_cppflags}"
132       else
133          if test "x$4" != "x" ; then
134             AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
135          fi
136       fi
137       if test "x${$1_HEADER_FOUND}" = "x0" ; then
138          $1_LIB=""
139          $1_INCLUDE=""
140       else
141          if test "x${pbxfuncname}" = "x" ; then         # only checking headers -> no library
142             $1_LIB=""
143          fi
144          PBX_$1=1
145          # XXX don't know how to evaluate the description (third argument) in AC_DEFINE_UNQUOTED
146          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define this to indicate the ${$1_DESCRIP} library])
147          AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$6], [Define to indicate the ${$1_DESCRIP} library version])
148       fi
149    fi
150 fi
151 ])
152
153
154 AC_DEFUN(
155 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
156    GNU_MAKE='Not Found' ;
157    GNU_MAKE_VERSION_MAJOR=0 ;
158    GNU_MAKE_VERSION_MINOR=0 ;
159    for a in make gmake gnumake ; do
160       if test -z "$a" ; then continue ; fi ;
161       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
162          GNU_MAKE=$a ;
163          GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
164          GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
165          break;
166       fi
167    done ;
168 ) ;
169 if test  "x$GNU_MAKE" = "xNot Found"  ; then
170    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
171    exit 1
172 fi
173 AC_SUBST([GNU_MAKE])
174 ])
175
176
177 AC_DEFUN(
178 [AST_CHECK_PWLIB], [
179 PWLIB_INCDIR=
180 PWLIB_LIBDIR=
181 if test "${PWLIBDIR:-unset}" != "unset" ; then
182   AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
183 fi
184 if test "${HAS_PWLIB:-unset}" = "unset" ; then
185   if test "${OPENH323DIR:-unset}" != "unset"; then
186     AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
187   fi
188   if test "${HAS_PWLIB:-unset}" != "unset" ; then
189     PWLIBDIR="${OPENH323DIR}/../pwlib"
190   else
191     AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
192     if test "${HAS_PWLIB:-unset}" != "unset" ; then
193       PWLIBDIR="${HOME}/pwlib"
194     else
195       AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
196       if test "${HAS_PWLIB:-unset}" != "unset" ; then
197         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
198         if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
199           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
200         fi
201         PWLIB_INCDIR="/usr/local/include"
202         if test "x$LIB64" != "x"; then
203           PWLIB_LIBDIR="/usr/local/lib64"
204         else
205           PWLIB_LIBDIR="/usr/local/lib"
206         fi
207       else
208         AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
209         if test "${HAS_PWLIB:-unset}" != "unset" ; then
210           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
211           PWLIB_INCDIR="/usr/include"
212           if test "x$LIB64" != "x"; then
213                 PWLIB_LIBDIR="/usr/lib64"
214           else
215                 PWLIB_LIBDIR="/usr/lib"
216               fi
217         fi
218       fi
219     fi
220   fi
221 fi
222
223 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
224 #  echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
225 #  exit
226 #fi
227
228 if test "${HAS_PWLIB:-unset}" != "unset" ; then
229   if test "${PWLIBDIR:-unset}" = "unset" ; then
230     if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
231       PWLIBDIR=`$PTLIB_CONFIG --prefix`
232     else
233       echo "Cannot find ptlib-config - please install and try again"
234       exit
235     fi
236   fi
237
238   if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
239     PWLIBDIR="/usr/share/pwlib"
240     PWLIB_INCDIR="/usr/include"
241     if test "x$LIB64" != "x"; then
242       PWLIB_LIBDIR="/usr/lib64"
243     else
244       PWLIB_LIBDIR="/usr/lib"
245     fi
246   fi
247   if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
248     PWLIBDIR="/usr/local/share/pwlib"
249     PWLIB_INCDIR="/usr/local/include"
250     if test "x$LIB64" != "x"; then
251       PWLIB_LIBDIR="/usr/local/lib64"
252     else
253       PWLIB_LIBDIR="/usr/local/lib"
254     fi
255   fi
256
257   if test "${PWLIB_INCDIR:-unset}" = "unset"; then
258     PWLIB_INCDIR="${PWLIBDIR}/include"
259   fi
260   if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
261     PWLIB_LIBDIR="${PWLIBDIR}/lib"
262   fi
263
264   AC_SUBST([PWLIBDIR])
265   AC_SUBST([PWLIB_INCDIR])
266   AC_SUBST([PWLIB_LIBDIR])
267 fi
268 ])
269
270
271 AC_DEFUN(
272 [AST_CHECK_OPENH323_PLATFORM], [
273 PWLIB_OSTYPE=
274 case "$host_os" in
275   linux*)          PWLIB_OSTYPE=linux ;
276                 ;;
277   freebsd* )       PWLIB_OSTYPE=FreeBSD ;
278                 ;;
279   openbsd* )       PWLIB_OSTYPE=OpenBSD ;
280                                    ENDLDLIBS="-lossaudio" ;
281                 ;;
282   netbsd* )        PWLIB_OSTYPE=NetBSD ;
283                                    ENDLDLIBS="-lossaudio" ;
284                 ;;
285   solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
286                 ;;
287   darwin* )            PWLIB_OSTYPE=Darwin ;
288                 ;;
289   beos*)           PWLIB_OSTYPE=beos ;
290                    STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
291                 ;;
292   cygwin*)         PWLIB_OSTYPE=cygwin ;
293                 ;;
294   mingw*)              PWLIB_OSTYPE=mingw ;
295                            STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
296                            ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
297                 ;;
298   * )                  PWLIB_OSTYPE="$host_os" ;
299                            AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
300                 ;;
301 esac
302
303 PWLIB_MACHTYPE=
304 case "$host_cpu" in
305    x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
306                    ;;
307
308    x86_64)         PWLIB_MACHTYPE=x86_64 ;
309                    P_64BIT=1 ;
310                    LIB64=1 ;
311                    ;;
312
313    alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
314                    P_64BIT=1 ;
315                    ;;
316
317    sparc )         PWLIB_MACHTYPE=sparc ;
318                    ;;
319
320    powerpc )       PWLIB_MACHTYPE=ppc ;
321                    ;;
322
323    ppc )           PWLIB_MACHTYPE=ppc ;
324                    ;;
325
326    powerpc64 )     PWLIB_MACHTYPE=ppc64 ;
327                    P_64BIT=1 ;
328                    LIB64=1 ;
329                    ;;
330
331    ppc64 )         PWLIB_MACHTYPE=ppc64 ;
332                    P_64BIT=1 ;
333                    LIB64=1 ;
334                    ;;
335
336    ia64)           PWLIB_MACHTYPE=ia64 ;
337                    P_64BIT=1 ;
338                    ;;
339
340    s390x)          PWLIB_MACHTYPE=s390x ;
341                    P_64BIT=1 ;
342                    LIB64=1 ;
343                    ;;
344
345    s390)           PWLIB_MACHTYPE=s390 ;
346                    ;;
347
348    * )             PWLIB_MACHTYPE="$host_cpu";
349                    AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
350 esac
351
352 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
353
354 AC_SUBST([PWLIB_PLATFORM])
355 ])
356
357
358 AC_DEFUN(
359 [AST_CHECK_OPENH323], [
360 OPENH323_INCDIR=
361 OPENH323_LIBDIR=
362 if test "${OPENH323DIR:-unset}" != "unset" ; then
363   AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
364 fi
365 if test "${HAS_OPENH323:-unset}" = "unset" ; then
366   AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
367   if test "${HAS_OPENH323:-unset}" != "unset" ; then
368     OPENH323DIR="${PWLIBDIR}/../openh323"
369     AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
370   else
371     AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
372     if test "${HAS_OPENH323:-unset}" != "unset" ; then
373       OPENH323DIR="${HOME}/openh323"
374     else
375       AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
376       if test "${HAS_OPENH323:-unset}" != "unset" ; then
377         OPENH323DIR="/usr/local/share/openh323"
378         OPENH323_INCDIR="/usr/local/include/openh323"
379         if test "x$LIB64" != "x"; then
380           OPENH323_LIBDIR="/usr/local/lib64"
381         else
382           OPENH323_LIBDIR="/usr/local/lib"
383         fi
384       else
385         AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
386         if test "${HAS_OPENH323:-unset}" != "unset" ; then
387           OPENH323DIR="/usr/share/openh323"
388           OPENH323_INCDIR="/usr/include/openh323"
389           if test "x$LIB64" != "x"; then
390             OPENH323_LIBDIR="/usr/lib64"
391           else
392             OPENH323_LIBDIR="/usr/lib"
393           fi
394         fi
395       fi
396     fi
397   fi
398 fi
399
400 if test "${HAS_OPENH323:-unset}" != "unset" ; then
401   if test "${OPENH323_INCDIR:-unset}" = "unset"; then
402     OPENH323_INCDIR="${OPENH323DIR}/include"
403   fi
404   if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
405     OPENH323_LIBDIR="${OPENH323DIR}/lib"
406   fi
407
408   AC_SUBST([OPENH323DIR])
409   AC_SUBST([OPENH323_INCDIR])
410   AC_SUBST([OPENH323_LIBDIR])
411 fi
412 ])
413
414
415 AC_DEFUN(
416 [AST_CHECK_PWLIB_VERSION], [
417         if test "${HAS_$2:-unset}" != "unset"; then
418                 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
419                 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
420                 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
421                 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
422                 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
423                 let $2_REQ=$4*10000+$5*100+$6
424
425                 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
426                 if test ${$2_VER} -lt ${$2_REQ}; then
427                         AC_MSG_RESULT(no)
428                         unset HAS_$2
429                 else
430                         AC_MSG_RESULT(yes)
431                 fi
432         fi
433 ])
434
435
436 AC_DEFUN(
437 [AST_CHECK_PWLIB_BUILD], [
438         if test "${HAS_$2:-unset}" != "unset"; then
439            AC_MSG_CHECKING($1 installation validity)
440
441            saved_cppflags="${CPPFLAGS}"
442            saved_libs="${LIBS}"
443            LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
444            CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
445
446            AC_LANG_PUSH([C++])
447
448            AC_LINK_IFELSE(
449                 [AC_LANG_PROGRAM([$4],[$5])],
450                 [       AC_MSG_RESULT(yes) 
451                         ac_cv_lib_$2="yes" 
452                 ],
453                 [       AC_MSG_RESULT(no) 
454                         ac_cv_lib_$2="no" 
455                 ]
456                 )
457
458            AC_LANG_POP([C++])
459
460            LIBS="${saved_libs}"
461            CPPFLAGS="${saved_cppflags}"
462
463            if test "${ac_cv_lib_$2}" = "yes"; then
464               if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
465                  $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
466               else
467                  $2_LIB="-l${PLATFORM_$2}"
468               fi
469               if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
470                  $2_INCLUDE="-I${$2_INCDIR}"
471               fi
472                   PBX_$2=1
473                   AC_DEFINE([HAVE_$2], 1, [$3])
474            fi
475         fi
476 ])
477
478 AC_DEFUN(
479 [AST_CHECK_OPENH323_BUILD], [
480         if test "${HAS_OPENH323:-unset}" != "unset"; then
481                 AC_MSG_CHECKING(OpenH323 build option)
482                 OPENH323_SUFFIX=
483                 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
484                 libfile=
485                 if test -n "$files"; then
486                         for f in $files; do
487                                 if test -f $f -a ! -L $f; then
488                                         libfile=`basename $f`
489                                         break;
490                                 fi
491                         done
492                 fi
493                 if test "${libfile:-unset}" != "unset"; then
494                         OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
495                 fi
496                 case "${OPENH323_SUFFIX}" in
497                         n)
498                                 OPENH323_BUILD="notrace";;
499                         r)
500                                 OPENH323_BUILD="opt";;
501                         d)
502                                 OPENH323_BUILD="debug";;
503                         *)
504                                 OPENH323_BUILD="notrace";;
505                 esac
506                 AC_MSG_RESULT(${OPENH323_BUILD})
507
508                 AC_SUBST([OPENH323_SUFFIX])
509                 AC_SUBST([OPENH323_BUILD])
510         fi
511 ])
512
513
514 # AST_FUNC_FORK
515 # -------------
516 AN_FUNCTION([fork],  [AST_FUNC_FORK])
517 AN_FUNCTION([vfork], [AST_FUNC_FORK])
518 AC_DEFUN([AST_FUNC_FORK],
519 [AC_REQUIRE([AC_TYPE_PID_T])dnl
520 AC_CHECK_HEADERS(vfork.h)
521 AC_CHECK_FUNCS(fork vfork)
522 if test "x$ac_cv_func_fork" = xyes; then
523   _AST_FUNC_FORK
524 else
525   ac_cv_func_fork_works=$ac_cv_func_fork
526 fi
527 if test "x$ac_cv_func_fork_works" = xcross; then
528   case $host in
529     *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
530       # Override, as these systems have only a dummy fork() stub
531       ac_cv_func_fork_works=no
532       ;;
533     *)
534       ac_cv_func_fork_works=yes
535       ;;
536   esac
537   AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
538 fi
539 ac_cv_func_vfork_works=$ac_cv_func_vfork
540 if test "x$ac_cv_func_vfork" = xyes; then
541   _AC_FUNC_VFORK
542 fi;
543 if test "x$ac_cv_func_fork_works" = xcross; then
544   ac_cv_func_vfork_works=$ac_cv_func_vfork
545   AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
546 fi
547
548 if test "x$ac_cv_func_vfork_works" = xyes; then
549   AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
550 else
551   AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
552 fi
553 if test "x$ac_cv_func_fork_works" = xyes; then
554   AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
555 fi
556 ])# AST_FUNC_FORK
557
558
559 # _AST_FUNC_FORK
560 # -------------
561 AC_DEFUN([_AST_FUNC_FORK],
562   [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
563     [AC_RUN_IFELSE(
564       [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
565         [
566           /* By Ruediger Kuhlmann. */
567           return fork () < 0;
568         ])],
569       [ac_cv_func_fork_works=yes],
570       [ac_cv_func_fork_works=no],
571       [ac_cv_func_fork_works=cross])])]
572 )# _AST_FUNC_FORK
573
574 # AST_PROG_LD
575 # ----------
576 # find the pathname to the GNU or non-GNU linker
577 AC_DEFUN([AST_PROG_LD],
578 [AC_ARG_WITH([gnu-ld],
579     [AC_HELP_STRING([--with-gnu-ld],
580         [assume the C compiler uses GNU ld @<:@default=no@:>@])],
581     [test "$withval" = no || with_gnu_ld=yes],
582     [with_gnu_ld=no])
583 AC_REQUIRE([AST_PROG_SED])dnl
584 AC_REQUIRE([AC_PROG_CC])dnl
585 AC_REQUIRE([AC_CANONICAL_HOST])dnl
586 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
587 ac_prog=ld
588 if test "$GCC" = yes; then
589   # Check if gcc -print-prog-name=ld gives a path.
590   AC_MSG_CHECKING([for ld used by $CC])
591   case $host in
592   *-*-mingw*)
593     # gcc leaves a trailing carriage return which upsets mingw
594     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
595   *)
596     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
597   esac
598   case $ac_prog in
599     # Accept absolute paths.
600     [[\\/]]* | ?:[[\\/]]*)
601       re_direlt='/[[^/]][[^/]]*/\.\./'
602       # Canonicalize the pathname of ld
603       ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
604       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
605         ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
606       done
607       test -z "$LD" && LD="$ac_prog"
608       ;;
609   "")
610     # If it fails, then pretend we aren't using GCC.
611     ac_prog=ld
612     ;;
613   *)
614     # If it is relative, then search for the first ld in PATH.
615     with_gnu_ld=unknown
616     ;;
617   esac
618 elif test "$with_gnu_ld" = yes; then
619   AC_MSG_CHECKING([for GNU ld])
620 else
621   AC_MSG_CHECKING([for non-GNU ld])
622 fi
623 AC_CACHE_VAL(lt_cv_path_LD,
624 [if test -z "$LD"; then
625   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
626   for ac_dir in $PATH; do
627     IFS="$lt_save_ifs"
628     test -z "$ac_dir" && ac_dir=.
629     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
630       lt_cv_path_LD="$ac_dir/$ac_prog"
631       # Check to see if the program is GNU ld.  I'd rather use --version,
632       # but apparently some variants of GNU ld only accept -v.
633       # Break only if it was the GNU/non-GNU ld that we prefer.
634       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
635       *GNU* | *'with BFD'*)
636         test "$with_gnu_ld" != no && break
637         ;;
638       *)
639         test "$with_gnu_ld" != yes && break
640         ;;
641       esac
642     fi
643   done
644   IFS="$lt_save_ifs"
645 else
646   lt_cv_path_LD="$LD" # Let the user override the test with a path.
647 fi])
648 LD="$lt_cv_path_LD"
649 if test -n "$LD"; then
650   AC_MSG_RESULT($LD)
651 else
652   AC_MSG_RESULT(no)
653 fi
654 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
655 AST_PROG_LD_GNU
656 ])# AST_PROG_LD
657
658
659 # AST_PROG_LD_GNU
660 # --------------
661 AC_DEFUN([AST_PROG_LD_GNU],
662 [AC_REQUIRE([AST_PROG_EGREP])dnl
663 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
664 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
665 case `$LD -v 2>&1 </dev/null` in
666 *GNU* | *'with BFD'*)
667   lt_cv_prog_gnu_ld=yes
668   ;;
669 *)
670   lt_cv_prog_gnu_ld=no
671   ;;
672 esac])
673 with_gnu_ld=$lt_cv_prog_gnu_ld
674 ])# AST_PROG_LD_GNU
675
676 # AST_PROG_EGREP
677 # -------------
678 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
679 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
680    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
681     then ac_cv_prog_egrep='grep -E'
682     else ac_cv_prog_egrep='egrep'
683     fi])
684  EGREP=$ac_cv_prog_egrep
685  AC_SUBST([EGREP])
686 ])]) # AST_PROG_EGREP
687
688 # AST_PROG_SED
689 # -----------
690 # Check for a fully functional sed program that truncates
691 # as few characters as possible.  Prefer GNU sed if found.
692 AC_DEFUN([AST_PROG_SED],
693 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
694     [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
695      dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
696      ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
697      for ac_i in 1 2 3 4 5 6 7; do
698        ac_script="$ac_script$as_nl$ac_script"
699      done
700      echo "$ac_script" | sed 99q >conftest.sed
701      $as_unset ac_script || ac_script=
702      _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
703         [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
704                 ["$ac_path_SED" -f conftest.sed])])])
705  SED="$ac_cv_path_SED"
706  AC_SUBST([SED])dnl
707  rm -f conftest.sed
708 ])# AST_PROG_SED
709