Merged revisions 151240 via svnmerge from
[asterisk/asterisk.git] / autoconf / ast_check_openh323.m4
1 AC_DEFUN([AST_CHECK_OPENH323_PLATFORM], [
2 PWLIB_OSTYPE=
3 case "$host_os" in
4   linux*)          PWLIB_OSTYPE=linux ;
5                 ;;
6   freebsd* )       PWLIB_OSTYPE=FreeBSD ;
7                 ;;
8   openbsd* )       PWLIB_OSTYPE=OpenBSD ;
9                                    ENDLDLIBS="-lossaudio" ;
10                 ;;
11   netbsd* )        PWLIB_OSTYPE=NetBSD ;
12                                    ENDLDLIBS="-lossaudio" ;
13                 ;;
14   solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
15                 ;;
16   darwin* )            PWLIB_OSTYPE=Darwin ;
17                 ;;
18   beos*)           PWLIB_OSTYPE=beos ;
19                    STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
20                 ;;
21   cygwin*)         PWLIB_OSTYPE=cygwin ;
22                 ;;
23   mingw*)              PWLIB_OSTYPE=mingw ;
24                            STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
25                            ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
26                 ;;
27   * )                  PWLIB_OSTYPE="$host_os" ;
28                            AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
29                 ;;
30 esac
31
32 PWLIB_MACHTYPE=
33 case "$host_cpu" in
34    x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
35                    ;;
36
37    x86_64)         PWLIB_MACHTYPE=x86_64 ;
38                    P_64BIT=1 ;
39                    LIB64=1 ;
40                    ;;
41
42    alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
43                    P_64BIT=1 ;
44                    ;;
45
46    sparc )         PWLIB_MACHTYPE=sparc ;
47                    ;;
48
49    powerpc )       PWLIB_MACHTYPE=ppc ;
50                    ;;
51
52    ppc )           PWLIB_MACHTYPE=ppc ;
53                    ;;
54
55    powerpc64 )     PWLIB_MACHTYPE=ppc64 ;
56                    P_64BIT=1 ;
57                    LIB64=1 ;
58                    ;;
59
60    ppc64 )         PWLIB_MACHTYPE=ppc64 ;
61                    P_64BIT=1 ;
62                    LIB64=1 ;
63                    ;;
64
65    ia64)           PWLIB_MACHTYPE=ia64 ;
66                    P_64BIT=1 ;
67                    ;;
68
69    s390x)          PWLIB_MACHTYPE=s390x ;
70                    P_64BIT=1 ;
71                    LIB64=1 ;
72                    ;;
73
74    s390)           PWLIB_MACHTYPE=s390 ;
75                    ;;
76
77    * )             PWLIB_MACHTYPE="$host_cpu";
78                    AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
79 esac
80
81 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
82
83 AC_SUBST([PWLIB_PLATFORM])
84 ])
85
86 AC_DEFUN([AST_CHECK_OPENH323], [
87 OPENH323_INCDIR=
88 OPENH323_LIBDIR=
89 AC_LANG_PUSH([C++])
90 if test "${OPENH323DIR:-unset}" != "unset" ; then
91   AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
92 fi
93 if test "${HAS_OPENH323:-unset}" = "unset" ; then
94   AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
95   if test "${HAS_OPENH323:-unset}" != "unset" ; then
96     OPENH323DIR="${PWLIBDIR}/../openh323"
97     saved_cppflags="${CPPFLAGS}"
98     CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
99     AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
100     CPPFLAGS="${saved_cppflags}"
101   else
102     saved_cppflags="${CPPFLAGS}"
103     CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
104     AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
105     CPPFLAGS="${saved_cppflags}"
106     if test "${HAS_OPENH323:-unset}" != "unset" ; then
107       OPENH323DIR="${HOME}/openh323"
108     else
109       saved_cppflags="${CPPFLAGS}"
110       CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
111       AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
112       CPPFLAGS="${saved_cppflags}"
113       if test "${HAS_OPENH323:-unset}" != "unset" ; then
114         OPENH323DIR="/usr/local/share/openh323"
115         OPENH323_INCDIR="/usr/local/include/openh323"
116         if test "x$LIB64" != "x"; then
117           OPENH323_LIBDIR="/usr/local/lib64"
118         else
119           OPENH323_LIBDIR="/usr/local/lib"
120         fi
121       else
122         saved_cppflags="${CPPFLAGS}"
123         CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
124         AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
125         CPPFLAGS="${saved_cppflags}"
126         if test "${HAS_OPENH323:-unset}" != "unset" ; then
127           OPENH323DIR="/usr/share/openh323"
128           OPENH323_INCDIR="/usr/include/openh323"
129           if test "x$LIB64" != "x"; then
130             OPENH323_LIBDIR="/usr/lib64"
131           else
132             OPENH323_LIBDIR="/usr/lib"
133           fi
134         fi
135       fi
136     fi
137   fi
138 fi
139
140 if test "${HAS_OPENH323:-unset}" != "unset" ; then
141   if test "${OPENH323_INCDIR:-unset}" = "unset"; then
142     OPENH323_INCDIR="${OPENH323DIR}/include"
143   fi
144   if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
145     OPENH323_LIBDIR="${OPENH323DIR}/lib"
146   fi
147
148   OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
149   OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
150   OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
151
152   AC_SUBST([OPENH323DIR])
153   AC_SUBST([OPENH323_INCDIR])
154   AC_SUBST([OPENH323_LIBDIR])
155 fi
156   AC_LANG_POP([C++])
157 ])
158
159 AC_DEFUN([AST_CHECK_OPENH323_BUILD], [
160         if test "${HAS_OPENH323:-unset}" != "unset"; then
161                 AC_MSG_CHECKING(OpenH323 build option)
162                 OPENH323_SUFFIX=
163                 prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
164                 for pfx in $prefixes; do
165                         files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
166                         libfile=
167                         if test -n "$files"; then
168                                 for f in $files; do
169                                         if test -f $f -a ! -L $f; then
170                                                 libfile=`basename $f`
171                                                 break;
172                                         fi
173                                 done
174                         fi
175                         if test -n "$libfile"; then
176                                 OPENH323_PREFIX=$pfx
177                                 break;
178                         fi
179                 done
180                 if test "${libfile:-unset}" != "unset"; then
181                         OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
182                 fi
183                 case "${OPENH323_SUFFIX}" in
184                         n)
185                                 OPENH323_BUILD="notrace";;
186                         r)
187                                 OPENH323_BUILD="opt";;
188                         d)
189                                 OPENH323_BUILD="debug";;
190                         *)
191                                 if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
192                                         notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@      @:>@*=@<:@      @:>@*//'"`
193                                         if test "x$notrace" = "x"; then
194                                                 notrace="0"
195                                         fi
196                                         if test "$notrace" -ne 0; then
197                                                 OPENH323_BUILD="notrace"
198                                         else
199                                                 OPENH323_BUILD="opt"
200                                         fi
201                                         OPENH323_LIB="-l${OPENH323_PREFIX}"
202                                 else
203                                         OPENH323_BUILD="notrace"
204                                 fi
205                                 ;;
206                 esac
207                 AC_MSG_RESULT(${OPENH323_BUILD})
208
209                 AC_SUBST([OPENH323_SUFFIX])
210                 AC_SUBST([OPENH323_BUILD])
211         fi
212 ])