Macro AST_PKG_CONFIG_CHECK to use chkconfig
[asterisk/asterisk.git] / autoconf / ast_check_openh323.m4
1 AC_DEFUN([AST_CHECK_OPENH323], [
2 OPENH323_INCDIR=
3 OPENH323_LIBDIR=
4 AC_LANG_PUSH([C++])
5 if test "${OPENH323DIR:-unset}" != "unset" ; then
6   AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
7 fi
8 if test "${HAS_OPENH323:-unset}" = "unset" ; then
9   AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
10   if test "${HAS_OPENH323:-unset}" != "unset" ; then
11     OPENH323DIR="${PWLIBDIR}/../openh323"
12     saved_cppflags="${CPPFLAGS}"
13     CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
14     AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
15     CPPFLAGS="${saved_cppflags}"
16   else
17     saved_cppflags="${CPPFLAGS}"
18     CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
19     AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
20     CPPFLAGS="${saved_cppflags}"
21     if test "${HAS_OPENH323:-unset}" != "unset" ; then
22       OPENH323DIR="${HOME}/openh323"
23     else
24       saved_cppflags="${CPPFLAGS}"
25       CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
26       AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
27       CPPFLAGS="${saved_cppflags}"
28       if test "${HAS_OPENH323:-unset}" != "unset" ; then
29         OPENH323DIR="/usr/local/share/openh323"
30         OPENH323_INCDIR="/usr/local/include/openh323"
31         if test "x$LIB64" != "x" && test -d "/usr/local/lib64"; then
32           OPENH323_LIBDIR="/usr/local/lib64"
33         else
34           OPENH323_LIBDIR="/usr/local/lib"
35         fi
36       else
37         saved_cppflags="${CPPFLAGS}"
38         CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
39         AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
40         CPPFLAGS="${saved_cppflags}"
41         if test "${HAS_OPENH323:-unset}" != "unset" ; then
42           OPENH323DIR="/usr/share/openh323"
43           OPENH323_INCDIR="/usr/include/openh323"
44           if test "x$LIB64" != "x" && test -d "/usr/local/lib64"; then
45             OPENH323_LIBDIR="/usr/lib64"
46           else
47             OPENH323_LIBDIR="/usr/lib"
48           fi
49         fi
50       fi
51     fi
52   fi
53 fi
54
55 if test "${HAS_OPENH323:-unset}" != "unset" ; then
56   if test "${OPENH323_INCDIR:-unset}" = "unset"; then
57     OPENH323_INCDIR="${OPENH323DIR}/include"
58   fi
59   if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
60     OPENH323_LIBDIR="${OPENH323DIR}/lib"
61   fi
62
63   OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
64   OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
65   OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
66
67   AC_SUBST([OPENH323DIR])
68   AC_SUBST([OPENH323_INCDIR])
69   AC_SUBST([OPENH323_LIBDIR])
70 fi
71   AC_LANG_POP([C++])
72 ])
73
74 AC_DEFUN([AST_CHECK_OPENH323_BUILD], [
75         if test "${HAS_OPENH323:-unset}" != "unset"; then
76                 AC_MSG_CHECKING(OpenH323 build option)
77                 OPENH323_SUFFIX=
78                 prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
79                 for pfx in $prefixes; do
80                         #files=`ls -l /usr/local/lib/lib${pfx}*.so* 2>/dev/null`
81                         files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
82                         if test -z "$files"; then
83                                 # check the default location
84                                 files=`ls -l /usr/local/lib/lib${pfx}*.so* 2>/dev/null`
85                         fi
86                         libfile=
87                         if test -n "$files"; then
88                                 for f in $files; do
89                                         if test -f $f -a ! -L $f; then
90                                                 libfile=`basename $f`
91                                                 break;
92                                         fi
93                                 done
94                         fi
95                         if test -n "$libfile"; then
96                                 OPENH323_PREFIX=$pfx
97                                 break;
98                         fi
99                 done
100                 if test "${libfile:-unset}" != "unset"; then
101                         OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
102                 fi
103                 case "${OPENH323_SUFFIX}" in
104                         n)
105                                 OPENH323_BUILD="notrace";;
106                         r)
107                                 OPENH323_BUILD="opt";;
108                         d)
109                                 OPENH323_BUILD="debug";;
110                         *)
111                                 if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
112                                         notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@      @:>@*=@<:@      @:>@*//'"`
113                                         if test "x$notrace" = "x"; then
114                                                 notrace="0"
115                                         fi
116                                         if test "$notrace" -ne 0; then
117                                                 OPENH323_BUILD="notrace"
118                                         else
119                                                 OPENH323_BUILD="opt"
120                                         fi
121                                         OPENH323_LIB="-l${OPENH323_PREFIX}"
122                                 else
123                                         OPENH323_BUILD="notrace"
124                                 fi
125                                 ;;
126                 esac
127                 AC_MSG_RESULT(${OPENH323_BUILD})
128
129                 AC_SUBST([OPENH323_SUFFIX])
130                 AC_SUBST([OPENH323_BUILD])
131         fi
132 ])