Add in check for the GCC attribute deprecated. It may be used soon!
[asterisk/asterisk.git] / acinclude.m4
index 093bfb3..1363a9e 100644 (file)
@@ -34,6 +34,7 @@ esac
 PBX_$1=0
 AC_SUBST([$1_LIB])
 AC_SUBST([$1_INCLUDE])
+AC_SUBST([$1_DIR])
 AC_SUBST([PBX_$1])
 ])
 
@@ -76,7 +77,7 @@ AC_DEFUN([AST_C_DEFINE_CHECK],
        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}"
 
@@ -178,42 +179,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
@@ -265,6 +277,7 @@ if test "${HAS_PWLIB:-unset}" != "unset" ; then
   AC_SUBST([PWLIB_INCDIR])
   AC_SUBST([PWLIB_LIBDIR])
 fi
+  AC_LANG_POP([C++])
 ])
 
 
@@ -359,20 +372,21 @@ 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}")
+    AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
   else
-    AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
+    AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
     if test "${HAS_OPENH323:-unset}" != "unset" ; then
       OPENH323DIR="${HOME}/openh323"
     else
-      AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
+      AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
       if test "${HAS_OPENH323:-unset}" != "unset" ; then
         OPENH323DIR="/usr/local/share/openh323"
         OPENH323_INCDIR="/usr/local/include/openh323"
@@ -382,7 +396,7 @@ 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, )
+        AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
         if test "${HAS_OPENH323:-unset}" != "unset" ; then
           OPENH323DIR="/usr/share/openh323"
           OPENH323_INCDIR="/usr/include/openh323"
@@ -405,10 +419,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++])
 ])
 
 
@@ -440,7 +459,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++])
@@ -461,10 +484,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}"
@@ -480,18 +505,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)
@@ -501,7 +533,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})
 
@@ -526,7 +572,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
       ;;