Blocked revisions 210067 via svnmerge
[asterisk/asterisk.git] / autoconf / ast_check_pwlib.m4
index 2bd080c..f92fb2c 100644 (file)
@@ -1,3 +1,88 @@
+AC_DEFUN([AST_CHECK_PWLIB_PLATFORM], [
+PWLIB_OSTYPE=
+case "$host_os" in
+  linux*)          PWLIB_OSTYPE=linux ;
+               ;;
+  freebsd* )       PWLIB_OSTYPE=FreeBSD ;
+               ;;
+  openbsd* )       PWLIB_OSTYPE=OpenBSD ;
+                                  ENDLDLIBS="-lossaudio" ;
+               ;;
+  netbsd* )        PWLIB_OSTYPE=NetBSD ;
+                                  ENDLDLIBS="-lossaudio" ;
+               ;;
+  solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
+               ;;
+  darwin* )           PWLIB_OSTYPE=Darwin ;
+               ;;
+  beos*)           PWLIB_OSTYPE=beos ;
+                   STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
+               ;;
+  cygwin*)         PWLIB_OSTYPE=cygwin ;
+               ;;
+  mingw*)             PWLIB_OSTYPE=mingw ;
+                          STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
+                          ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
+               ;;
+  * )                 PWLIB_OSTYPE="$host_os" ;
+                          AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
+               ;;
+esac
+
+PWLIB_MACHTYPE=
+case "$host_cpu" in
+   x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
+                   ;;
+
+   x86_64)        PWLIB_MACHTYPE=x86_64 ;
+                  P_64BIT=1 ;
+                   LIB64=1 ;
+                  ;;
+
+   alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
+                  P_64BIT=1 ;
+                  ;;
+
+   sparc )         PWLIB_MACHTYPE=sparc ;
+                  ;;
+
+   powerpc )       PWLIB_MACHTYPE=ppc ;
+                  ;;
+
+   ppc )           PWLIB_MACHTYPE=ppc ;
+                  ;;
+
+   powerpc64 )     PWLIB_MACHTYPE=ppc64 ;
+                  P_64BIT=1 ;
+                   LIB64=1 ;
+                  ;;
+
+   ppc64 )         PWLIB_MACHTYPE=ppc64 ;
+                  P_64BIT=1 ;
+                   LIB64=1 ;
+                  ;;
+
+   ia64)          PWLIB_MACHTYPE=ia64 ;
+                  P_64BIT=1 ;
+                  ;;
+
+   s390x)         PWLIB_MACHTYPE=s390x ;
+                  P_64BIT=1 ;
+                   LIB64=1 ;
+                  ;;
+
+   s390)          PWLIB_MACHTYPE=s390 ;
+                  ;;
+
+   * )            PWLIB_MACHTYPE="$host_cpu";
+                  AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
+esac
+
+PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
+
+AC_SUBST([PWLIB_PLATFORM])
+])
+
 AC_DEFUN([AST_CHECK_PWLIB], [
 PWLIB_INCDIR=
 PWLIB_LIBDIR=
@@ -18,12 +103,12 @@ if test "${HAS_PWLIB:-unset}" = "unset" ; then
     else
       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
+        AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin$PATH_SEPARATOR/usr/local/share/pwlib/make)
         PWLIB_INCDIR="/usr/local/include"
-        PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
+        PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
+        if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
+          PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
+        fi
         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
           if test "x$LIB64" != "x"; then
             PWLIB_LIBDIR="/usr/local/lib64"
@@ -36,9 +121,12 @@ if test "${HAS_PWLIB:-unset}" = "unset" ; then
       else
         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)
+          AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/bin$PATH_SEPARATOR/usr/share/pwlib/make)
           PWLIB_INCDIR="/usr/include"
-          PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
+          PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
+          if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
+            PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
+          fi
           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
             if test "x$LIB64" != "x"; then
               PWLIB_LIBDIR="/usr/lib64"
@@ -103,8 +191,14 @@ fi
 ])
 
 AC_DEFUN([AST_CHECK_PWLIB_VERSION], [
+       if test "x$7" != "x"; then
+               VNAME="$7"
+               else
+               VNAME="$2_VERSION"
+       fi
+
        if test "${HAS_$2:-unset}" != "unset"; then
-               $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
+               $2_VERSION=`grep "$VNAME" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
                $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
                $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
                $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`