Add new object for VoicemailUserEntry
[asterisk/asterisk.git] / autoconf / ast_check_pwlib.m4
1 AC_DEFUN([AST_CHECK_PWLIB_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_PWLIB], [
87 PWLIB_INCDIR=
88 PWLIB_LIBDIR=
89 AC_LANG_PUSH([C++])
90 if test "${PWLIBDIR:-unset}" != "unset" ; then
91   AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
92 fi
93 if test "${HAS_PWLIB:-unset}" = "unset" ; then
94   if test "${OPENH323DIR:-unset}" != "unset"; then
95     AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
96   fi
97   if test "${HAS_PWLIB:-unset}" != "unset" ; then
98     PWLIBDIR="${OPENH323DIR}/../pwlib"
99   else
100     AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
101     if test "${HAS_PWLIB:-unset}" != "unset" ; then
102       PWLIBDIR="${HOME}/pwlib"
103     else
104       AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
105       if test "${HAS_PWLIB:-unset}" != "unset" ; then
106         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin$PATH_SEPARATOR/usr/local/share/pwlib/make)
107         PWLIB_INCDIR="/usr/local/include"
108         PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
109         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
110           PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
111         fi
112         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
113           if test "x$LIB64" != "x"; then
114             PWLIB_LIBDIR="/usr/local/lib64"
115           else
116             PWLIB_LIBDIR="/usr/local/lib"
117           fi
118         fi
119         PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
120         PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
121       else
122         AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
123         if test "${HAS_PWLIB:-unset}" != "unset" ; then
124           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/bin$PATH_SEPARATOR/usr/share/pwlib/make)
125           PWLIB_INCDIR="/usr/include"
126           PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
127           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
128             PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
129           fi
130           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
131             if test "x$LIB64" != "x"; then
132               PWLIB_LIBDIR="/usr/lib64"
133             else
134               PWLIB_LIBDIR="/usr/lib"
135             fi
136           fi
137           PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
138           PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
139         fi
140       fi
141     fi
142   fi
143 fi
144
145 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
146 #  echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
147 #  exit
148 #fi
149
150 if test "${HAS_PWLIB:-unset}" != "unset" ; then
151   if test "${PWLIBDIR:-unset}" = "unset" ; then
152     if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
153       PWLIBDIR=`$PTLIB_CONFIG --prefix`
154     else
155       echo "Cannot find ptlib-config - please install and try again"
156       exit
157     fi
158   fi
159
160   if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
161     PWLIBDIR="/usr/share/pwlib"
162     PWLIB_INCDIR="/usr/include"
163     if test "x$LIB64" != "x"; then
164       PWLIB_LIBDIR="/usr/lib64"
165     else
166       PWLIB_LIBDIR="/usr/lib"
167     fi
168   fi
169   if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
170     PWLIBDIR="/usr/local/share/pwlib"
171     PWLIB_INCDIR="/usr/local/include"
172     if test "x$LIB64" != "x"; then
173       PWLIB_LIBDIR="/usr/local/lib64"
174     else
175       PWLIB_LIBDIR="/usr/local/lib"
176     fi
177   fi
178
179   if test "${PWLIB_INCDIR:-unset}" = "unset"; then
180     PWLIB_INCDIR="${PWLIBDIR}/include"
181   fi
182   if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
183     PWLIB_LIBDIR="${PWLIBDIR}/lib"
184   fi
185
186   AC_SUBST([PWLIBDIR])
187   AC_SUBST([PWLIB_INCDIR])
188   AC_SUBST([PWLIB_LIBDIR])
189 fi
190   AC_LANG_POP([C++])
191 ])
192
193 AC_DEFUN([AST_CHECK_PWLIB_VERSION], [
194         VNAME="m4_default([$7],[$2_VERSION])"
195
196         if test "${HAS_$2:-unset}" != "unset"; then
197                 $2_VERSION=`grep "$VNAME \"" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
198                 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
199                 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
200                 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
201                 $2_VER=$((${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}))
202                 $2_REQ=$(($4*10000+$5*100+$6))
203                 $2_MAX=m4_ifblank([$10], [9999999], [$(($8*10000+$9*100+$10))])
204
205                 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
206                 if test ${$2_VER} -lt ${$2_REQ}; then
207                         AC_MSG_RESULT(no)
208                         unset HAS_$2
209                 else
210                         if test ${$2_VER} -gt ${$2_MAX}; then
211                                 AC_MSG_RESULT(no)
212                                 unset HAS_$2
213                         else
214                                 AC_MSG_RESULT(yes)
215                         fi
216                 fi
217         fi
218 ])
219
220 AC_DEFUN([AST_CHECK_PWLIB_BUILD], [
221         if test "${HAS_$2:-unset}" != "unset"; then
222            AC_MSG_CHECKING($1 installation validity)
223
224            saved_cppflags="${CPPFLAGS}"
225            saved_libs="${LIBS}"
226            if test "${$2_LIB:-unset}" != "unset"; then
227               LIBS="${LIBS} ${$2_LIB} $7"
228            else
229               LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
230            fi
231            CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
232
233            AC_LANG_PUSH([C++])
234
235            AC_LINK_IFELSE(
236                 [AC_LANG_PROGRAM([$4],[$5])],
237                 [       AC_MSG_RESULT(yes) 
238                         ac_cv_lib_$2="yes" 
239                 ],
240                 [       AC_MSG_RESULT(no) 
241                         ac_cv_lib_$2="no" 
242                 ]
243                 )
244
245            AC_LANG_POP([C++])
246
247            LIBS="${saved_libs}"
248            CPPFLAGS="${saved_cppflags}"
249
250            if test "${ac_cv_lib_$2}" = "yes"; then
251               if test "${$2_LIB:-undef}" = "undef"; then
252                  if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
253                     $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
254                  else
255                     $2_LIB="-l${PLATFORM_$2}"
256                  fi
257               fi
258               if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
259                  $2_INCLUDE="-I${$2_INCDIR}"
260               fi
261                   PBX_$2=1
262                   AC_DEFINE([HAVE_$2], 1, [$3])
263            fi
264         fi
265 ])