Merged revisions 140817 via svnmerge from
[asterisk-bristuff.git] / acinclude.m4
blob59566d075a8c3e0e2ef2418f1814584381e234d4
1 # Various support functions for configure.ac in asterisk
4 # Helper function to check for gcc attributes.
5 # AST_GCC_ATTRIBUTE([attribute name])
7 AC_DEFUN([AST_GCC_ATTRIBUTE],
9 AC_MSG_CHECKING(for compiler 'attribute $1' support)
10 saved_CFLAGS="$CFLAGS"
11 CFLAGS="$CFLAGS -Werror"
12 AC_COMPILE_IFELSE(
13         AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
14                         []),
15         AC_MSG_RESULT(yes)
16         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
17         AC_MSG_RESULT(no))
19 CFLAGS="$saved_CFLAGS"
22 # Helper function to setup variables for a package.
23 # $1 -> the package name. Used in configure.ac and also as a prefix
24 #       for the variables ($1_DIR, $1_INCLUDE, $1_LIB) in makeopts
25 # $3 -> option name, used in --with-$3 or --without-$3 when calling configure.
26 # $2 and $4 are just text describing the package (short and long form)
28 # AST_EXT_LIB_SETUP([package], [short description], [configure option name], [long description])
30 AC_DEFUN([AST_EXT_LIB_SETUP],
32     $1_DESCRIP="$2"
33     $1_OPTION="$3"
34     AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),
35     [
36         case ${withval} in
37         n|no)
38         USE_$1=no
39         ;;
40         y|ye|yes)
41         ac_mandatory_list="${ac_mandatory_list} $1"
42         ;;
43         *)
44         $1_DIR="${withval}"
45         ac_mandatory_list="${ac_mandatory_list} $1"
46         ;;
47         esac
48     ])
49     PBX_$1=0
50     AC_SUBST([$1_LIB])
51     AC_SUBST([$1_INCLUDE])
52     AC_SUBST([$1_DIR])
53     AC_SUBST([PBX_$1])
56 # Check whether any of the mandatory modules are not present, and
57 # print error messages in case. The mandatory list is built using
58 # --with-* arguments when invoking configure.
60 AC_DEFUN([AST_CHECK_MANDATORY],
62         AC_MSG_CHECKING([for mandatory modules: ${ac_mandatory_list}])
63         err=0;
64         for i in ${ac_mandatory_list}; do
65                 eval "a=\${PBX_$i}"
66                 if test "x${a}" = "x1" ; then continue; fi
67                 if test ${err} = "0" ; then AC_MSG_RESULT(fail) ; fi
68                 AC_MSG_RESULT()
69                 eval "a=\${${i}_OPTION}"
70                 AC_MSG_NOTICE([***])
71                 AC_MSG_NOTICE([*** The $i installation appears to be missing or broken.])
72                 AC_MSG_NOTICE([*** Either correct the installation, or run configure])
73                 AC_MSG_NOTICE([*** including --without-${a}.])
74                 err=1
75         done
76         if test $err = 1 ; then exit 1; fi
77         AC_MSG_RESULT(ok)
80 # The next three functions check for the availability of a given package.
81 # AST_C_DEFINE_CHECK looks for the presence of a #define in a header file,
82 # AST_C_COMPILE_CHECK can be used for testing for various items in header files,
83 # AST_EXT_LIB_CHECK looks for a symbol in a given library, or at least
84 #       for the presence of a header file.
85 # AST_EXT_TOOL_CHECK looks for a symbol in using $1-config to determine CFLAGS and LIBS
87 # They are only run if PBX_$1 != 1 (where $1 is the package),
88 # so you can call them multiple times and stop at the first matching one.
89 # On success, they both set PBX_$1 = 1, set $1_INCLUDE and $1_LIB as applicable,
90 # and also #define HAVE_$1 1 and #define HAVE_$1_VERSION ${last_argument}
91 # in autoconfig.h so you can tell which test succeeded.
92 # They should be called after AST_EXT_LIB_SETUP($1, ...)
94 # Check if a given macro is defined in a certain header.
96 # AST_C_DEFINE_CHECK([package], [macro name], [header file], [version])
97 AC_DEFUN([AST_C_DEFINE_CHECK],
99     if test "x${PBX_$1}" != "x1"; then
100         AC_MSG_CHECKING([for $2 in $3])
101         saved_cppflags="${CPPFLAGS}"
102         if test "x${$1_DIR}" != "x"; then
103             $1_INCLUDE="-I${$1_DIR}/include"
104         fi
105         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
107         AC_COMPILE_IFELSE(
108             [ AC_LANG_PROGRAM( [#include <$3>],
109                                [#if defined($2)
110                                 int foo = 0;
111                                 #else
112                                 int foo = bar;
113                                 #endif
114                                 0
115                                ])],
116             [   AC_MSG_RESULT(yes)
117                 PBX_$1=1
118                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
119                 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
120             ],
121             [   AC_MSG_RESULT(no) ] 
122         )
123         CPPFLAGS="${saved_cppflags}"
124     fi
125     AC_SUBST(PBX_$1)
129 # Check if a given expression will compile using a certain header.
131 # AST_C_COMPILE_CHECK([package], [expression], [header file], [version], [description])
132 AC_DEFUN([AST_C_COMPILE_CHECK],
134     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
135         if test "x$5" != "x"; then
136             AC_MSG_CHECKING([for $5])
137         else
138             AC_MSG_CHECKING([if "$2" compiles using $3])
139         fi
140         saved_cppflags="${CPPFLAGS}"
141         if test "x${$1_DIR}" != "x"; then
142             $1_INCLUDE="-I${$1_DIR}/include"
143         fi
144         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
146         AC_COMPILE_IFELSE(
147             [ AC_LANG_PROGRAM( [#include <$3>],
148                                [ $2; ]
149                                )],
150             [   AC_MSG_RESULT(yes)
151                 PBX_$1=1
152                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
153                 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
154             ],
155             [       AC_MSG_RESULT(no) ] 
156         )
157         CPPFLAGS="${saved_cppflags}"
158     fi
162 # Check for existence of a given package ($1), either looking up a function
163 # in a library, or, if no function is supplied, only check for the
164 # existence of the header files.
166 # AST_EXT_LIB_CHECK([package], [library], [function], [header],
167 #        [extra libs], [extra cflags], [version])
168 AC_DEFUN([AST_EXT_LIB_CHECK],
170 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
171    pbxlibdir=""
172    # if --with-$1=DIR has been specified, use it.
173    if test "x${$1_DIR}" != "x"; then
174       if test -d ${$1_DIR}/lib; then
175          pbxlibdir="-L${$1_DIR}/lib"
176       else
177          pbxlibdir="-L${$1_DIR}"
178       fi
179    fi
180    pbxfuncname="$3"
181    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
182       AST_$1_FOUND=yes
183    else
184       AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
185    fi
187    # now check for the header.
188    if test "${AST_$1_FOUND}" = "yes"; then
189       $1_LIB="${pbxlibdir} -l$2 $5"
190       # if --with-$1=DIR has been specified, use it.
191       if test "x${$1_DIR}" != "x"; then
192          $1_INCLUDE="-I${$1_DIR}/include"
193       fi
194       $1_INCLUDE="${$1_INCLUDE} $6"
195       if test "x$4" = "x" ; then        # no header, assume found
196          $1_HEADER_FOUND="1"
197       else                              # check for the header
198          saved_cppflags="${CPPFLAGS}"
199          CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
200          AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
201          CPPFLAGS="${saved_cppflags}"
202       fi
203       if test "x${$1_HEADER_FOUND}" = "x0" ; then
204          $1_LIB=""
205          $1_INCLUDE=""
206       else
207          if test "x${pbxfuncname}" = "x" ; then         # only checking headers -> no library
208             $1_LIB=""
209          fi
210          PBX_$1=1
211          # XXX don't know how to evaluate the description (third argument) in AC_DEFINE_UNQUOTED
212          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define this to indicate the ${$1_DESCRIP} library])
213          AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$7], [Define to indicate the ${$1_DESCRIP} library version])
214       fi
215    fi
220 # Check for a package using $2-config. Similar to AST_EXT_LIB_CHECK,
221 # but use $2-config to determine cflags and libraries to use.
222 # $3 and $4 can be used to replace --cflags and --libs in the request
224 # AST_EXT_TOOL_CHECK([package], [tool name], [--cflags], [--libs], [includes], [expression])
225 AC_DEFUN([AST_EXT_TOOL_CHECK],
227     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
228         PBX_$1=0
229         AC_CHECK_TOOL(CONFIG_$1, $2-config, No)
230         if test ! "x${CONFIG_$1}" = xNo; then
231             if test x"$3" = x ; then A=--cflags ; else A="$3" ; fi
232             $1_INCLUDE=$(${CONFIG_$1} $A)
233             if test x"$4" = x ; then A=--libs ; else A="$4" ; fi
234             $1_LIB=$(${CONFIG_$1} $A)
235             if test x"$5" != x ; then
236                 saved_cppflags="${CPPFLAGS}"
237                 if test "x${$1_DIR}" != "x"; then
238                     $1_INCLUDE="-I${$1_DIR}/include"
239                 fi
240                 CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
242                 saved_ldflags="${LDFLAGS}"
243                 LDFLAGS="${$1_LIB}"
245                 AC_LINK_IFELSE(
246                     [ AC_LANG_PROGRAM( [ $5 ],
247                                        [ $6; ]
248                                        )],
249                     [   PBX_$1=1
250                         AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
251                     ],
252                     []
253                 )
254                 CPPFLAGS="${saved_cppflags}"
255                 LDFLAGS="${saved_ldflags}"
256             else
257                 PBX_$1=1
258                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 libraries.])
259             fi
260         fi
261     fi
264 AC_DEFUN(
265 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
266    GNU_MAKE='Not Found' ;
267    GNU_MAKE_VERSION_MAJOR=0 ;
268    GNU_MAKE_VERSION_MINOR=0 ;
269    for a in make gmake gnumake ; do
270       if test -z "$a" ; then continue ; fi ;
271       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
272          GNU_MAKE=$a ;
273          GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
274          GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
275          break;
276       fi
277    done ;
278 ) ;
279 if test  "x$GNU_MAKE" = "xNot Found"  ; then
280    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
281    exit 1
283 AC_SUBST([GNU_MAKE])
287 AC_DEFUN(
288 [AST_CHECK_PWLIB], [
289 PWLIB_INCDIR=
290 PWLIB_LIBDIR=
291 AC_LANG_PUSH([C++])
292 if test "${PWLIBDIR:-unset}" != "unset" ; then
293   AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
295 if test "${HAS_PWLIB:-unset}" = "unset" ; then
296   if test "${OPENH323DIR:-unset}" != "unset"; then
297     AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
298   fi
299   if test "${HAS_PWLIB:-unset}" != "unset" ; then
300     PWLIBDIR="${OPENH323DIR}/../pwlib"
301   else
302     AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
303     if test "${HAS_PWLIB:-unset}" != "unset" ; then
304       PWLIBDIR="${HOME}/pwlib"
305     else
306       AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
307       if test "${HAS_PWLIB:-unset}" != "unset" ; then
308         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
309         if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
310           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
311         fi
312         PWLIB_INCDIR="/usr/local/include"
313         PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
314         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
315           if test "x$LIB64" != "x"; then
316             PWLIB_LIBDIR="/usr/local/lib64"
317           else
318             PWLIB_LIBDIR="/usr/local/lib"
319           fi
320         fi
321         PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
322         PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
323       else
324         AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
325         if test "${HAS_PWLIB:-unset}" != "unset" ; then
326           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
327           PWLIB_INCDIR="/usr/include"
328           PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
329           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
330             if test "x$LIB64" != "x"; then
331               PWLIB_LIBDIR="/usr/lib64"
332             else
333               PWLIB_LIBDIR="/usr/lib"
334             fi
335           fi
336           PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
337           PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
338         fi
339       fi
340     fi
341   fi
344 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
345 #  echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
346 #  exit
349 if test "${HAS_PWLIB:-unset}" != "unset" ; then
350   if test "${PWLIBDIR:-unset}" = "unset" ; then
351     if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
352       PWLIBDIR=`$PTLIB_CONFIG --prefix`
353     else
354       echo "Cannot find ptlib-config - please install and try again"
355       exit
356     fi
357   fi
359   if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
360     PWLIBDIR="/usr/share/pwlib"
361     PWLIB_INCDIR="/usr/include"
362     if test "x$LIB64" != "x"; then
363       PWLIB_LIBDIR="/usr/lib64"
364     else
365       PWLIB_LIBDIR="/usr/lib"
366     fi
367   fi
368   if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
369     PWLIBDIR="/usr/local/share/pwlib"
370     PWLIB_INCDIR="/usr/local/include"
371     if test "x$LIB64" != "x"; then
372       PWLIB_LIBDIR="/usr/local/lib64"
373     else
374       PWLIB_LIBDIR="/usr/local/lib"
375     fi
376   fi
378   if test "${PWLIB_INCDIR:-unset}" = "unset"; then
379     PWLIB_INCDIR="${PWLIBDIR}/include"
380   fi
381   if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
382     PWLIB_LIBDIR="${PWLIBDIR}/lib"
383   fi
385   AC_SUBST([PWLIBDIR])
386   AC_SUBST([PWLIB_INCDIR])
387   AC_SUBST([PWLIB_LIBDIR])
389   AC_LANG_POP([C++])
393 AC_DEFUN(
394 [AST_CHECK_OPENH323_PLATFORM], [
395 PWLIB_OSTYPE=
396 case "$host_os" in
397   linux*)          PWLIB_OSTYPE=linux ;
398                 ;;
399   freebsd* )       PWLIB_OSTYPE=FreeBSD ;
400                 ;;
401   openbsd* )       PWLIB_OSTYPE=OpenBSD ;
402                                    ENDLDLIBS="-lossaudio" ;
403                 ;;
404   netbsd* )        PWLIB_OSTYPE=NetBSD ;
405                                    ENDLDLIBS="-lossaudio" ;
406                 ;;
407   solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
408                 ;;
409   darwin* )            PWLIB_OSTYPE=Darwin ;
410                 ;;
411   beos*)           PWLIB_OSTYPE=beos ;
412                    STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
413                 ;;
414   cygwin*)         PWLIB_OSTYPE=cygwin ;
415                 ;;
416   mingw*)              PWLIB_OSTYPE=mingw ;
417                            STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
418                            ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
419                 ;;
420   * )                  PWLIB_OSTYPE="$host_os" ;
421                            AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
422                 ;;
423 esac
425 PWLIB_MACHTYPE=
426 case "$host_cpu" in
427    x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
428                    ;;
430    x86_64)         PWLIB_MACHTYPE=x86_64 ;
431                    P_64BIT=1 ;
432                    LIB64=1 ;
433                    ;;
435    alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
436                    P_64BIT=1 ;
437                    ;;
439    sparc )         PWLIB_MACHTYPE=sparc ;
440                    ;;
442    powerpc )       PWLIB_MACHTYPE=ppc ;
443                    ;;
445    ppc )           PWLIB_MACHTYPE=ppc ;
446                    ;;
448    powerpc64 )     PWLIB_MACHTYPE=ppc64 ;
449                    P_64BIT=1 ;
450                    LIB64=1 ;
451                    ;;
453    ppc64 )         PWLIB_MACHTYPE=ppc64 ;
454                    P_64BIT=1 ;
455                    LIB64=1 ;
456                    ;;
458    ia64)           PWLIB_MACHTYPE=ia64 ;
459                    P_64BIT=1 ;
460                    ;;
462    s390x)          PWLIB_MACHTYPE=s390x ;
463                    P_64BIT=1 ;
464                    LIB64=1 ;
465                    ;;
467    s390)           PWLIB_MACHTYPE=s390 ;
468                    ;;
470    * )             PWLIB_MACHTYPE="$host_cpu";
471                    AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
472 esac
474 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
476 AC_SUBST([PWLIB_PLATFORM])
480 AC_DEFUN(
481 [AST_CHECK_OPENH323], [
482 OPENH323_INCDIR=
483 OPENH323_LIBDIR=
484 AC_LANG_PUSH([C++])
485 if test "${OPENH323DIR:-unset}" != "unset" ; then
486   AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
488 if test "${HAS_OPENH323:-unset}" = "unset" ; then
489   AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
490   if test "${HAS_OPENH323:-unset}" != "unset" ; then
491     OPENH323DIR="${PWLIBDIR}/../openh323"
492     saved_cppflags="${CPPFLAGS}"
493     CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
494     AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
495     CPPFLAGS="${saved_cppflags}"
496   else
497     saved_cppflags="${CPPFLAGS}"
498     CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
499     AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
500     CPPFLAGS="${saved_cppflags}"
501     if test "${HAS_OPENH323:-unset}" != "unset" ; then
502       OPENH323DIR="${HOME}/openh323"
503     else
504       saved_cppflags="${CPPFLAGS}"
505       CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
506       AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
507       CPPFLAGS="${saved_cppflags}"
508       if test "${HAS_OPENH323:-unset}" != "unset" ; then
509         OPENH323DIR="/usr/local/share/openh323"
510         OPENH323_INCDIR="/usr/local/include/openh323"
511         if test "x$LIB64" != "x"; then
512           OPENH323_LIBDIR="/usr/local/lib64"
513         else
514           OPENH323_LIBDIR="/usr/local/lib"
515         fi
516       else
517         saved_cppflags="${CPPFLAGS}"
518         CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
519         AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
520         CPPFLAGS="${saved_cppflags}"
521         if test "${HAS_OPENH323:-unset}" != "unset" ; then
522           OPENH323DIR="/usr/share/openh323"
523           OPENH323_INCDIR="/usr/include/openh323"
524           if test "x$LIB64" != "x"; then
525             OPENH323_LIBDIR="/usr/lib64"
526           else
527             OPENH323_LIBDIR="/usr/lib"
528           fi
529         fi
530       fi
531     fi
532   fi
535 if test "${HAS_OPENH323:-unset}" != "unset" ; then
536   if test "${OPENH323_INCDIR:-unset}" = "unset"; then
537     OPENH323_INCDIR="${OPENH323DIR}/include"
538   fi
539   if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
540     OPENH323_LIBDIR="${OPENH323DIR}/lib"
541   fi
543   OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
544   OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
545   OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
547   AC_SUBST([OPENH323DIR])
548   AC_SUBST([OPENH323_INCDIR])
549   AC_SUBST([OPENH323_LIBDIR])
551   AC_LANG_POP([C++])
555 AC_DEFUN(
556 [AST_CHECK_PWLIB_VERSION], [
557         if test "${HAS_$2:-unset}" != "unset"; then
558                 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
559                 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
560                 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
561                 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
562                 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
563                 let $2_REQ=$4*10000+$5*100+$6
565                 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
566                 if test ${$2_VER} -lt ${$2_REQ}; then
567                         AC_MSG_RESULT(no)
568                         unset HAS_$2
569                 else
570                         AC_MSG_RESULT(yes)
571                 fi
572         fi
576 AC_DEFUN(
577 [AST_CHECK_PWLIB_BUILD], [
578         if test "${HAS_$2:-unset}" != "unset"; then
579            AC_MSG_CHECKING($1 installation validity)
581            saved_cppflags="${CPPFLAGS}"
582            saved_libs="${LIBS}"
583            if test "${$2_LIB:-unset}" != "unset"; then
584               LIBS="${LIBS} ${$2_LIB} $7"
585            else
586               LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
587            fi
588            CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
590            AC_LANG_PUSH([C++])
592            AC_LINK_IFELSE(
593                 [AC_LANG_PROGRAM([$4],[$5])],
594                 [       AC_MSG_RESULT(yes) 
595                         ac_cv_lib_$2="yes" 
596                 ],
597                 [       AC_MSG_RESULT(no) 
598                         ac_cv_lib_$2="no" 
599                 ]
600                 )
602            AC_LANG_POP([C++])
604            LIBS="${saved_libs}"
605            CPPFLAGS="${saved_cppflags}"
607            if test "${ac_cv_lib_$2}" = "yes"; then
608               if test "${$2_LIB:-undef}" = "undef"; then
609                  if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
610                     $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
611                  else
612                     $2_LIB="-l${PLATFORM_$2}"
613                  fi
614               fi
615               if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
616                  $2_INCLUDE="-I${$2_INCDIR}"
617               fi
618                   PBX_$2=1
619                   AC_DEFINE([HAVE_$2], 1, [$3])
620            fi
621         fi
624 AC_DEFUN(
625 [AST_CHECK_OPENH323_BUILD], [
626         if test "${HAS_OPENH323:-unset}" != "unset"; then
627                 AC_MSG_CHECKING(OpenH323 build option)
628                 OPENH323_SUFFIX=
629                 prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
630                 for pfx in $prefixes; do
631                         files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
632                         libfile=
633                         if test -n "$files"; then
634                                 for f in $files; do
635                                         if test -f $f -a ! -L $f; then
636                                                 libfile=`basename $f`
637                                                 break;
638                                         fi
639                                 done
640                         fi
641                         if test -n "$libfile"; then
642                                 OPENH323_PREFIX=$pfx
643                                 break;
644                         fi
645                 done
646                 if test "${libfile:-unset}" != "unset"; then
647                         OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
648                 fi
649                 case "${OPENH323_SUFFIX}" in
650                         n)
651                                 OPENH323_BUILD="notrace";;
652                         r)
653                                 OPENH323_BUILD="opt";;
654                         d)
655                                 OPENH323_BUILD="debug";;
656                         *)
657                                 if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
658                                         notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@      @:>@*=@<:@      @:>@*//'"`
659                                         if test "x$notrace" = "x"; then
660                                                 notrace="0"
661                                         fi
662                                         if test "$notrace" -ne 0; then
663                                                 OPENH323_BUILD="notrace"
664                                         else
665                                                 OPENH323_BUILD="opt"
666                                         fi
667                                         OPENH323_LIB="-l${OPENH323_PREFIX}"
668                                 else
669                                         OPENH323_BUILD="notrace"
670                                 fi
671                                 ;;
672                 esac
673                 AC_MSG_RESULT(${OPENH323_BUILD})
675                 AC_SUBST([OPENH323_SUFFIX])
676                 AC_SUBST([OPENH323_BUILD])
677         fi
681 # AST_FUNC_FORK
682 # -------------
683 AN_FUNCTION([fork],  [AST_FUNC_FORK])
684 AN_FUNCTION([vfork], [AST_FUNC_FORK])
685 AC_DEFUN([AST_FUNC_FORK],
686 [AC_REQUIRE([AC_TYPE_PID_T])dnl
687 AC_CHECK_HEADERS(vfork.h)
688 AC_CHECK_FUNCS(fork vfork)
689 if test "x$ac_cv_func_fork" = xyes; then
690   _AST_FUNC_FORK
691 else
692   ac_cv_func_fork_works=$ac_cv_func_fork
694 if test "x$ac_cv_func_fork_works" = xcross; then
695   case $host in
696     *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* )
697       # Override, as these systems have only a dummy fork() stub
698       ac_cv_func_fork_works=no
699       ;;
700     *)
701       ac_cv_func_fork_works=yes
702       ;;
703   esac
704   AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
706 ac_cv_func_vfork_works=$ac_cv_func_vfork
707 if test "x$ac_cv_func_vfork" = xyes; then
708   _AC_FUNC_VFORK
710 if test "x$ac_cv_func_fork_works" = xcross; then
711   ac_cv_func_vfork_works=$ac_cv_func_vfork
712   AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
715 if test "x$ac_cv_func_vfork_works" = xyes; then
716   AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
717 else
718   AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
720 if test "x$ac_cv_func_fork_works" = xyes; then
721   AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
723 ])# AST_FUNC_FORK
726 # _AST_FUNC_FORK
727 # -------------
728 AC_DEFUN([_AST_FUNC_FORK],
729   [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
730     [AC_RUN_IFELSE(
731       [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
732         [
733           /* By Ruediger Kuhlmann. */
734           return fork () < 0;
735         ])],
736       [ac_cv_func_fork_works=yes],
737       [ac_cv_func_fork_works=no],
738       [ac_cv_func_fork_works=cross])])]
739 )# _AST_FUNC_FORK
741 # AST_PROG_LD
742 # ----------
743 # find the pathname to the GNU or non-GNU linker
744 AC_DEFUN([AST_PROG_LD],
745 [AC_ARG_WITH([gnu-ld],
746     [AC_HELP_STRING([--with-gnu-ld],
747         [assume the C compiler uses GNU ld @<:@default=no@:>@])],
748     [test "$withval" = no || with_gnu_ld=yes],
749     [with_gnu_ld=no])
750 AC_REQUIRE([AST_PROG_SED])dnl
751 AC_REQUIRE([AC_PROG_CC])dnl
752 AC_REQUIRE([AC_CANONICAL_HOST])dnl
753 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
754 ac_prog=ld
755 if test "$GCC" = yes; then
756   # Check if gcc -print-prog-name=ld gives a path.
757   AC_MSG_CHECKING([for ld used by $CC])
758   case $host in
759   *-*-mingw*)
760     # gcc leaves a trailing carriage return which upsets mingw
761     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
762   *)
763     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
764   esac
765   case $ac_prog in
766     # Accept absolute paths.
767     [[\\/]]* | ?:[[\\/]]*)
768       re_direlt='/[[^/]][[^/]]*/\.\./'
769       # Canonicalize the pathname of ld
770       ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
771       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
772         ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
773       done
774       test -z "$LD" && LD="$ac_prog"
775       ;;
776   "")
777     # If it fails, then pretend we aren't using GCC.
778     ac_prog=ld
779     ;;
780   *)
781     # If it is relative, then search for the first ld in PATH.
782     with_gnu_ld=unknown
783     ;;
784   esac
785 elif test "$with_gnu_ld" = yes; then
786   AC_MSG_CHECKING([for GNU ld])
787 else
788   AC_MSG_CHECKING([for non-GNU ld])
790 AC_CACHE_VAL(lt_cv_path_LD,
791 [if test -z "$LD"; then
792   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
793   for ac_dir in $PATH; do
794     IFS="$lt_save_ifs"
795     test -z "$ac_dir" && ac_dir=.
796     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
797       lt_cv_path_LD="$ac_dir/$ac_prog"
798       # Check to see if the program is GNU ld.  I'd rather use --version,
799       # but apparently some variants of GNU ld only accept -v.
800       # Break only if it was the GNU/non-GNU ld that we prefer.
801       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
802       *GNU* | *'with BFD'*)
803         test "$with_gnu_ld" != no && break
804         ;;
805       *)
806         test "$with_gnu_ld" != yes && break
807         ;;
808       esac
809     fi
810   done
811   IFS="$lt_save_ifs"
812 else
813   lt_cv_path_LD="$LD" # Let the user override the test with a path.
814 fi])
815 LD="$lt_cv_path_LD"
816 if test -n "$LD"; then
817   AC_MSG_RESULT($LD)
818 else
819   AC_MSG_RESULT(no)
821 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
822 AST_PROG_LD_GNU
823 ])# AST_PROG_LD
826 # AST_PROG_LD_GNU
827 # --------------
828 AC_DEFUN([AST_PROG_LD_GNU],
829 [AC_REQUIRE([AST_PROG_EGREP])dnl
830 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
831 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
832 case `$LD -v 2>&1 </dev/null` in
833 *GNU* | *'with BFD'*)
834   lt_cv_prog_gnu_ld=yes
835   ;;
837   lt_cv_prog_gnu_ld=no
838   ;;
839 esac])
840 with_gnu_ld=$lt_cv_prog_gnu_ld
841 ])# AST_PROG_LD_GNU
843 # AST_PROG_EGREP
844 # -------------
845 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
846 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
847    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
848     then ac_cv_prog_egrep='grep -E'
849     else ac_cv_prog_egrep='egrep'
850     fi])
851  EGREP=$ac_cv_prog_egrep
852  AC_SUBST([EGREP])
853 ])]) # AST_PROG_EGREP
855 # AST_PROG_SED
856 # -----------
857 # Check for a fully functional sed program that truncates
858 # as few characters as possible.  Prefer GNU sed if found.
859 AC_DEFUN([AST_PROG_SED],
860 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
861     [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
862      dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
863      ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
864      for ac_i in 1 2 3 4 5 6 7; do
865        ac_script="$ac_script$as_nl$ac_script"
866      done
867      echo "$ac_script" | sed 99q >conftest.sed
868      $as_unset ac_script || ac_script=
869      _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
870         [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
871                 ["$ac_path_SED" -f conftest.sed])])])
872  SED="$ac_cv_path_SED"
873  AC_SUBST([SED])dnl
874  rm -f conftest.sed
875 ])# AST_PROG_SED
877 dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
879 dnl @summary figure out how to build C programs using POSIX threads
881 dnl This macro figures out how to build C programs using POSIX threads.
882 dnl It sets the PTHREAD_LIBS output variable to the threads library and
883 dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
884 dnl C compiler flags that are needed. (The user can also force certain
885 dnl compiler flags/libs to be tested by setting these environment
886 dnl variables.)
888 dnl Also sets PTHREAD_CC to any special C compiler that is needed for
889 dnl multi-threaded programs (defaults to the value of CC otherwise).
890 dnl (This is necessary on AIX to use the special cc_r compiler alias.)
892 dnl NOTE: You are assumed to not only compile your program with these
893 dnl flags, but also link it with them as well. e.g. you should link
894 dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
895 dnl $LIBS
897 dnl If you are only building threads programs, you may wish to use
898 dnl these variables in your default LIBS, CFLAGS, and CC:
900 dnl        LIBS="$PTHREAD_LIBS $LIBS"
901 dnl        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
902 dnl        CC="$PTHREAD_CC"
904 dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
905 dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
906 dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
908 dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
909 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
910 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
911 dnl default action will define HAVE_PTHREAD.
913 dnl Please let the authors know if this macro fails on any platform, or
914 dnl if you have any other suggestions or comments. This macro was based
915 dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
916 dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
917 dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
918 dnl We are also grateful for the helpful feedback of numerous users.
920 dnl @category InstalledPackages
921 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
922 dnl @version 2006-05-29
923 dnl @license GPLWithACException
925 AC_DEFUN([ACX_PTHREAD],
927 AC_REQUIRE([AC_CANONICAL_HOST])
928 AC_LANG_SAVE
929 AC_LANG_C
930 acx_pthread_ok=no
932 # We used to check for pthread.h first, but this fails if pthread.h
933 # requires special compiler flags (e.g. on True64 or Sequent).
934 # It gets checked for in the link test anyway.
936 # First of all, check if the user has set any of the PTHREAD_LIBS,
937 # etcetera environment variables, and if threads linking works using
938 # them:
939 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
940         save_CFLAGS="$CFLAGS"
941         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
942         save_LIBS="$LIBS"
943         LIBS="$PTHREAD_LIBS $LIBS"
944         AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
945         AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
946         AC_MSG_RESULT($acx_pthread_ok)
947         if test x"$acx_pthread_ok" = xno; then
948                 PTHREAD_LIBS=""
949                 PTHREAD_CFLAGS=""
950         fi
951         LIBS="$save_LIBS"
952         CFLAGS="$save_CFLAGS"
955 # We must check for the threads library under a number of different
956 # names; the ordering is very important because some systems
957 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
958 # libraries is broken (non-POSIX).
960 # Create a list of thread flags to try.  Items starting with a "-" are
961 # C compiler flags, and other items are library names, except for "none"
962 # which indicates that we try without any flags at all, and "pthread-config"
963 # which is a program returning the flags for the Pth emulation library.
965 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
967 # The ordering *is* (sometimes) important.  Some notes on the
968 # individual items follow:
970 # pthreads: AIX (must check this before -lpthread)
971 # none: in case threads are in libc; should be tried before -Kthread and
972 #       other compiler flags to prevent continual compiler warnings
973 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
974 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
975 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
976 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
977 # -pthreads: Solaris/gcc
978 # -mthreads: Mingw32/gcc, Lynx/gcc
979 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
980 #      doesn't hurt to check since this sometimes defines pthreads too;
981 #      also defines -D_REENTRANT)
982 #      ... -mt is also the pthreads flag for HP/aCC
983 # pthread: Linux, etcetera
984 # --thread-safe: KAI C++
985 # pthread-config: use pthread-config program (for GNU Pth library)
987 case "${host_cpu}-${host_os}" in
988         *solaris*)
990         # On Solaris (at least, for some versions), libc contains stubbed
991         # (non-functional) versions of the pthreads routines, so link-based
992         # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
993         # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
994         # a function called by this macro, so we could check for that, but
995         # who knows whether they'll stub that too in a future libc.)  So,
996         # we'll just look for -pthreads and -lpthread first:
998         acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
999         ;;
1000 esac
1002 if test x"$acx_pthread_ok" = xno; then
1003 for flag in $acx_pthread_flags; do
1005         case $flag in
1006                 none)
1007                 AC_MSG_CHECKING([whether pthreads work without any flags])
1008                 ;;
1010                 -*)
1011                 AC_MSG_CHECKING([whether pthreads work with $flag])
1012                 PTHREAD_CFLAGS="$flag"
1013                 ;;
1015                 pthread-config)
1016                 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
1017                 if test x"$acx_pthread_config" = xno; then continue; fi
1018                 PTHREAD_CFLAGS="`pthread-config --cflags`"
1019                 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
1020                 ;;
1022                 *)
1023                 AC_MSG_CHECKING([for the pthreads library -l$flag])
1024                 PTHREAD_LIBS="-l$flag"
1025                 ;;
1026         esac
1028         save_LIBS="$LIBS"
1029         save_CFLAGS="$CFLAGS"
1030         LIBS="$PTHREAD_LIBS $LIBS"
1031         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1033         # Check for various functions.  We must include pthread.h,
1034         # since some functions may be macros.  (On the Sequent, we
1035         # need a special flag -Kthread to make this header compile.)
1036         # We check for pthread_join because it is in -lpthread on IRIX
1037         # while pthread_create is in libc.  We check for pthread_attr_init
1038         # due to DEC craziness with -lpthreads.  We check for
1039         # pthread_cleanup_push because it is one of the few pthread
1040         # functions on Solaris that doesn't have a non-functional libc stub.
1041         # We try pthread_create on general principles.
1042         AC_TRY_LINK([#include <pthread.h>],
1043                     [pthread_t th; pthread_join(th, 0);
1044                      pthread_attr_init(0); pthread_cleanup_push(0, 0);
1045                      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
1046                     [acx_pthread_ok=yes])
1048         LIBS="$save_LIBS"
1049         CFLAGS="$save_CFLAGS"
1051         AC_MSG_RESULT($acx_pthread_ok)
1052         if test "x$acx_pthread_ok" = xyes; then
1053                 break;
1054         fi
1056         PTHREAD_LIBS=""
1057         PTHREAD_CFLAGS=""
1058 done
1061 # Various other checks:
1062 if test "x$acx_pthread_ok" = xyes; then
1063         save_LIBS="$LIBS"
1064         LIBS="$PTHREAD_LIBS $LIBS"
1065         save_CFLAGS="$CFLAGS"
1066         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1068         # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
1069         AC_MSG_CHECKING([for joinable pthread attribute])
1070         attr_name=unknown
1071         for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
1072             AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
1073                         [attr_name=$attr; break])
1074         done
1075         AC_MSG_RESULT($attr_name)
1076         if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
1077             AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
1078                                [Define to necessary symbol if this constant
1079                                 uses a non-standard name on your system.])
1080         fi
1082         AC_MSG_CHECKING([if more special flags are required for pthreads])
1083         flag=no
1084         case "${host_cpu}-${host_os}" in
1085             *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
1086             *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
1087         esac
1088         AC_MSG_RESULT(${flag})
1089         if test "x$flag" != xno; then
1090             PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
1091         fi
1093         LIBS="$save_LIBS"
1094         CFLAGS="$save_CFLAGS"
1096         # More AIX lossage: must compile with xlc_r or cc_r
1097         if test x"$GCC" != xyes; then
1098           AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
1099         else
1100           PTHREAD_CC=$CC
1101         fi
1102 else
1103         PTHREAD_CC="$CC"
1106 AC_SUBST(PTHREAD_LIBS)
1107 AC_SUBST(PTHREAD_CFLAGS)
1108 AC_SUBST(PTHREAD_CC)
1110 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
1111 if test x"$acx_pthread_ok" = xyes; then
1112         ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
1113         :
1114 else
1115         acx_pthread_ok=no
1116         $2
1118 AC_LANG_RESTORE
1119 ])dnl ACX_PTHREAD