Minor formatting change to test a mantis change ...
[asterisk-bristuff.git] / acinclude.m4
blob1395241409332fc4d01a078df2ad2f1e71e7a0f1
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])
132 AC_DEFUN([AST_C_COMPILE_CHECK],
134     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
135         AC_MSG_CHECKING([if "$2" compiles using $3])
136         saved_cppflags="${CPPFLAGS}"
137         if test "x${$1_DIR}" != "x"; then
138             $1_INCLUDE="-I${$1_DIR}/include"
139         fi
140         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
142         AC_COMPILE_IFELSE(
143             [ AC_LANG_PROGRAM( [#include <$3>],
144                                [ $2; ]
145                                )],
146             [   AC_MSG_RESULT(yes)
147                 PBX_$1=1
148                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
149                 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
150             ],
151             [       AC_MSG_RESULT(no) ] 
152         )
153         CPPFLAGS="${saved_cppflags}"
154     fi
158 # Check for existence of a given package ($1), either looking up a function
159 # in a library, or, if no function is supplied, only check for the
160 # existence of the header files.
162 # AST_EXT_LIB_CHECK([package], [library], [function], [header],
163 #        [extra libs], [extra cflags], [version])
164 AC_DEFUN([AST_EXT_LIB_CHECK],
166 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
167    pbxlibdir=""
168    # if --with-$1=DIR has been specified, use it.
169    if test "x${$1_DIR}" != "x"; then
170       if test -d ${$1_DIR}/lib; then
171          pbxlibdir="-L${$1_DIR}/lib"
172       else
173          pbxlibdir="-L${$1_DIR}"
174       fi
175    fi
176    pbxfuncname="$3"
177    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
178       AST_$1_FOUND=yes
179    else
180       AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
181    fi
183    # now check for the header.
184    if test "${AST_$1_FOUND}" = "yes"; then
185       $1_LIB="${pbxlibdir} -l$2 $5"
186       # if --with-$1=DIR has been specified, use it.
187       if test "x${$1_DIR}" != "x"; then
188          $1_INCLUDE="-I${$1_DIR}/include"
189       fi
190       $1_INCLUDE="${$1_INCLUDE} $6"
191       if test "x$4" = "x" ; then        # no header, assume found
192          $1_HEADER_FOUND="1"
193       else                              # check for the header
194          saved_cppflags="${CPPFLAGS}"
195          CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE} $6"
196          AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
197          CPPFLAGS="${saved_cppflags}"
198       fi
199       if test "x${$1_HEADER_FOUND}" = "x0" ; then
200          $1_LIB=""
201          $1_INCLUDE=""
202       else
203          if test "x${pbxfuncname}" = "x" ; then         # only checking headers -> no library
204             $1_LIB=""
205          fi
206          PBX_$1=1
207          # XXX don't know how to evaluate the description (third argument) in AC_DEFINE_UNQUOTED
208          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define this to indicate the ${$1_DESCRIP} library])
209          AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$7], [Define to indicate the ${$1_DESCRIP} library version])
210       fi
211    fi
216 # Check for a package using $2-config. Similar to AST_EXT_LIB_CHECK,
217 # but use $2-config to determine cflags and libraries to use.
218 # $3 and $4 can be used to replace --cflags and --libs in the request
220 # AST_EXT_TOOL_CHECK([package], [tool name], [--cflags], [--libs], [includes], [expression])
221 AC_DEFUN([AST_EXT_TOOL_CHECK],
223     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
224         PBX_$1=0
225         AC_CHECK_TOOL(CONFIG_$1, $2-config, No)
226         if test ! "x${CONFIG_$1}" = xNo; then
227             if test x"$3" = x ; then A=--cflags ; else A="$3" ; fi
228             $1_INCLUDE=$(${CONFIG_$1} $A)
229             if test x"$4" = x ; then A=--libs ; else A="$4" ; fi
230             $1_LIB=$(${CONFIG_$1} $A)
231             if test x"$5" != x ; then
232                 saved_cppflags="${CPPFLAGS}"
233                 if test "x${$1_DIR}" != "x"; then
234                     $1_INCLUDE="-I${$1_DIR}/include"
235                 fi
236                 CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
238                 saved_ldflags="${LDFLAGS}"
239                 LDFLAGS="${$1_LIB}"
241                 AC_LINK_IFELSE(
242                     [ AC_LANG_PROGRAM( [ $5 ],
243                                        [ $6; ]
244                                        )],
245                     [   PBX_$1=1
246                         AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
247                     ],
248                     []
249                 )
250                 CPPFLAGS="${saved_cppflags}"
251                 LDFLAGS="${saved_ldflags}"
252             else
253                 PBX_$1=1
254                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 libraries.])
255             fi
256         fi
257     fi
260 AC_DEFUN(
261 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
262    GNU_MAKE='Not Found' ;
263    GNU_MAKE_VERSION_MAJOR=0 ;
264    GNU_MAKE_VERSION_MINOR=0 ;
265    for a in make gmake gnumake ; do
266       if test -z "$a" ; then continue ; fi ;
267       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
268          GNU_MAKE=$a ;
269          GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
270          GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
271          break;
272       fi
273    done ;
274 ) ;
275 if test  "x$GNU_MAKE" = "xNot Found"  ; then
276    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
277    exit 1
279 AC_SUBST([GNU_MAKE])
283 AC_DEFUN(
284 [AST_CHECK_PWLIB], [
285 PWLIB_INCDIR=
286 PWLIB_LIBDIR=
287 AC_LANG_PUSH([C++])
288 if test "${PWLIBDIR:-unset}" != "unset" ; then
289   AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
291 if test "${HAS_PWLIB:-unset}" = "unset" ; then
292   if test "${OPENH323DIR:-unset}" != "unset"; then
293     AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
294   fi
295   if test "${HAS_PWLIB:-unset}" != "unset" ; then
296     PWLIBDIR="${OPENH323DIR}/../pwlib"
297   else
298     AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
299     if test "${HAS_PWLIB:-unset}" != "unset" ; then
300       PWLIBDIR="${HOME}/pwlib"
301     else
302       AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
303       if test "${HAS_PWLIB:-unset}" != "unset" ; then
304         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
305         if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
306           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
307         fi
308         PWLIB_INCDIR="/usr/local/include"
309         PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
310         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
311           if test "x$LIB64" != "x"; then
312             PWLIB_LIBDIR="/usr/local/lib64"
313           else
314             PWLIB_LIBDIR="/usr/local/lib"
315           fi
316         fi
317         PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
318         PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
319       else
320         AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
321         if test "${HAS_PWLIB:-unset}" != "unset" ; then
322           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
323           PWLIB_INCDIR="/usr/include"
324           PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
325           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
326             if test "x$LIB64" != "x"; then
327               PWLIB_LIBDIR="/usr/lib64"
328             else
329               PWLIB_LIBDIR="/usr/lib"
330             fi
331           fi
332           PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
333           PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
334         fi
335       fi
336     fi
337   fi
340 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
341 #  echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
342 #  exit
345 if test "${HAS_PWLIB:-unset}" != "unset" ; then
346   if test "${PWLIBDIR:-unset}" = "unset" ; then
347     if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
348       PWLIBDIR=`$PTLIB_CONFIG --prefix`
349     else
350       echo "Cannot find ptlib-config - please install and try again"
351       exit
352     fi
353   fi
355   if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
356     PWLIBDIR="/usr/share/pwlib"
357     PWLIB_INCDIR="/usr/include"
358     if test "x$LIB64" != "x"; then
359       PWLIB_LIBDIR="/usr/lib64"
360     else
361       PWLIB_LIBDIR="/usr/lib"
362     fi
363   fi
364   if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
365     PWLIBDIR="/usr/local/share/pwlib"
366     PWLIB_INCDIR="/usr/local/include"
367     if test "x$LIB64" != "x"; then
368       PWLIB_LIBDIR="/usr/local/lib64"
369     else
370       PWLIB_LIBDIR="/usr/local/lib"
371     fi
372   fi
374   if test "${PWLIB_INCDIR:-unset}" = "unset"; then
375     PWLIB_INCDIR="${PWLIBDIR}/include"
376   fi
377   if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
378     PWLIB_LIBDIR="${PWLIBDIR}/lib"
379   fi
381   AC_SUBST([PWLIBDIR])
382   AC_SUBST([PWLIB_INCDIR])
383   AC_SUBST([PWLIB_LIBDIR])
385   AC_LANG_POP([C++])
389 AC_DEFUN(
390 [AST_CHECK_OPENH323_PLATFORM], [
391 PWLIB_OSTYPE=
392 case "$host_os" in
393   linux*)          PWLIB_OSTYPE=linux ;
394                 ;;
395   freebsd* )       PWLIB_OSTYPE=FreeBSD ;
396                 ;;
397   openbsd* )       PWLIB_OSTYPE=OpenBSD ;
398                                    ENDLDLIBS="-lossaudio" ;
399                 ;;
400   netbsd* )        PWLIB_OSTYPE=NetBSD ;
401                                    ENDLDLIBS="-lossaudio" ;
402                 ;;
403   solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
404                 ;;
405   darwin* )            PWLIB_OSTYPE=Darwin ;
406                 ;;
407   beos*)           PWLIB_OSTYPE=beos ;
408                    STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
409                 ;;
410   cygwin*)         PWLIB_OSTYPE=cygwin ;
411                 ;;
412   mingw*)              PWLIB_OSTYPE=mingw ;
413                            STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
414                            ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
415                 ;;
416   * )                  PWLIB_OSTYPE="$host_os" ;
417                            AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
418                 ;;
419 esac
421 PWLIB_MACHTYPE=
422 case "$host_cpu" in
423    x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
424                    ;;
426    x86_64)         PWLIB_MACHTYPE=x86_64 ;
427                    P_64BIT=1 ;
428                    LIB64=1 ;
429                    ;;
431    alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
432                    P_64BIT=1 ;
433                    ;;
435    sparc )         PWLIB_MACHTYPE=sparc ;
436                    ;;
438    powerpc )       PWLIB_MACHTYPE=ppc ;
439                    ;;
441    ppc )           PWLIB_MACHTYPE=ppc ;
442                    ;;
444    powerpc64 )     PWLIB_MACHTYPE=ppc64 ;
445                    P_64BIT=1 ;
446                    LIB64=1 ;
447                    ;;
449    ppc64 )         PWLIB_MACHTYPE=ppc64 ;
450                    P_64BIT=1 ;
451                    LIB64=1 ;
452                    ;;
454    ia64)           PWLIB_MACHTYPE=ia64 ;
455                    P_64BIT=1 ;
456                    ;;
458    s390x)          PWLIB_MACHTYPE=s390x ;
459                    P_64BIT=1 ;
460                    LIB64=1 ;
461                    ;;
463    s390)           PWLIB_MACHTYPE=s390 ;
464                    ;;
466    * )             PWLIB_MACHTYPE="$host_cpu";
467                    AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
468 esac
470 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
472 AC_SUBST([PWLIB_PLATFORM])
476 AC_DEFUN(
477 [AST_CHECK_OPENH323], [
478 OPENH323_INCDIR=
479 OPENH323_LIBDIR=
480 AC_LANG_PUSH([C++])
481 if test "${OPENH323DIR:-unset}" != "unset" ; then
482   AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
484 if test "${HAS_OPENH323:-unset}" = "unset" ; then
485   AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
486   if test "${HAS_OPENH323:-unset}" != "unset" ; then
487     OPENH323DIR="${PWLIBDIR}/../openh323"
488     saved_cppflags="${CPPFLAGS}"
489     CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
490     AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
491     CPPFLAGS="${saved_cppflags}"
492   else
493     saved_cppflags="${CPPFLAGS}"
494     CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
495     AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
496     CPPFLAGS="${saved_cppflags}"
497     if test "${HAS_OPENH323:-unset}" != "unset" ; then
498       OPENH323DIR="${HOME}/openh323"
499     else
500       saved_cppflags="${CPPFLAGS}"
501       CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
502       AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
503       CPPFLAGS="${saved_cppflags}"
504       if test "${HAS_OPENH323:-unset}" != "unset" ; then
505         OPENH323DIR="/usr/local/share/openh323"
506         OPENH323_INCDIR="/usr/local/include/openh323"
507         if test "x$LIB64" != "x"; then
508           OPENH323_LIBDIR="/usr/local/lib64"
509         else
510           OPENH323_LIBDIR="/usr/local/lib"
511         fi
512       else
513         saved_cppflags="${CPPFLAGS}"
514         CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
515         AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
516         CPPFLAGS="${saved_cppflags}"
517         if test "${HAS_OPENH323:-unset}" != "unset" ; then
518           OPENH323DIR="/usr/share/openh323"
519           OPENH323_INCDIR="/usr/include/openh323"
520           if test "x$LIB64" != "x"; then
521             OPENH323_LIBDIR="/usr/lib64"
522           else
523             OPENH323_LIBDIR="/usr/lib"
524           fi
525         fi
526       fi
527     fi
528   fi
531 if test "${HAS_OPENH323:-unset}" != "unset" ; then
532   if test "${OPENH323_INCDIR:-unset}" = "unset"; then
533     OPENH323_INCDIR="${OPENH323DIR}/include"
534   fi
535   if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
536     OPENH323_LIBDIR="${OPENH323DIR}/lib"
537   fi
539   OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
540   OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
541   OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
543   AC_SUBST([OPENH323DIR])
544   AC_SUBST([OPENH323_INCDIR])
545   AC_SUBST([OPENH323_LIBDIR])
547   AC_LANG_POP([C++])
551 AC_DEFUN(
552 [AST_CHECK_PWLIB_VERSION], [
553         if test "${HAS_$2:-unset}" != "unset"; then
554                 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
555                 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
556                 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
557                 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
558                 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
559                 let $2_REQ=$4*10000+$5*100+$6
561                 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
562                 if test ${$2_VER} -lt ${$2_REQ}; then
563                         AC_MSG_RESULT(no)
564                         unset HAS_$2
565                 else
566                         AC_MSG_RESULT(yes)
567                 fi
568         fi
572 AC_DEFUN(
573 [AST_CHECK_PWLIB_BUILD], [
574         if test "${HAS_$2:-unset}" != "unset"; then
575            AC_MSG_CHECKING($1 installation validity)
577            saved_cppflags="${CPPFLAGS}"
578            saved_libs="${LIBS}"
579            if test "${$2_LIB:-unset}" != "unset"; then
580               LIBS="${LIBS} ${$2_LIB} $7"
581            else
582               LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
583            fi
584            CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
586            AC_LANG_PUSH([C++])
588            AC_LINK_IFELSE(
589                 [AC_LANG_PROGRAM([$4],[$5])],
590                 [       AC_MSG_RESULT(yes) 
591                         ac_cv_lib_$2="yes" 
592                 ],
593                 [       AC_MSG_RESULT(no) 
594                         ac_cv_lib_$2="no" 
595                 ]
596                 )
598            AC_LANG_POP([C++])
600            LIBS="${saved_libs}"
601            CPPFLAGS="${saved_cppflags}"
603            if test "${ac_cv_lib_$2}" = "yes"; then
604               if test "${$2_LIB:-undef}" = "undef"; then
605                  if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
606                     $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
607                  else
608                     $2_LIB="-l${PLATFORM_$2}"
609                  fi
610               fi
611               if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
612                  $2_INCLUDE="-I${$2_INCDIR}"
613               fi
614                   PBX_$2=1
615                   AC_DEFINE([HAVE_$2], 1, [$3])
616            fi
617         fi
620 AC_DEFUN(
621 [AST_CHECK_OPENH323_BUILD], [
622         if test "${HAS_OPENH323:-unset}" != "unset"; then
623                 AC_MSG_CHECKING(OpenH323 build option)
624                 OPENH323_SUFFIX=
625                 prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
626                 for pfx in $prefixes; do
627                         files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
628                         libfile=
629                         if test -n "$files"; then
630                                 for f in $files; do
631                                         if test -f $f -a ! -L $f; then
632                                                 libfile=`basename $f`
633                                                 break;
634                                         fi
635                                 done
636                         fi
637                         if test -n "$libfile"; then
638                                 OPENH323_PREFIX=$pfx
639                                 break;
640                         fi
641                 done
642                 if test "${libfile:-unset}" != "unset"; then
643                         OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
644                 fi
645                 case "${OPENH323_SUFFIX}" in
646                         n)
647                                 OPENH323_BUILD="notrace";;
648                         r)
649                                 OPENH323_BUILD="opt";;
650                         d)
651                                 OPENH323_BUILD="debug";;
652                         *)
653                                 if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
654                                         notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@      @:>@*=@<:@      @:>@*//'"`
655                                         if test "x$notrace" = "x"; then
656                                                 notrace="0"
657                                         fi
658                                         if test "$notrace" -ne 0; then
659                                                 OPENH323_BUILD="notrace"
660                                         else
661                                                 OPENH323_BUILD="opt"
662                                         fi
663                                         OPENH323_LIB="-l${OPENH323_PREFIX}"
664                                 else
665                                         OPENH323_BUILD="notrace"
666                                 fi
667                                 ;;
668                 esac
669                 AC_MSG_RESULT(${OPENH323_BUILD})
671                 AC_SUBST([OPENH323_SUFFIX])
672                 AC_SUBST([OPENH323_BUILD])
673         fi
677 # AST_FUNC_FORK
678 # -------------
679 AN_FUNCTION([fork],  [AST_FUNC_FORK])
680 AN_FUNCTION([vfork], [AST_FUNC_FORK])
681 AC_DEFUN([AST_FUNC_FORK],
682 [AC_REQUIRE([AC_TYPE_PID_T])dnl
683 AC_CHECK_HEADERS(vfork.h)
684 AC_CHECK_FUNCS(fork vfork)
685 if test "x$ac_cv_func_fork" = xyes; then
686   _AST_FUNC_FORK
687 else
688   ac_cv_func_fork_works=$ac_cv_func_fork
690 if test "x$ac_cv_func_fork_works" = xcross; then
691   case $host in
692     *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* )
693       # Override, as these systems have only a dummy fork() stub
694       ac_cv_func_fork_works=no
695       ;;
696     *)
697       ac_cv_func_fork_works=yes
698       ;;
699   esac
700   AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
702 ac_cv_func_vfork_works=$ac_cv_func_vfork
703 if test "x$ac_cv_func_vfork" = xyes; then
704   _AC_FUNC_VFORK
706 if test "x$ac_cv_func_fork_works" = xcross; then
707   ac_cv_func_vfork_works=$ac_cv_func_vfork
708   AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
711 if test "x$ac_cv_func_vfork_works" = xyes; then
712   AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
713 else
714   AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
716 if test "x$ac_cv_func_fork_works" = xyes; then
717   AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
719 ])# AST_FUNC_FORK
722 # _AST_FUNC_FORK
723 # -------------
724 AC_DEFUN([_AST_FUNC_FORK],
725   [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
726     [AC_RUN_IFELSE(
727       [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
728         [
729           /* By Ruediger Kuhlmann. */
730           return fork () < 0;
731         ])],
732       [ac_cv_func_fork_works=yes],
733       [ac_cv_func_fork_works=no],
734       [ac_cv_func_fork_works=cross])])]
735 )# _AST_FUNC_FORK
737 # AST_PROG_LD
738 # ----------
739 # find the pathname to the GNU or non-GNU linker
740 AC_DEFUN([AST_PROG_LD],
741 [AC_ARG_WITH([gnu-ld],
742     [AC_HELP_STRING([--with-gnu-ld],
743         [assume the C compiler uses GNU ld @<:@default=no@:>@])],
744     [test "$withval" = no || with_gnu_ld=yes],
745     [with_gnu_ld=no])
746 AC_REQUIRE([AST_PROG_SED])dnl
747 AC_REQUIRE([AC_PROG_CC])dnl
748 AC_REQUIRE([AC_CANONICAL_HOST])dnl
749 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
750 ac_prog=ld
751 if test "$GCC" = yes; then
752   # Check if gcc -print-prog-name=ld gives a path.
753   AC_MSG_CHECKING([for ld used by $CC])
754   case $host in
755   *-*-mingw*)
756     # gcc leaves a trailing carriage return which upsets mingw
757     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
758   *)
759     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
760   esac
761   case $ac_prog in
762     # Accept absolute paths.
763     [[\\/]]* | ?:[[\\/]]*)
764       re_direlt='/[[^/]][[^/]]*/\.\./'
765       # Canonicalize the pathname of ld
766       ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
767       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
768         ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
769       done
770       test -z "$LD" && LD="$ac_prog"
771       ;;
772   "")
773     # If it fails, then pretend we aren't using GCC.
774     ac_prog=ld
775     ;;
776   *)
777     # If it is relative, then search for the first ld in PATH.
778     with_gnu_ld=unknown
779     ;;
780   esac
781 elif test "$with_gnu_ld" = yes; then
782   AC_MSG_CHECKING([for GNU ld])
783 else
784   AC_MSG_CHECKING([for non-GNU ld])
786 AC_CACHE_VAL(lt_cv_path_LD,
787 [if test -z "$LD"; then
788   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
789   for ac_dir in $PATH; do
790     IFS="$lt_save_ifs"
791     test -z "$ac_dir" && ac_dir=.
792     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
793       lt_cv_path_LD="$ac_dir/$ac_prog"
794       # Check to see if the program is GNU ld.  I'd rather use --version,
795       # but apparently some variants of GNU ld only accept -v.
796       # Break only if it was the GNU/non-GNU ld that we prefer.
797       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
798       *GNU* | *'with BFD'*)
799         test "$with_gnu_ld" != no && break
800         ;;
801       *)
802         test "$with_gnu_ld" != yes && break
803         ;;
804       esac
805     fi
806   done
807   IFS="$lt_save_ifs"
808 else
809   lt_cv_path_LD="$LD" # Let the user override the test with a path.
810 fi])
811 LD="$lt_cv_path_LD"
812 if test -n "$LD"; then
813   AC_MSG_RESULT($LD)
814 else
815   AC_MSG_RESULT(no)
817 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
818 AST_PROG_LD_GNU
819 ])# AST_PROG_LD
822 # AST_PROG_LD_GNU
823 # --------------
824 AC_DEFUN([AST_PROG_LD_GNU],
825 [AC_REQUIRE([AST_PROG_EGREP])dnl
826 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
827 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
828 case `$LD -v 2>&1 </dev/null` in
829 *GNU* | *'with BFD'*)
830   lt_cv_prog_gnu_ld=yes
831   ;;
833   lt_cv_prog_gnu_ld=no
834   ;;
835 esac])
836 with_gnu_ld=$lt_cv_prog_gnu_ld
837 ])# AST_PROG_LD_GNU
839 # AST_PROG_EGREP
840 # -------------
841 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
842 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
843    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
844     then ac_cv_prog_egrep='grep -E'
845     else ac_cv_prog_egrep='egrep'
846     fi])
847  EGREP=$ac_cv_prog_egrep
848  AC_SUBST([EGREP])
849 ])]) # AST_PROG_EGREP
851 # AST_PROG_SED
852 # -----------
853 # Check for a fully functional sed program that truncates
854 # as few characters as possible.  Prefer GNU sed if found.
855 AC_DEFUN([AST_PROG_SED],
856 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
857     [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
858      dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
859      ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
860      for ac_i in 1 2 3 4 5 6 7; do
861        ac_script="$ac_script$as_nl$ac_script"
862      done
863      echo "$ac_script" | sed 99q >conftest.sed
864      $as_unset ac_script || ac_script=
865      _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
866         [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
867                 ["$ac_path_SED" -f conftest.sed])])])
868  SED="$ac_cv_path_SED"
869  AC_SUBST([SED])dnl
870  rm -f conftest.sed
871 ])# AST_PROG_SED
873 dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
875 dnl @summary figure out how to build C programs using POSIX threads
877 dnl This macro figures out how to build C programs using POSIX threads.
878 dnl It sets the PTHREAD_LIBS output variable to the threads library and
879 dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
880 dnl C compiler flags that are needed. (The user can also force certain
881 dnl compiler flags/libs to be tested by setting these environment
882 dnl variables.)
884 dnl Also sets PTHREAD_CC to any special C compiler that is needed for
885 dnl multi-threaded programs (defaults to the value of CC otherwise).
886 dnl (This is necessary on AIX to use the special cc_r compiler alias.)
888 dnl NOTE: You are assumed to not only compile your program with these
889 dnl flags, but also link it with them as well. e.g. you should link
890 dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
891 dnl $LIBS
893 dnl If you are only building threads programs, you may wish to use
894 dnl these variables in your default LIBS, CFLAGS, and CC:
896 dnl        LIBS="$PTHREAD_LIBS $LIBS"
897 dnl        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
898 dnl        CC="$PTHREAD_CC"
900 dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
901 dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
902 dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
904 dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
905 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
906 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
907 dnl default action will define HAVE_PTHREAD.
909 dnl Please let the authors know if this macro fails on any platform, or
910 dnl if you have any other suggestions or comments. This macro was based
911 dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
912 dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
913 dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
914 dnl We are also grateful for the helpful feedback of numerous users.
916 dnl @category InstalledPackages
917 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
918 dnl @version 2006-05-29
919 dnl @license GPLWithACException
921 AC_DEFUN([ACX_PTHREAD],
923 AC_REQUIRE([AC_CANONICAL_HOST])
924 AC_LANG_SAVE
925 AC_LANG_C
926 acx_pthread_ok=no
928 # We used to check for pthread.h first, but this fails if pthread.h
929 # requires special compiler flags (e.g. on True64 or Sequent).
930 # It gets checked for in the link test anyway.
932 # First of all, check if the user has set any of the PTHREAD_LIBS,
933 # etcetera environment variables, and if threads linking works using
934 # them:
935 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
936         save_CFLAGS="$CFLAGS"
937         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
938         save_LIBS="$LIBS"
939         LIBS="$PTHREAD_LIBS $LIBS"
940         AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
941         AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
942         AC_MSG_RESULT($acx_pthread_ok)
943         if test x"$acx_pthread_ok" = xno; then
944                 PTHREAD_LIBS=""
945                 PTHREAD_CFLAGS=""
946         fi
947         LIBS="$save_LIBS"
948         CFLAGS="$save_CFLAGS"
951 # We must check for the threads library under a number of different
952 # names; the ordering is very important because some systems
953 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
954 # libraries is broken (non-POSIX).
956 # Create a list of thread flags to try.  Items starting with a "-" are
957 # C compiler flags, and other items are library names, except for "none"
958 # which indicates that we try without any flags at all, and "pthread-config"
959 # which is a program returning the flags for the Pth emulation library.
961 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
963 # The ordering *is* (sometimes) important.  Some notes on the
964 # individual items follow:
966 # pthreads: AIX (must check this before -lpthread)
967 # none: in case threads are in libc; should be tried before -Kthread and
968 #       other compiler flags to prevent continual compiler warnings
969 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
970 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
971 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
972 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
973 # -pthreads: Solaris/gcc
974 # -mthreads: Mingw32/gcc, Lynx/gcc
975 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
976 #      doesn't hurt to check since this sometimes defines pthreads too;
977 #      also defines -D_REENTRANT)
978 #      ... -mt is also the pthreads flag for HP/aCC
979 # pthread: Linux, etcetera
980 # --thread-safe: KAI C++
981 # pthread-config: use pthread-config program (for GNU Pth library)
983 case "${host_cpu}-${host_os}" in
984         *solaris*)
986         # On Solaris (at least, for some versions), libc contains stubbed
987         # (non-functional) versions of the pthreads routines, so link-based
988         # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
989         # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
990         # a function called by this macro, so we could check for that, but
991         # who knows whether they'll stub that too in a future libc.)  So,
992         # we'll just look for -pthreads and -lpthread first:
994         acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
995         ;;
996 esac
998 if test x"$acx_pthread_ok" = xno; then
999 for flag in $acx_pthread_flags; do
1001         case $flag in
1002                 none)
1003                 AC_MSG_CHECKING([whether pthreads work without any flags])
1004                 ;;
1006                 -*)
1007                 AC_MSG_CHECKING([whether pthreads work with $flag])
1008                 PTHREAD_CFLAGS="$flag"
1009                 ;;
1011                 pthread-config)
1012                 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
1013                 if test x"$acx_pthread_config" = xno; then continue; fi
1014                 PTHREAD_CFLAGS="`pthread-config --cflags`"
1015                 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
1016                 ;;
1018                 *)
1019                 AC_MSG_CHECKING([for the pthreads library -l$flag])
1020                 PTHREAD_LIBS="-l$flag"
1021                 ;;
1022         esac
1024         save_LIBS="$LIBS"
1025         save_CFLAGS="$CFLAGS"
1026         LIBS="$PTHREAD_LIBS $LIBS"
1027         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1029         # Check for various functions.  We must include pthread.h,
1030         # since some functions may be macros.  (On the Sequent, we
1031         # need a special flag -Kthread to make this header compile.)
1032         # We check for pthread_join because it is in -lpthread on IRIX
1033         # while pthread_create is in libc.  We check for pthread_attr_init
1034         # due to DEC craziness with -lpthreads.  We check for
1035         # pthread_cleanup_push because it is one of the few pthread
1036         # functions on Solaris that doesn't have a non-functional libc stub.
1037         # We try pthread_create on general principles.
1038         AC_TRY_LINK([#include <pthread.h>],
1039                     [pthread_t th; pthread_join(th, 0);
1040                      pthread_attr_init(0); pthread_cleanup_push(0, 0);
1041                      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
1042                     [acx_pthread_ok=yes])
1044         LIBS="$save_LIBS"
1045         CFLAGS="$save_CFLAGS"
1047         AC_MSG_RESULT($acx_pthread_ok)
1048         if test "x$acx_pthread_ok" = xyes; then
1049                 break;
1050         fi
1052         PTHREAD_LIBS=""
1053         PTHREAD_CFLAGS=""
1054 done
1057 # Various other checks:
1058 if test "x$acx_pthread_ok" = xyes; then
1059         save_LIBS="$LIBS"
1060         LIBS="$PTHREAD_LIBS $LIBS"
1061         save_CFLAGS="$CFLAGS"
1062         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1064         # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
1065         AC_MSG_CHECKING([for joinable pthread attribute])
1066         attr_name=unknown
1067         for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
1068             AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
1069                         [attr_name=$attr; break])
1070         done
1071         AC_MSG_RESULT($attr_name)
1072         if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
1073             AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
1074                                [Define to necessary symbol if this constant
1075                                 uses a non-standard name on your system.])
1076         fi
1078         AC_MSG_CHECKING([if more special flags are required for pthreads])
1079         flag=no
1080         case "${host_cpu}-${host_os}" in
1081             *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
1082             *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
1083         esac
1084         AC_MSG_RESULT(${flag})
1085         if test "x$flag" != xno; then
1086             PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
1087         fi
1089         LIBS="$save_LIBS"
1090         CFLAGS="$save_CFLAGS"
1092         # More AIX lossage: must compile with xlc_r or cc_r
1093         if test x"$GCC" != xyes; then
1094           AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
1095         else
1096           PTHREAD_CC=$CC
1097         fi
1098 else
1099         PTHREAD_CC="$CC"
1102 AC_SUBST(PTHREAD_LIBS)
1103 AC_SUBST(PTHREAD_CFLAGS)
1104 AC_SUBST(PTHREAD_CC)
1106 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
1107 if test x"$acx_pthread_ok" = xyes; then
1108         ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
1109         :
1110 else
1111         acx_pthread_ok=no
1112         $2
1114 AC_LANG_RESTORE
1115 ])dnl ACX_PTHREAD