sac-su2.m4 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. dnl ======================================================================
  2. dnl su module
  3. dnl ======================================================================
  4. AC_DEFUN([SAC_SU])
  5. AC_DEFUN([SAC_SOFIA_SU], [
  6. # Beginning of SAC_SOFIA_SU
  7. # ======================================================================
  8. # Check for features used by su
  9. dnl Define compilation options for su_configure.h
  10. case "$target" in
  11. *-*-solaris?.* )
  12. SAC_SU_DEFINE(__EXTENSIONS__, 1, [Define to 1 in Solaris in order to get POSIX extensions.])
  13. ;;
  14. esac
  15. # Check includes used by su includes
  16. AC_CHECK_HEADER(sys/types.h,
  17. SAC_SU_DEFINE([SU_HAVE_SYS_TYPES], 1,
  18. [Define to 1 if Sofia uses sys/types.h]))
  19. ax_inttypes=false
  20. AC_CHECK_HEADER(stdint.h, [
  21. ax_inttypes=true
  22. SAC_SU_DEFINE([SU_HAVE_STDINT], 1,
  23. [Define to 1 if Sofia uses stdint.h])])
  24. AC_CHECK_HEADER(inttypes.h,[
  25. ax_inttypes=true
  26. SAC_SU_DEFINE([SU_HAVE_INTTYPES], 1,
  27. [Define to 1 if Sofia uses inttypes.h])])
  28. if $ax_inttypes; then : ; else
  29. AC_MSG_ERROR("No <stdint.h> or <inttypes.h> found.")
  30. fi
  31. if test "x$MINGW_ENVIRONMENT" != x1 ; then
  32. AC_CHECK_HEADER(pthread.h,
  33. HAVE_PTHREADS=1;
  34. SAC_SU_DEFINE([SU_HAVE_PTHREADS], 1, [Sofia SU uses pthreads]))
  35. else
  36. HAVE_PTHREADS=1;
  37. SAC_SU_DEFINE([SU_HAVE_PTHREADS], 1, [Sofia SU uses pthreads])
  38. fi
  39. AC_ARG_ENABLE(experimental,
  40. [ --enable-experimental enable experimental features [[disabled]]],
  41. , enable_experimental=no)
  42. if test $enable_experimental = yes ; then
  43. SAC_SU_DEFINE([SU_HAVE_EXPERIMENTAL], 1, [Enable experimental features])
  44. fi
  45. dnl ===========================================================================
  46. dnl Checks for typedefs, headers, structures, and compiler characteristics.
  47. dnl ===========================================================================
  48. AC_REQUIRE([AC_C_CONST])
  49. AC_REQUIRE([AC_HEADER_TIME])
  50. AC_REQUIRE([AC_TYPE_SIZE_T])
  51. AC_REQUIRE([AC_C_VAR_FUNC])
  52. AC_REQUIRE([AC_C_MACRO_FUNCTION])
  53. AC_REQUIRE([AC_C_INLINE])
  54. AC_ARG_ENABLE(tag-cast,
  55. [ --disable-tag-cast cast tag values with inlined functions [[enabled]]],
  56. , enable_tag_cast=yes)
  57. if test "$enable_tag_cast" = "yes"; then
  58. tag_cast=1
  59. else
  60. tag_cast=0
  61. fi
  62. case "$ac_cv_c_inline" in
  63. yes) SAC_SU_DEFINE(su_inline, static inline, [
  64. Define to declarator for static inline functions.
  65. ])dnl
  66. SAC_SU_DEFINE(SU_INLINE, inline, [
  67. Define to declarator for inline functions.
  68. ])dnl
  69. SAC_SU_DEFINE(SU_HAVE_INLINE, 1, [
  70. Define to 1 if you have inline functions.
  71. ])dnl
  72. SAC_SU_DEFINE_UNQUOTED(SU_INLINE_TAG_CAST, $tag_cast, [
  73. Define to 1 if you use inline function to cast tag values.
  74. ])dnl
  75. ;;
  76. no | "" )
  77. SAC_SU_DEFINE(su_inline, static)dnl
  78. SAC_SU_DEFINE(SU_INLINE, /*inline*/)dnl
  79. SAC_SU_DEFINE(SU_HAVE_INLINE, 0)dnl
  80. SAC_SU_DEFINE(SU_INLINE_TAG_CAST, 0)dnl
  81. ;;
  82. *) SAC_SU_DEFINE_UNQUOTED(su_inline, static $ac_cv_c_inline)dnl
  83. SAC_SU_DEFINE_UNQUOTED(SU_INLINE, $ac_cv_c_inline)dnl
  84. SAC_SU_DEFINE(SU_HAVE_INLINE, 1)dnl
  85. SAC_SU_DEFINE_UNQUOTED(SU_INLINE_TAG_CAST, $tag_cast)dnl
  86. ;;
  87. esac
  88. AC_ARG_ENABLE(size-compat,
  89. [ --disable-size-compat use compatibility size_t types [[enabled]]],
  90. , enable_size_compat=yes)
  91. if test X$enable_size_compat != Xyes; then
  92. SAC_SU_DEFINE(SOFIA_ISIZE_T, size_t)dnl
  93. SAC_SU_DEFINE(ISIZE_MAX, SIZE_MAX)dnl
  94. SAC_SU_DEFINE(SOFIA_ISSIZE_T, ssize_t)dnl
  95. SAC_SU_DEFINE(ISSIZE_MAX, SSIZE_MAX)dnl
  96. SAC_SU_DEFINE(SOFIA_USIZE_T, size_t)dnl
  97. SAC_SU_DEFINE(USIZE_MAX, SIZE_MAX)dnl
  98. else
  99. SAC_SU_DEFINE(SOFIA_ISIZE_T, int)dnl
  100. SAC_SU_DEFINE(ISIZE_MAX, INT_MAX)dnl
  101. SAC_SU_DEFINE(SOFIA_ISSIZE_T, int)dnl
  102. SAC_SU_DEFINE(ISSIZE_MAX, INT_MAX)dnl
  103. SAC_SU_DEFINE(SOFIA_USIZE_T, unsigned)dnl
  104. SAC_SU_DEFINE(USIZE_MAX, UINT_MAX)dnl
  105. fi
  106. dnl ======================================================================
  107. dnl SAC_ENABLE_COREFOUNDATION
  108. dnl ======================================================================
  109. AC_ARG_ENABLE(corefoundation,
  110. [ --enable-corefoundation
  111. compile with OSX COREFOUNDATION [[disabled]]],
  112. , enable_corefoundation=no)
  113. AM_CONDITIONAL(COREFOUNDATION, test $enable_corefoundation = yes)
  114. if test $enable_corefoundation = yes ; then
  115. SAC_SU_DEFINE([SU_HAVE_OSX_CF_API], 1, [
  116. Define as 1 if you have OSX CoreFoundation interface])
  117. LIBS="-framework CoreFoundation -framework SystemConfiguration $LIBS"
  118. fi
  119. ### ======================================================================
  120. ### Test if we have stack suitable for handling tags directly
  121. ###
  122. AC_CACHE_CHECK([for stack suitable for tags],[ac_cv_tagstack],[
  123. ac_cv_tagstack=no
  124. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  125. #if HAVE_INTTYPES_H
  126. #include <inttypes.h>
  127. #endif
  128. #if HAVE_STDINT_H
  129. #include <stdint.h>
  130. #endif
  131. #include <stdarg.h>
  132. typedef void *tp;
  133. typedef intptr_t tv;
  134. int test1(tv l, tv h, ...)
  135. {
  136. va_list ap;
  137. tv i, *p = &l;
  138. va_start(ap, h);
  139. if (*p++ != l || *p++ != h) return 1;
  140. for (i = l; i <= h; i++) {
  141. if (*p++ != i)
  142. return 1;
  143. }
  144. for (i = l; i <= h; i++) {
  145. if (va_arg(ap, tv) != i)
  146. return 1;
  147. }
  148. va_end(ap);
  149. return 0;
  150. }
  151. int main(int avc, char **av)
  152. {
  153. return test1((tv)1, (tv)10,
  154. (tv)1, (tv)2, (tv)3, (tv)4, (tv)5,
  155. (tv)6, (tv)7, (tv)8, (tv)9, (tv)10);
  156. }
  157. ]])],[ac_cv_tagstack=yes],[ac_cv_tagstack=no],[
  158. case "$target" in
  159. i?86-*-* ) ac_cv_tagstack=yes ;;
  160. * ) ac_cv_tagstack=no ;;
  161. esac
  162. ])])
  163. if test $ac_cv_tagstack = yes ; then
  164. SAC_SU_DEFINE([SU_HAVE_TAGSTACK], 1, [
  165. Define this as 1 if your compiler puts the variable argument list nicely in memory])
  166. fi
  167. ### ======================================================================
  168. ### Test if free(0) fails
  169. ###
  170. AC_CACHE_CHECK([for graceful free(0)],[ac_cv_free_null],[
  171. ac_cv_free_null=no
  172. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  173. #include <stdlib.h>
  174. int main(int avc, char **av)
  175. {
  176. free(0);
  177. return 0;
  178. }
  179. ]])],[ac_cv_free_null=yes],[ac_cv_free_null=no],[ac_cv_free_null=no])])
  180. if test $ac_cv_free_null = yes ; then
  181. AC_DEFINE([HAVE_FREE_NULL], 1, [
  182. Define this as 1 if your c library does not crash with free(0)])
  183. fi
  184. dnl ======================================================================
  185. dnl Socket features
  186. AC_REQUIRE([AC_SYS_SA_LEN])
  187. if test "$ac_cv_sa_len" = yes ;then
  188. SAC_SU_DEFINE([SU_HAVE_SOCKADDR_SA_LEN], 1,
  189. [Define to 1 if you have sa_len in struct sockaddr])
  190. fi
  191. AC_ARG_ENABLE([ip6],
  192. [ --disable-ip6 disable IPv6 functionality [[enabled]]],,enable_ip6=yes)
  193. if ! test no$enable_ip6 = nono ; then
  194. AC_STRUCT_SIN6
  195. case $ac_cv_sin6 in
  196. yes) SAC_SU_DEFINE(SU_HAVE_IN6, 1, [
  197. Define to 1 if you have struct sockaddr_in6]) ;;
  198. no) ;;
  199. *) AC_MSG_ERROR([Inconsistent struct sockaddr_sin6 test]) ;;
  200. esac
  201. fi
  202. AC_CHECK_HEADERS([unistd.h sys/time.h])
  203. AC_CHECK_HEADERS([fcntl.h dirent.h])
  204. AC_CHECK_HEADERS([winsock2.h], [
  205. AC_DEFINE([HAVE_WIN32], 1, [Define to 1 you have WIN32])
  206. SAC_SU_DEFINE([SU_HAVE_WINSOCK], 1, [Define to 1 you have WinSock])
  207. SAC_SU_DEFINE([SU_HAVE_WINSOCK2], 1, [Define to 1 you have WinSock2])
  208. SAC_SU_DEFINE([SU_HAVE_SOCKADDR_STORAGE], 1,
  209. [Define to 1 if you have struct sockaddr_storage])
  210. AC_DEFINE([HAVE_ADDRINFO], 1,
  211. [Define to 1 if you have addrinfo structure.])
  212. AC_DEFINE([HAVE_GETADDRINFO], 1,
  213. [Define to 1 if you have addrinfo structure.])
  214. AC_DEFINE([HAVE_FREEADDRINFO], 1,
  215. [Define to 1 if you have addrinfo structure.])
  216. SAC_SU_DEFINE([SU_HAVE_ADDRINFO], 1,
  217. [Define to 1 if you have addrinfo structure.])
  218. AC_CHECK_HEADERS([windef.h ws2tcpip.h])
  219. AC_CHECK_HEADERS([iphlpapi.h], [
  220. AC_DEFINE([HAVE_INTERFACE_INFO_EX], 1, [
  221. Define to 1 if you have WIN32 INTERFACE_INFO_EX type.])
  222. AC_DEFINE([HAVE_SIO_ADDRESS_LIST_QUERY], 1, [
  223. Define to 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY.])
  224. ], [], [#if HAVE_WINDEF_H
  225. #include <windef.h>
  226. #include <winbase.h>
  227. #endif
  228. ])
  229. AC_DEFINE([HAVE_FILETIME], 1, [
  230. Define to 1 if you have WIN32 FILETIME type and
  231. GetSystemTimeAsFileTime().])
  232. ],[
  233. dnl no winsock2
  234. SAC_SU_DEFINE([SU_HAVE_BSDSOCK], 1, [Define to 1 if you have BSD socket interface])
  235. AC_CHECK_HEADERS([sys/socket.h sys/ioctl.h sys/filio.h sys/sockio.h \
  236. sys/select.h sys/epoll.h sys/devpoll.h])
  237. AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h \
  238. net/if.h net/if_types.h ifaddr.h netpacket/packet.h],,,
  239. [
  240. #include <sys/types.h>
  241. #include <sys/socket.h>])
  242. AC_CHECK_DECL([MSG_TRUNC],
  243. AC_DEFINE([HAVE_MSG_TRUNC],1,[Define to 1 if you have MSG_TRUNC flag]),,[
  244. #include <sys/types.h>
  245. #include <sys/socket.h>])
  246. AC_CHECK_DECL([SO_RCVBUFFORCE],
  247. AC_DEFINE([HAVE_SO_RCVBUFFORCE],1,[Define to 1 if you have socket option SO_RCVBUFFORCE]),,[
  248. #include <sys/types.h>
  249. #include <sys/socket.h>])
  250. AC_CHECK_DECL([SO_SNDBUFFORCE],
  251. AC_DEFINE([HAVE_SO_SNDBUFFORCE],1,[Define to 1 if you have socket option SO_SNDBUFFORCE]),,[
  252. #include <sys/types.h>
  253. #include <sys/socket.h>])
  254. AC_CHECK_DECL([IP_ADD_MEMBERSHIP],
  255. AC_DEFINE([HAVE_IP_ADD_MEMBERSHIP],1,[Define to 1 if you have IP_ADD_MEMBERSHIP]),,[
  256. #include <sys/types.h>
  257. #include <sys/socket.h>
  258. #include <netinet/in.h>])
  259. AC_CHECK_DECL([IP_MULTICAST_LOOP],
  260. AC_DEFINE([HAVE_IP_MULTICAST_LOOP],1,[Define to 1 if you have IP_MULTICAST_LOOP]),,[
  261. #include <sys/types.h>
  262. #include <sys/socket.h>
  263. #include <netinet/in.h>])
  264. AC_CHECK_DECL([IP_MTU_DISCOVER],
  265. AC_DEFINE([HAVE_IP_MTU_DISCOVER],1,
  266. [Define to 1 if you have IP_MTU_DISCOVER]),,[
  267. #include <sys/types.h>
  268. #include <sys/socket.h>
  269. #include <netinet/in.h>])
  270. AC_CACHE_CHECK([for struct addrinfo],
  271. [ac_cv_struct_addrinfo],[
  272. ac_cv_struct_addrinfo=no
  273. if test "$ac_cv_header_sys_socket_h" = yes; then
  274. AC_EGREP_HEADER([struct.+addrinfo], [netdb.h], [
  275. ac_cv_struct_addrinfo=yes])
  276. else
  277. ac_cv_struct_addrinfo='sys/socket.h missing'
  278. fi])
  279. if test "$ac_cv_struct_addrinfo" = yes; then
  280. SAC_SU_DEFINE([SU_HAVE_ADDRINFO], 1,
  281. [Define to 1 if you have struct addrinfo.])
  282. fi
  283. AC_CACHE_CHECK([for struct sockaddr_storage],
  284. [ac_cv_struct_sockaddr_storage],[
  285. ac_cv_struct_sockaddr_storage=no
  286. if test "$ac_cv_header_sys_socket_h" = yes; then
  287. AC_EGREP_HEADER([struct.+sockaddr_storage], [sys/socket.h], [
  288. ac_cv_struct_sockaddr_storage=yes])
  289. else
  290. ac_cv_struct_sockaddr_storage='sys/socket.h missing'
  291. fi])
  292. if test "$ac_cv_struct_sockaddr_storage" = yes; then
  293. SAC_SU_DEFINE(SU_HAVE_SOCKADDR_STORAGE, 1,
  294. [Define to 1 if you have struct sockaddr_storage])
  295. fi
  296. AC_CACHE_CHECK([for field ifr_index in struct ifreq],
  297. [ac_cv_struct_ifreq_ifr_index],[
  298. ac_cv_struct_ifreq_ifr_index=no
  299. if test "1${ac_cv_header_arpa_inet_h}2${ac_cv_header_netdb_h}3${ac_cv_header_sys_socket_h}4${ac_cv_header_net_if_h}" = 1yes2yes3yes4yes; then
  300. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  301. #include <arpa/inet.h>
  302. #include <netdb.h>
  303. #include <sys/socket.h>
  304. #include <net/if.h>]], [[
  305. struct ifreq ifreq; int index; index = ifreq.ifr_index;
  306. ]])],[ac_cv_struct_ifreq_ifr_index=yes],[])
  307. else
  308. ac_cv_struct_ifreq_ifr_index='net/if.h missing'
  309. fi # arpa/inet.h && netdb.h && sys/socket.h && net/if.h
  310. ])
  311. if test "$ac_cv_struct_ifreq_ifr_index" = yes ; then
  312. :
  313. AC_DEFINE(HAVE_IFR_INDEX, 1, [Define to 1 if you have ifr_index in <net/if.h>])
  314. else
  315. AC_CACHE_CHECK([for field ifr_ifindex in struct ifreq],
  316. [ac_cv_struct_ifreq_ifr_ifindex],[
  317. ac_cv_struct_ifreq_ifr_ifindex=no
  318. if test "1${ac_cv_header_arpa_inet_h}2${ac_cv_header_netdb_h}3${ac_cv_header_sys_socket_h}4${ac_cv_header_net_if_h}" = 1yes2yes3yes4yes; then
  319. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  320. #include <arpa/inet.h>
  321. #include <netdb.h>
  322. #include <sys/socket.h>
  323. #include <net/if.h>]], [[
  324. struct ifreq ifreq; int index; index = ifreq.ifr_ifindex;
  325. ]])],[ac_cv_struct_ifreq_ifr_ifindex=yes],[])
  326. else
  327. ac_cv_struct_ifreq_ifr_ifindex='net/if.h missing'
  328. fi # arpa/inet.h && netdb.h && sys/socket.h && net/if.h
  329. ])
  330. if test "$ac_cv_struct_ifreq_ifr_ifindex" = yes; then
  331. :
  332. AC_DEFINE(HAVE_IFR_IFINDEX, 1, [Define to 1 if you have ifr_ifindex in <net/if.h>])
  333. fi
  334. fi # ifr_index in struct ifreq
  335. dnl SIOGCIFCONF & struct ifconf
  336. AC_CACHE_CHECK([for struct ifconf],
  337. [ac_cv_struct_ifconf],[
  338. ac_cv_struct_ifconf=no
  339. if test "$ac_cv_header_net_if_h" = yes; then
  340. AC_EGREP_HEADER(struct.+ifconf, net/if.h, ac_cv_struct_ifconf=yes)
  341. else
  342. ac_cv_struct_ifconf='net/if.h missing'
  343. fi])
  344. if test "$ac_cv_struct_ifconf" = yes; then
  345. AC_DEFINE(HAVE_IFCONF, 1, [Define to 1 if you have SIOCGIFCONF])
  346. fi
  347. AC_CACHE_CHECK([for ioctl SIOCGIFNUM],
  348. [ac_cv_ioctl_siocgifnum],[
  349. ac_cv_ioctl_siocgifnum=no
  350. if test "$ac_cv_header_sys_sockio_h" = yes; then
  351. AC_EGREP_CPP(yes, [
  352. #include <sys/sockio.h>
  353. #ifdef SIOCGIFNUM
  354. yes
  355. #endif
  356. ], [ac_cv_ioctl_siocgifnum=yes])
  357. else
  358. ac_cv_ioctl_siocgifnum='sys/sockio.h missing'
  359. fi])
  360. if test "$ac_cv_ioctl_siocgifnum" = yes; then
  361. HAVE_IFNUM=1
  362. AC_DEFINE(HAVE_IFNUM, 1, [Define to 1 if you have SIOCGIFNUM ioctl])
  363. else
  364. HAVE_IFNUM=0
  365. fi
  366. ]) dnl AC_CHECK_HEADERS([winsock2.h ... ])
  367. # ===========================================================================
  368. # Checks for libraries
  369. # ===========================================================================
  370. AC_CHECK_LIB(pthread, pthread_create)
  371. AC_CHECK_LIB(socket, socketpair,,,-lnsl)
  372. AC_ARG_WITH(rt,
  373. [ --with-rt use POSIX realtime library [[used by default]]])
  374. if test "${with_rt}" != no; then
  375. AC_SEARCH_LIBS(clock_gettime, rt)
  376. AC_CHECK_FUNCS([clock_gettime clock_getcpuclockid])
  377. AC_CHECK_DECL([CLOCK_MONOTONIC],
  378. AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
  379. [Define to 1 if you have CLOCK_MONOTONIC]),,[
  380. #include <time.h>])
  381. fi
  382. # No GLib path explicitly defined, use pkg-config
  383. AC_ARG_WITH(glib,
  384. [ --with-glib=version use GLib (default=2.0)], [
  385. case "$with_glib" in
  386. yes | "" ) with_glib=2.0 ;;
  387. esac
  388. ], [with_glib=2.0])
  389. AC_ARG_WITH(glib-dir,
  390. [ --with-glib-dir=PREFIX explicitly define GLib path],,
  391. with_glib_dir="pkg-config")
  392. if test "$with_glib" = no || test "$with_glib_dir" = "no" ; then
  393. : # No glib
  394. elif test "$with_glib_dir" = "pkg-config" ; then
  395. PKG_CHECK_MODULES(GLIB, glib-$with_glib, [HAVE_GLIB=yes], [HAVE_GLIB=no])
  396. else # GLib path is explicitly defined
  397. gprefix=$with_glib_dir
  398. GLIB_VERSION="$with_glib"
  399. GLIBXXX=glib-$with_glib
  400. if test "$gprefix" = "yes" ; then
  401. for gprefix in /usr /usr/local /opt/$GLIBXXX
  402. do
  403. test -d $gprefix/include/$GLIBXXX && break
  404. done
  405. fi
  406. if ! test -d $gprefix/include/$GLIBXXX ; then
  407. AC_MSG_ERROR("No $GLIBXXX in --with-glib=$with_glib_dir")
  408. else
  409. exec_gprefix=${gprefix}
  410. glibdir=${exec_gprefix}/lib
  411. gincludedir=${gprefix}/include
  412. # glib_genmarshal=glib-genmarshal
  413. # glib_mkenums=glib-mkenums
  414. HAVE_GLIB=yes
  415. if test "x$MINGW_ENVIRONMENT" = x1 ; then
  416. GLIB_LIBS="${glibdir}/lib$GLIBXXX.dll.a ${glibdir}/libintl.a ${glibdir}/libiconv.a"
  417. else
  418. GLIB_LIBS="-L${glibdir} -l$GLIBXXX -lintl -liconv"
  419. fi
  420. GLIB_CFLAGS="-I${gincludedir}/$GLIBXXX -I${glibdir}/$GLIBXXX/include"
  421. fi
  422. fi # GLib path is explicitly defined
  423. if test "x$HAVE_GLIB" = xyes ; then
  424. SAC_COMMA_APPEND([SOFIA_GLIB_PKG_REQUIRES],[glib-2.0])
  425. fi
  426. AM_CONDITIONAL([HAVE_GLIB], [test "x$HAVE_GLIB" = xyes])
  427. AC_SUBST([GLIB_LIBS])
  428. AC_SUBST([GLIB_CFLAGS])
  429. AC_SUBST([GLIB_VERSION])
  430. AC_SUBST([SOFIA_GLIB_PKG_REQUIRES])
  431. # ===========================================================================
  432. # Checks for library functions.
  433. # ===========================================================================
  434. AC_SEARCH_LIBS(socket, xnet socket)
  435. AC_SEARCH_LIBS(inet_ntop, socket nsl)
  436. dnl AC_SEARCH_LIBS(inet_pton, socket nsl)
  437. AC_SEARCH_LIBS(getipnodebyname, xnet socket nsl)
  438. AC_SEARCH_LIBS(gethostbyname, xnet nsl)
  439. AC_SEARCH_LIBS(getaddrinfo, xnet socket nsl)
  440. AC_FUNC_ALLOCA
  441. AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock \
  442. socketpair gethostname gethostbyname getipnodebyname \
  443. poll epoll_create kqueue select if_nameindex \
  444. signal alarm \
  445. strnlen \
  446. getaddrinfo getnameinfo freeaddrinfo gai_strerror getifaddrs \
  447. getline getdelim getpass])
  448. # getline getdelim getpass are _GNU_SOURCE stuff
  449. if test $ac_cv_func_poll = yes ; then
  450. SAC_SU_DEFINE([SU_HAVE_POLL], 1, [Define to 1 if you have poll().])
  451. fi
  452. if test $ac_cv_func_epoll_create = yes && test $ac_cv_header_sys_epoll_h = yes
  453. then
  454. AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have epoll interface.])
  455. fi
  456. if test $ac_cv_func_if_nameindex = yes ; then
  457. SAC_SU_DEFINE([SU_HAVE_IF_NAMEINDEX], 1,
  458. [Define to 1 if you have if_nameindex().])
  459. fi
  460. SAC_REPLACE_FUNCS([memmem memccpy memspn memcspn strtoull \
  461. inet_ntop inet_pton poll])
  462. if test $ac_cv_func_signal = yes ; then
  463. AC_CHECK_DECL([SIGPIPE], [
  464. AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
  465. #include <signal.h>
  466. ])
  467. dnl add SIGHUP SIGQUIT if needed
  468. fi
  469. # ===========================================================================
  470. # Check how to implement su_port
  471. # ===========================================================================
  472. AC_ARG_ENABLE(poll-port,
  473. [ --disable-poll-port disable su_poll_port [[enabled]]
  474. Use this option in systems emulating poll with select],
  475. , enable_poll_port=maybe)
  476. if test $enable_poll_port = maybe ; then
  477. if test $ac_cv_func_poll = yes ; then
  478. AC_DEFINE([HAVE_POLL_PORT], 1, [Define to 1 if you use poll in su_port.])
  479. fi
  480. elif test $enable_poll_port = yes ; then
  481. AC_DEFINE([HAVE_POLL_PORT], 1, [Define to 1 if you use poll in su_port.])
  482. fi
  483. # ===========================================================================
  484. # Check pthread_rwlock_unlock()
  485. # ===========================================================================
  486. AC_DEFUN([AC_DEFINE_HAVE_PTHREAD_RWLOCK],[dnl
  487. AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1,[
  488. Define to 1 if you have working pthread_rwlock_t implementation.
  489. A thread may hold multiple concurrent read locks on rwlock - that is,
  490. successfully call the pthread_rwlock_rdlock() function n times. If
  491. so, the application shall ensure that the thread performs matching
  492. unlocks - that is, it calls the pthread_rwlock_unlock() function n
  493. times.
  494. ])])
  495. if test x$HAVE_PTHREADS = x1 ; then
  496. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  497. #define _XOPEN_SOURCE (500)
  498. #include <pthread.h>
  499. pthread_rwlock_t rw;
  500. int main()
  501. {
  502. pthread_rwlock_init(&rw, NULL);
  503. pthread_rwlock_rdlock(&rw);
  504. pthread_rwlock_rdlock(&rw);
  505. pthread_rwlock_unlock(&rw);
  506. /* pthread_rwlock_trywrlock() should fail (not return 0) */
  507. return pthread_rwlock_trywrlock(&rw) != 0 ? 0 : 1;
  508. }
  509. ]])],[AC_DEFINE_HAVE_PTHREAD_RWLOCK],[
  510. AC_MSG_WARN([Recursive pthread_rwlock_rdlock() does not work!!! ])
  511. ],[AC_DEFINE_HAVE_PTHREAD_RWLOCK])
  512. fi
  513. # ===========================================================================
  514. # Check IPv6 addresss configuration
  515. # ===========================================================================
  516. case "$target" in
  517. *-*-linux*) AC_DEFINE([HAVE_PROC_NET_IF_INET6], 1,
  518. [Define to 1 if you have /proc/net/if_inet6 control file]) ;;
  519. esac
  520. AC_CONFIG_HEADERS([libsofia-sip-ua/su/sofia-sip/su_configure.h])
  521. # End of SAC_SOFIA_SU
  522. ])
  523. dnl
  524. dnl Append a value $2 to a variable, separating values with comma
  525. dnl
  526. AC_DEFUN([SAC_COMMA_APPEND],[$1="`test -n "$$1" && echo "$$1, "`$2"])
  527. # SAC_SU_DEFINE(VARIABLE, [VALUE], [DESCRIPTION])
  528. # -------------------------------------------
  529. # Set VARIABLE to VALUE, verbatim, or 1. Remember the value
  530. # and if VARIABLE is affected the same VALUE, do nothing, else
  531. # die. The third argument is used by autoheader.
  532. m4_define([SAC_SU_DEFINE],[
  533. cat >>confdefs.h <<\_AXEOF
  534. [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
  535. _AXEOF
  536. ])
  537. # SAC_SU_DEFINE_UNQUOTED(VARIABLE, [VALUE], [DESCRIPTION])
  538. # ----------------------------------------------------
  539. # Similar, but perform shell substitutions $ ` \ once on VALUE.
  540. m4_define([SAC_SU_DEFINE_UNQUOTED],[
  541. cat >>confdefs.h <<_ACEOF
  542. [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
  543. _ACEOF
  544. ])
  545. AC_DEFUN([SAC_REPLACE_FUNCS],[dnl
  546. AC_CHECK_FUNCS([$1],ifelse([$2], , :,[$2]),[dnl
  547. case "$REPLACE_LIBADD" in
  548. "$ac_func.lo" | \
  549. *" $ac_func.lo" | \
  550. "$ac_func.lo "* | \
  551. *" $ac_func.lo "* ) ;;
  552. *) REPLACE_LIBADD="$REPLACE_LIBADD $ac_func.lo" ;;
  553. esac])
  554. AC_SUBST([REPLACE_LIBADD])
  555. ifelse([$3], , :, [$3])
  556. ])