Merged revisions 135597 via svnmerge from
[asterisk/asterisk.git] / acinclude.m4
index 26360a6..59566d0 100644 (file)
@@ -1,45 +1,61 @@
+# Various support functions for configure.ac in asterisk
+#
+
+# Helper function to check for gcc attributes.
 # AST_GCC_ATTRIBUTE([attribute name])
 
 AC_DEFUN([AST_GCC_ATTRIBUTE],
 [
 AC_MSG_CHECKING(for compiler 'attribute $1' support)
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE(
-       AC_LANG_PROGRAM([static int __attribute__(($1)) test(void) {}],
+       AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
                        []),
        AC_MSG_RESULT(yes)
        AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
        AC_MSG_RESULT(no))
-])
+]
+CFLAGS="$saved_CFLAGS"
+)
 
-# AST_EXT_LIB_SETUP([package symbol name], [package friendly name], [package option name], [additional help text])
+# Helper function to setup variables for a package.
+# $1 -> the package name. Used in configure.ac and also as a prefix
+#      for the variables ($1_DIR, $1_INCLUDE, $1_LIB) in makeopts
+# $3 ->        option name, used in --with-$3 or --without-$3 when calling configure.
+# $2 and $4 are just text describing the package (short and long form)
+
+# AST_EXT_LIB_SETUP([package], [short description], [configure option name], [long description])
 
 AC_DEFUN([AST_EXT_LIB_SETUP],
 [
-$1_DESCRIP="$2"
-$1_OPTION="$3"
-AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
-case ${withval} in
-     n|no)
-     USE_$1=no
-     ;;
-     y|ye|yes)
-     ac_mandatory_list="${ac_mandatory_list} $1"
-     ;;
-     *)
-     $1_DIR="${withval}"
-     ac_mandatory_list="${ac_mandatory_list} $1"
-     ;;
-esac
-])
-PBX_$1=0
-AC_SUBST([$1_LIB])
-AC_SUBST([$1_INCLUDE])
-AC_SUBST([$1_DIR])
-AC_SUBST([PBX_$1])
+    $1_DESCRIP="$2"
+    $1_OPTION="$3"
+    AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),
+    [
+       case ${withval} in
+       n|no)
+       USE_$1=no
+       ;;
+       y|ye|yes)
+       ac_mandatory_list="${ac_mandatory_list} $1"
+       ;;
+       *)
+       $1_DIR="${withval}"
+       ac_mandatory_list="${ac_mandatory_list} $1"
+       ;;
+       esac
+    ])
+    PBX_$1=0
+    AC_SUBST([$1_LIB])
+    AC_SUBST([$1_INCLUDE])
+    AC_SUBST([$1_DIR])
+    AC_SUBST([PBX_$1])
 ])
 
 # Check whether any of the mandatory modules are not present, and
