ast_check_pwlib.m4 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. PWLIB_MACHTYPE=
  32. case "$host_cpu" in
  33. x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
  34. ;;
  35. x86_64) PWLIB_MACHTYPE=x86_64 ;
  36. P_64BIT=1 ;
  37. LIB64=1 ;
  38. ;;
  39. alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
  40. P_64BIT=1 ;
  41. ;;
  42. sparc ) PWLIB_MACHTYPE=sparc ;
  43. ;;
  44. powerpc ) PWLIB_MACHTYPE=ppc ;
  45. ;;
  46. ppc ) PWLIB_MACHTYPE=ppc ;
  47. ;;
  48. powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
  49. P_64BIT=1 ;
  50. LIB64=1 ;
  51. ;;
  52. ppc64 ) PWLIB_MACHTYPE=ppc64 ;
  53. P_64BIT=1 ;
  54. LIB64=1 ;
  55. ;;
  56. ia64) PWLIB_MACHTYPE=ia64 ;
  57. P_64BIT=1 ;
  58. ;;
  59. s390x) PWLIB_MACHTYPE=s390x ;
  60. P_64BIT=1 ;
  61. LIB64=1 ;
  62. ;;
  63. s390) PWLIB_MACHTYPE=s390 ;
  64. ;;
  65. * ) PWLIB_MACHTYPE="$host_cpu";
  66. AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
  67. esac
  68. PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
  69. AC_SUBST([PWLIB_PLATFORM])
  70. ])
  71. AC_DEFUN([AST_CHECK_PWLIB], [
  72. PWLIB_INCDIR=
  73. PWLIB_LIBDIR=
  74. AC_LANG_PUSH([C++])
  75. if test "${PWLIBDIR:-unset}" != "unset" ; then
  76. AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
  77. fi
  78. if test "${HAS_PWLIB:-unset}" = "unset" ; then
  79. if test "${OPENH323DIR:-unset}" != "unset"; then
  80. AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
  81. fi
  82. if test "${HAS_PWLIB:-unset}" != "unset" ; then
  83. PWLIBDIR="${OPENH323DIR}/../pwlib"
  84. else
  85. AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
  86. if test "${HAS_PWLIB:-unset}" != "unset" ; then
  87. PWLIBDIR="${HOME}/pwlib"
  88. else
  89. AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
  90. if test "${HAS_PWLIB:-unset}" != "unset" ; then
  91. AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin$PATH_SEPARATOR/usr/local/share/pwlib/make)
  92. PWLIB_INCDIR="/usr/local/include"
  93. PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
  94. if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
  95. PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
  96. fi
  97. if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
  98. if test "x$LIB64" != "x"; then
  99. PWLIB_LIBDIR="/usr/local/lib64"
  100. else
  101. PWLIB_LIBDIR="/usr/local/lib"
  102. fi
  103. fi
  104. PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
  105. PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
  106. else
  107. AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
  108. if test "${HAS_PWLIB:-unset}" != "unset" ; then
  109. AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/bin$PATH_SEPARATOR/usr/share/pwlib/make)
  110. PWLIB_INCDIR="/usr/include"
  111. PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
  112. if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
  113. PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
  114. fi
  115. if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
  116. if test "x$LIB64" != "x"; then
  117. PWLIB_LIBDIR="/usr/lib64"
  118. else
  119. PWLIB_LIBDIR="/usr/lib"
  120. fi
  121. fi
  122. PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
  123. PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
  124. fi
  125. fi
  126. fi
  127. fi
  128. fi
  129. #if test "${HAS_PWLIB:-unset}" = "unset" ; then
  130. # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
  131. # exit
  132. #fi
  133. if test "${HAS_PWLIB:-unset}" != "unset" ; then
  134. if test "${PWLIBDIR:-unset}" = "unset" ; then
  135. if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
  136. PWLIBDIR=`$PTLIB_CONFIG --prefix`
  137. else
  138. echo "Cannot find ptlib-config - please install and try again"
  139. exit
  140. fi
  141. fi
  142. if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
  143. PWLIBDIR="/usr/share/pwlib"
  144. PWLIB_INCDIR="/usr/include"
  145. if test "x$LIB64" != "x"; then
  146. PWLIB_LIBDIR="/usr/lib64"
  147. else
  148. PWLIB_LIBDIR="/usr/lib"
  149. fi
  150. fi
  151. if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
  152. PWLIBDIR="/usr/local/share/pwlib"
  153. PWLIB_INCDIR="/usr/local/include"
  154. if test "x$LIB64" != "x"; then
  155. PWLIB_LIBDIR="/usr/local/lib64"
  156. else
  157. PWLIB_LIBDIR="/usr/local/lib"
  158. fi
  159. fi
  160. if test "${PWLIB_INCDIR:-unset}" = "unset"; then
  161. PWLIB_INCDIR="${PWLIBDIR}/include"
  162. fi
  163. if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
  164. PWLIB_LIBDIR="${PWLIBDIR}/lib"
  165. fi
  166. AC_SUBST([PWLIBDIR])
  167. AC_SUBST([PWLIB_INCDIR])
  168. AC_SUBST([PWLIB_LIBDIR])
  169. fi
  170. AC_LANG_POP([C++])
  171. ])
  172. AC_DEFUN([AST_CHECK_PWLIB_VERSION], [
  173. if test "x$7" != "x"; then
  174. VNAME="$7"
  175. else
  176. VNAME="$2_VERSION"
  177. fi
  178. if test "${HAS_$2:-unset}" != "unset"; then
  179. $2_VERSION=`grep "$VNAME" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
  180. $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
  181. $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
  182. $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
  183. let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
  184. let $2_REQ=$4*10000+$5*100+$6
  185. AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
  186. if test ${$2_VER} -lt ${$2_REQ}; then
  187. AC_MSG_RESULT(no)
  188. unset HAS_$2
  189. else
  190. AC_MSG_RESULT(yes)
  191. fi
  192. fi
  193. ])
  194. AC_DEFUN([AST_CHECK_PWLIB_BUILD], [
  195. if test "${HAS_$2:-unset}" != "unset"; then
  196. AC_MSG_CHECKING($1 installation validity)
  197. saved_cppflags="${CPPFLAGS}"
  198. saved_libs="${LIBS}"
  199. if test "${$2_LIB:-unset}" != "unset"; then
  200. LIBS="${LIBS} ${$2_LIB} $7"
  201. else
  202. LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
  203. fi
  204. CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
  205. AC_LANG_PUSH([C++])
  206. AC_LINK_IFELSE(
  207. [AC_LANG_PROGRAM([$4],[$5])],
  208. [ AC_MSG_RESULT(yes)
  209. ac_cv_lib_$2="yes"
  210. ],
  211. [ AC_MSG_RESULT(no)
  212. ac_cv_lib_$2="no"
  213. ]
  214. )
  215. AC_LANG_POP([C++])
  216. LIBS="${saved_libs}"
  217. CPPFLAGS="${saved_cppflags}"
  218. if test "${ac_cv_lib_$2}" = "yes"; then
  219. if test "${$2_LIB:-undef}" = "undef"; then
  220. if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
  221. $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
  222. else
  223. $2_LIB="-l${PLATFORM_$2}"
  224. fi
  225. fi
  226. if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
  227. $2_INCLUDE="-I${$2_INCDIR}"
  228. fi
  229. PBX_$2=1
  230. AC_DEFINE([HAVE_$2], 1, [$3])
  231. fi
  232. fi
  233. ])