-# print error messages in case.
+# print error messages in case. The mandatory list is built using
+# --with-* arguments when invoking configure.
 
 AC_DEFUN([AST_CHECK_MANDATORY],
 [
@@ -61,28 +77,76 @@ AC_DEFUN([AST_CHECK_MANDATORY],
        AC_MSG_RESULT(ok)
 ])
 
-#-- The following two tests are only performed if PBX_$1 != 1,
-#   so you can use multiple tests and stop at the first matching one.
-#   On success, set PBX_$1 = 1, and also #define HAVE_$1 1
-#   and #define HAVE_$1_VERSION ${last_argument} so you can tell which
-#   test succeeded.
-#   They should be called after AST_EXT_LIB_SETUP($1, ...)
+# The next three functions check for the availability of a given package.
+# AST_C_DEFINE_CHECK looks for the presence of a #define in a header file,
+# AST_C_COMPILE_CHECK can be used for testing for various items in header files,
+# AST_EXT_LIB_CHECK looks for a symbol in a given library, or at least
+#      for the presence of a header file.
+# AST_EXT_TOOL_CHECK looks for a symbol in using $1-config to determine CFLAGS and LIBS
+#
+# They are only run if PBX_$1 != 1 (where $1 is the package),
+# so you can call them multiple times and stop at the first matching one.
+# On success, they both set PBX_$1 = 1, set $1_INCLUDE and $1_LIB as applicable,
+# and also #define HAVE_$1 1 and #define HAVE_$1_VERSION ${last_argument}
+# in autoconfig.h so you can tell which test succeeded.
+# They should be called after AST_EXT_LIB_SETUP($1, ...)
 
 # Check if a given macro is defined in a certain header.
 
-# AST_C_DEFINE_CHECK([package symbol name], [macro name], [header file], [version])
+# AST_C_DEFINE_CHECK([package], [macro name], [header file], [version])
 AC_DEFUN([AST_C_DEFINE_CHECK],
 [
-    if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+    if test "x${PBX_$1}" != "x1"; then
        AC_MSG_CHECKING([for $2 in $3])
        saved_cppflags="${CPPFLAGS}"
        if test "x${$1_DIR}" != "x"; then
-           $1_INCLUDE= "-I${$1_DIR}/include"
+           $1_INCLUDE="-I${$1_DIR}/include"
+       fi
+       CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+
+       AC_COMPILE_IFELSE(
+           [ AC_LANG_PROGRAM( [#include <$3>],
+                              [#if defined($2)
+                               int foo = 0;
+                               #else
+                               int foo = bar;
+                               #endif
+                               0
+                              ])],
+           [   AC_MSG_RESULT(yes)
+               PBX_$1=1
+               AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
+               AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
+           ],
+           [   AC_MSG_RESULT(no) ] 
+       )
+       CPPFLAGS="${saved_cppflags}"
+    fi
+    AC_SUBST(PBX_$1)
+])
+
+
+# Check if a given expression will compile using a certain header.
+
+# AST_C_COMPILE_CHECK([package], [expression], [header file], [version], [description])
+AC_DEFUN([AST_C_COMPILE_CHECK],
+[
+    if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+        if test "x$5" != "x"; then
+            AC_MSG_CHECKING([for $5])
+       else
+            AC_MSG_CHECKING([if "$2" compiles using $3])
+       fi
+       saved_cppflags="${CPPFLAGS}"
+       if test "x${$1_DIR}" != "x"; then
+           $1_INCLUDE="-I${$1_DIR}/include"
        fi
        CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
 
        AC_COMPILE_IFELSE(
-           [ AC_LANG_PROGRAM( [#include <$3>], [int foo = $2;]) ],
+           [ AC_LANG_PROGRAM( [#include <$3>],
+                              [ $2; ]
+                              )],
            [   AC_MSG_RESULT(yes)
                PBX_$1=1
                AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
@@ -99,11 +163,13 @@ AC_DEFUN([AST_C_DEFINE_CHECK],
 # in a library, or, if no function is supplied, only check for the
 # existence of the header files.
 
-# AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data], [version])
+# AST_EXT_LIB_CHECK([package], [library], [function], [header],
+#       [extra libs], [extra cflags], [version])
 AC_DEFUN([AST_EXT_LIB_CHECK],
 [
 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
    pbxlibdir=""
+   # if --with-$1=DIR has been specified, use it.
    if test "x${$1_DIR}" != "x"; then
       if test -d ${$1_DIR}/lib; then
         pbxlibdir="-L${$1_DIR}/lib"
@@ -118,22 +184,21 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
       AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
    fi
 
+   # now check for the header.
    if test "${AST_$1_FOUND}" = "yes"; then
-      $1_LIB="-l$2 $5"
-      $1_HEADER_FOUND="1"
+      $1_LIB="${pbxlibdir} -l$2 $5"
+      # if --with-$1=DIR has been specified, use it.
       if test "x${$1_DIR}" != "x"; then
-         $1_LIB="${pbxlibdir} ${$1_LIB}"
         $1_INCLUDE="-I${$1_DIR}/include"
-        saved_cppflags="${CPPFLAGS}"
-        CPPFLAGS="${CPPFLAGS} -I${$1_DIR}/include"
-        if test "x$4" != "x" ; then
-           AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
-        fi
-        CPPFLAGS="${saved_cppflags}"
-      else
-        if test "x$4" != "x" ; then
-            AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
-        fi
+      fi
+      $1_INCLUDE="${$1_INCLUDE} $6"
+      if test "x$4" = "x" ; then       # no header, assume found
+         $1_HEADER_FOUND="1"
+      else                             # check for the header
+         saved_cppflags="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+        AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
+         CPPFLAGS="${saved_cppflags}"
       fi
       if test "x${$1_HEADER_FOUND}" = "x0" ; then
          $1_LIB=""
@@ -145,13 +210,57 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
          PBX_$1=1
          # XXX don't know how to evaluate the description (third argument) in AC_DEFINE_UNQUOTED
          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define this to indicate the ${$1_DESCRIP} library])
-        AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$6], [Define to indicate the ${$1_DESCRIP} library version])
+        AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$7], [Define to indicate the ${$1_DESCRIP} library version])
       fi
    fi
 fi
 ])
 
 
+# Check for a package using $2-config. Similar to AST_EXT_LIB_CHECK,
+# but use $2-config to determine cflags and libraries to use.
+# $3 and $4 can be used to replace --cflags and --libs in the request
+
+# AST_EXT_TOOL_CHECK([package], [tool name], [--cflags], [--libs], [includes], [expression])
+AC_DEFUN([AST_EXT_TOOL_CHECK],
+[
+    if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+       PBX_$1=0
+       AC_CHECK_TOOL(CONFIG_$1, $2-config, No)
+       if test ! "x${CONFIG_$1}" = xNo; then
+           if test x"$3" = x ; then A=--cflags ; else A="$3" ; fi
+           $1_INCLUDE=$(${CONFIG_$1} $A)
+           if test x"$4" = x ; then A=--libs ; else A="$4" ; fi
+           $1_LIB=$(${CONFIG_$1} $A)
+           if test x"$5" != x ; then
+               saved_cppflags="${CPPFLAGS}"
+               if test "x${$1_DIR}" != "x"; then
+                   $1_INCLUDE="-I${$1_DIR}/include"
+               fi
+               CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+
+               saved_ldflags="${LDFLAGS}"
+               LDFLAGS="${$1_LIB}"
+
+               AC_LINK_IFELSE(
+                   [ AC_LANG_PROGRAM( [ $5 ],
+                                      [ $6; ]
+                                      )],
+                   [   PBX_$1=1
+                       AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
+                   ],
+                   []
+               )
+               CPPFLAGS="${saved_cppflags}"
+               LDFLAGS="${saved_ldflags}"
+           else
+               PBX_$1=1
+               AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 libraries.])
+           fi
+       fi
+    fi
+])
+
 AC_DEFUN(
 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
    GNU_MAKE='Not Found' ;
@@ -179,42 +288,53 @@ AC_DEFUN(
 [AST_CHECK_PWLIB], [
 PWLIB_INCDIR=
 PWLIB_LIBDIR=
+AC_LANG_PUSH([C++])
 if test "${PWLIBDIR:-unset}" != "unset" ; then
-  AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
+  AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
 fi
 if test "${HAS_PWLIB:-unset}" = "unset" ; then
   if test "${OPENH323DIR:-unset}" != "unset"; then
-    AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
+    AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
   fi
   if test "${HAS_PWLIB:-unset}" != "unset" ; then
     PWLIBDIR="${OPENH323DIR}/../pwlib"
   else
-    AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
+    AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
     if test "${HAS_PWLIB:-unset}" != "unset" ; then
       PWLIBDIR="${HOME}/pwlib"
     else
-      AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
+      AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
       if test "${HAS_PWLIB:-unset}" != "unset" ; then
         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
         if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
         fi
         PWLIB_INCDIR="/usr/local/include"
-        if test "x$LIB64" != "x"; then
-          PWLIB_LIBDIR="/usr/local/lib64"
-        else
-          PWLIB_LIBDIR="/usr/local/lib"
+        PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
+        if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
+          if test "x$LIB64" != "x"; then
+            PWLIB_LIBDIR="/usr/local/lib64"
+          else
+            PWLIB_LIBDIR="/usr/local/lib"
+          fi
         fi
+        PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
+        PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
       else
-        AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
+        AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
         if test "${HAS_PWLIB:-unset}" != "unset" ; then
           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
           PWLIB_INCDIR="/usr/include"
-          if test "x$LIB64" != "x"; then
-               PWLIB_LIBDIR="/usr/lib64"
-          else
-               PWLIB_LIBDIR="/usr/lib"
-             fi
+          PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
+          if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
+            if test "x$LIB64" != "x"; then
+              PWLIB_LIBDIR="/usr/lib64"
+            else
+              PWLIB_LIBDIR="/usr/lib"
+            fi
+          fi
+          PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
+          PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
         fi
       fi
     fi
@@ -266,6 +386,7 @@ if test "${HAS_PWLIB:-unset}" != "unset" ; then
   AC_SUBST([PWLIB_INCDIR])
   AC_SUBST([PWLIB_LIBDIR])
 fi
+  AC_LANG_POP([C++])
 ])
 
 
@@ -360,20 +481,30 @@ AC_DEFUN(
 [AST_CHECK_OPENH323], [
 OPENH323_INCDIR=
 OPENH323_LIBDIR=
+AC_LANG_PUSH([C++])
 if test "${OPENH323DIR:-unset}" != "unset" ; then
-  AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
+  AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
 fi
 if test "${HAS_OPENH323:-unset}" = "unset" ; then
-  AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
+  AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
   if test "${HAS_OPENH323:-unset}" != "unset" ; then
     OPENH323DIR="${PWLIBDIR}/../openh323"
-    AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
+    saved_cppflags="${CPPFLAGS}"
+    CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
+    AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
+    CPPFLAGS="${saved_cppflags}"
   else
-    AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
+    saved_cppflags="${CPPFLAGS}"
+    CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
+    AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
+    CPPFLAGS="${saved_cppflags}"
     if test "${HAS_OPENH323:-unset}" != "unset" ; then
       OPENH323DIR="${HOME}/openh323"
     else
-      AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
+      saved_cppflags="${CPPFLAGS}"
+      CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
+      AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
+      CPPFLAGS="${saved_cppflags}"
       if test "${HAS_OPENH323:-unset}" != "unset" ; then
         OPENH323DIR="/usr/local/share/openh323"
         OPENH323_INCDIR="/usr/local/include/openh323"
@@ -383,7 +514,10 @@ if test "${HAS_OPENH323:-unset}" = "unset" ; then
           OPENH323_LIBDIR="/usr/local/lib"
         fi
       else
-        AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
+        saved_cppflags="${CPPFLAGS}"
+        CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
+        AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
+        CPPFLAGS="${saved_cppflags}"
         if test "${HAS_OPENH323:-unset}" != "unset" ; then
           OPENH323DIR="/usr/share/openh323"
           OPENH323_INCDIR="/usr/include/openh323"
@@ -406,10 +540,15 @@ if test "${HAS_OPENH323:-unset}" != "unset" ; then
     OPENH323_LIBDIR="${OPENH323DIR}/lib"
   fi
 
+  OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
+  OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
+  OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
+
   AC_SUBST([OPENH323DIR])
   AC_SUBST([OPENH323_INCDIR])
   AC_SUBST([OPENH323_LIBDIR])
 fi
+  AC_LANG_POP([C++])
 ])
 
 
@@ -441,7 +580,11 @@ AC_DEFUN(
 
           saved_cppflags="${CPPFLAGS}"
           saved_libs="${LIBS}"
-          LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
+          if test "${$2_LIB:-unset}" != "unset"; then
+             LIBS="${LIBS} ${$2_LIB} $7"
+          else
+             LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
+          fi
           CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
 
           AC_LANG_PUSH([C++])
@@ -462,10 +605,12 @@ AC_DEFUN(
           CPPFLAGS="${saved_cppflags}"
 
           if test "${ac_cv_lib_$2}" = "yes"; then
-             if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
-                $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
-             else
-                $2_LIB="-l${PLATFORM_$2}"
+             if test "${$2_LIB:-undef}" = "undef"; then
+                if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
+                   $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
+                else
+                   $2_LIB="-l${PLATFORM_$2}"
+                fi
              fi
              if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
                 $2_INCLUDE="-I${$2_INCDIR}"
@@ -481,18 +626,25 @@ AC_DEFUN(
        if test "${HAS_OPENH323:-unset}" != "unset"; then
                AC_MSG_CHECKING(OpenH323 build option)
                OPENH323_SUFFIX=
-               files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
-               libfile=
-               if test -n "$files"; then
-                       for f in $files; do
-                               if test -f $f -a ! -L $f; then
-                                       libfile=`basename $f`
-                                       break;
-                               fi
-                       done
-               fi
+               prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
+               for pfx in $prefixes; do
+                       files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
+                       libfile=
+                       if test -n "$files"; then
+                               for f in $files; do
+                                       if test -f $f -a ! -L $f; then
+                                               libfile=`basename $f`
+                                               break;
+                                       fi
+                               done
+                       fi
+                       if test -n "$libfile"; then
+                               OPENH323_PREFIX=$pfx
+                               break;
+                       fi
+               done
                if test "${libfile:-unset}" != "unset"; then
-                       OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
+                       OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
                fi
                case "${OPENH323_SUFFIX}" in
                        n)
@@ -502,7 +654,21 @@ AC_DEFUN(
                        d)
                                OPENH323_BUILD="debug";;
                        *)
-                               OPENH323_BUILD="notrace";;
+                               if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
+                                       notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@      @:>@*=@<:@      @:>@*//'"`
+                                       if test "x$notrace" = "x"; then
+                                               notrace="0"
+                                       fi
+                                       if test "$notrace" -ne 0; then
+                                               OPENH323_BUILD="notrace"
+                                       else
+                                               OPENH323_BUILD="opt"
+                                       fi
+                                       OPENH323_LIB="-l${OPENH323_PREFIX}"
+                               else
+                                       OPENH323_BUILD="notrace"
+                               fi
+                               ;;
                esac
                AC_MSG_RESULT(${OPENH323_BUILD})
 
@@ -527,7 +693,7 @@ else
 fi
 if test "x$ac_cv_func_fork_works" = xcross; then
   case $host in
-    *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
+    *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* )
       # Override, as these systems have only a dummy fork() stub
       ac_cv_func_fork_works=no
       ;;
@@ -756,7 +922,8 @@ dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
 dnl @version 2006-05-29
 dnl @license GPLWithACException
 
-AC_DEFUN([ACX_PTHREAD], [
+AC_DEFUN([ACX_PTHREAD],
+[
 AC_REQUIRE([AC_CANONICAL_HOST])
 AC_LANG_SAVE
 AC_LANG_C