sac-general.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. dnl =====================================================================
  2. dnl This file contains autoconf macros shared by Sofia modules.
  3. dnl
  4. dnl Author: Pekka Pessi <Pekka.Pessi@nokia.com>
  5. dnl
  6. dnl License:
  7. dnl
  8. dnl Copyright (c) 2001,2004 Nokia and others. All Rights Reserved.
  9. dnl
  10. dnl Please note that every macro contained in this file is copyrighted by
  11. dnl its respective author, unless the macro source explicitely says
  12. dnl otherwise. Permission has been granted, though, to use and distribute
  13. dnl all macros under the following license, which is a modified version of
  14. dnl the GNU General Public License version 2:
  15. dnl
  16. dnl Each Autoconf macro in this file is free software; you can redistribute it
  17. dnl and/or modify it under the terms of the GNU General Public License as
  18. dnl published by the Free Software Foundation; either version 2, or (at your
  19. dnl option) any later version.
  20. dnl
  21. dnl They are distributed in the hope that they will be useful, but WITHOUT ANY
  22. dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  23. dnl FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  24. dnl details. (You should have received a copy of the GNU General Public License
  25. dnl along with this program; if not, write to the Free Software Foundation,
  26. dnl Inc., 59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA.)
  27. dnl
  28. dnl As a special exception, the Free Software Foundation gives unlimited
  29. dnl permission to copy, distribute and modify the configure scripts that are
  30. dnl the output of Autoconf. You need not follow the terms of the GNU General
  31. dnl Public License when using or distributing such scripts, even though
  32. dnl portions of the text of Autoconf appear in them. The GNU General Public
  33. dnl License (GPL) does govern all other use of the material that constitutes
  34. dnl the Autoconf program.
  35. dnl
  36. dnl Certain portions of the Autoconf source text are designed to be copied
  37. dnl (in certain cases, depending on the input) into the output of Autoconf.
  38. dnl We call these the "data" portions. The rest of the Autoconf source text
  39. dnl consists of comments plus executable code that decides which of the data
  40. dnl portions to output in any given case. We call these comments and
  41. dnl executable code the "non-data" portions. Autoconf never copies any of
  42. dnl the non-data portions into its output.
  43. dnl
  44. dnl This special exception to the GPL applies to versions of Autoconf
  45. dnl released by the Free Software Foundation. When you make and distribute a
  46. dnl modified version of Autoconf, you may extend this special exception to
  47. dnl the GPL to apply to your modified version as well, *unless* your
  48. dnl modified version has the potential to copy into its output some of the
  49. dnl text that was the non-data portion of the version that you started with.
  50. dnl (In other words, unless your change moves or copies text from the
  51. dnl non-data portions to the data portions.) If your modification has such
  52. dnl potential, you must delete any notice of this special exception to the
  53. dnl GPL from your modified version.
  54. dnl
  55. dnl =====================================================================
  56. dnl ===================================================================
  57. dnl Get host, target and build variables filled with appropriate info,
  58. dnl and check the validity of the cache
  59. dnl ===================================================================
  60. AC_DEFUN([SAC_CANONICAL_SYSTEM_CACHE_CHECK], [
  61. dnl Get host, target and build variables filled with appropriate info.
  62. AC_CANONICAL_TARGET([])
  63. dnl Check to assure the cached information is valid.
  64. AC_MSG_CHECKING(cached information)
  65. hostcheck="$host"
  66. AC_CACHE_VAL(ac_cv_hostcheck, [ ac_cv_hostcheck="$hostcheck" ])
  67. if test "$ac_cv_hostcheck" != "$hostcheck"; then
  68. AC_MSG_RESULT(changed)
  69. AC_MSG_WARN(config.cache exists!)
  70. AC_MSG_ERROR([you must do 'make distclean' first to compile
  71. for different host or different parameters.])
  72. else
  73. AC_MSG_RESULT(ok)
  74. fi
  75. dnl SOSXXX: AC_PATH_ADJUST
  76. ])
  77. dnl ======================================================================
  78. dnl Find C compiler
  79. dnl ======================================================================
  80. AC_DEFUN([SAC_TOOL_CC], [
  81. AC_REQUIRE([SAC_CANONICAL_SYSTEM_CACHE_CHECK])
  82. #AC_BEFORE([$0], [AC_PROG_CPP])dnl
  83. AC_CHECK_TOOL(CC, gcc, gcc)
  84. if test -z "$CC"; then
  85. AC_CHECK_TOOL(CC, cc, cc, , , /usr/ucb/cc)
  86. if test -z "$CC"; then
  87. case "`uname -s`" in
  88. *win32* | *WIN32* ) AC_CHECK_PROG(CC, cl, cl) ;;
  89. esac
  90. fi
  91. test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
  92. fi
  93. AC_PROG_CC
  94. #
  95. # Wall
  96. #
  97. AC_CACHE_CHECK([for maximum warnings compiler flag],
  98. ac_cv_cwflag,
  99. [case "${CC-cc}" in
  100. *gcc*) ac_cv_cwflag=-Wall;;
  101. *) case "$host" in
  102. *irix*) ac_cv_cwflag=-fullwarn ;;
  103. *solaris*) ac_cv_cwflag="-erroff=%none,E_END_OF_LOOP_CODE_NOT_REACHED,E_BAD_PTR_INT_COMBINATION -errtags"
  104. ;;
  105. *) ac_cv_cwflag=;;
  106. esac
  107. ;;
  108. esac])
  109. AC_SUBST([CWFLAG], [$ac_cv_cwflag])
  110. AC_ARG_VAR([SOFIA_CFLAGS], [CFLAGS not used during configure])
  111. AC_ARG_VAR([SOFIA_GLIB_CFLAGS], [Extra CFLAGS for libsofia-sip-ua-glib])
  112. SAC_COVERAGE
  113. ])
  114. dnl ======================================================================
  115. dnl Check for sockaddr_in6
  116. dnl ======================================================================
  117. AC_DEFUN([AC_STRUCT_SIN6], [
  118. AC_CACHE_CHECK([for sockaddr_in6],
  119. ac_cv_sin6,
  120. [AC_EGREP_HEADER(struct sockaddr_in6, netinet/in.h,
  121. ac_cv_sin6=yes, ac_cv_sin6=no)])
  122. if test $ac_cv_sin6 = yes ;then
  123. AC_DEFINE([HAVE_SIN6], 1,
  124. [Define to 1 if you have IPv6 structures and constants])
  125. fi
  126. ])
  127. dnl ======================================================================
  128. dnl Check for sa_len in struct sockaddr
  129. dnl ======================================================================
  130. AC_DEFUN([AC_SYS_SA_LEN], [
  131. AC_CACHE_CHECK([for sa_len],
  132. ac_cv_sa_len,
  133. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  134. #include <sys/socket.h>]], [[
  135. struct sockaddr t;t.sa_len = 0;]])],[ac_cv_sa_len=yes],[ac_cv_sa_len=no])])
  136. if test "$ac_cv_sa_len" = yes ;then
  137. AC_DEFINE([HAVE_SA_LEN], 1,
  138. [Define to 1 if you have sa_len in struct sockaddr])
  139. fi
  140. ])
  141. dnl ======================================================================
  142. dnl Check for MSG_NOSIGNAL flag
  143. dnl ======================================================================
  144. AC_DEFUN([AC_FLAG_MSG_NOSIGNAL], [
  145. AC_REQUIRE([AC_PROG_CC])
  146. AC_CACHE_CHECK([for MSG_NOSIGNAL],
  147. ac_cv_flag_msg_nosignal, [
  148. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  149. #include <sys/types.h>
  150. #include <sys/socket.h>]], [[
  151. int flags = MSG_NOSIGNAL;
  152. ]])],[ac_cv_flag_msg_nosignal=yes],[ac_cv_flag_msg_nosignal=no])])
  153. if test "$ac_cv_flag_msg_nosignal" = yes ; then
  154. AC_DEFINE([HAVE_MSG_NOSIGNAL], 1,
  155. [Define to 1 if you have MSG_NOSIGNAL flag for send()])
  156. fi
  157. ])dnl
  158. dnl ======================================================================
  159. dnl Check for MSG_ERRQUEUE flag
  160. dnl ======================================================================
  161. AC_DEFUN([AC_SYS_MSG_ERRQUEUE], [
  162. AC_REQUIRE([AC_PROG_CC])
  163. AC_CACHE_CHECK([for MSG_ERRQUEUE],
  164. ac_cv_flag_msg_errqueue, [
  165. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  166. #include <sys/types.h>
  167. #include <sys/socket.h>]], [[
  168. int flags = MSG_ERRQUEUE;
  169. ]])],[ac_cv_flag_msg_errqueue=yes],[ac_cv_flag_msg_errqueue=no])])
  170. if test "$ac_cv_flag_msg_errqueue" = yes; then
  171. AC_DEFINE([HAVE_MSG_ERRQUEUE], 1,
  172. [Define to 1 if you have MSG_ERRQUEUE flag for send()])
  173. fi
  174. ])dnl
  175. dnl ======================================================================
  176. dnl Check for IP_RECVERR option
  177. dnl ======================================================================
  178. AC_DEFUN([AC_SYS_IP_RECVERR], [
  179. AC_REQUIRE([AC_PROG_CC])
  180. AC_CACHE_CHECK([for IP_RECVERR],
  181. ac_cv_sys_ip_recverr, [
  182. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  183. #include <sys/types.h>
  184. #include <sys/socket.h>
  185. #include <netinet/in.h>
  186. ]], [[
  187. int one = 1;
  188. int s = 0;
  189. setsockopt(s, SOL_IP, IP_RECVERR, &one, sizeof(one));
  190. ]])],[ac_cv_sys_ip_recverr=yes],[ac_cv_sys_ip_recverr=no])])
  191. if test "$ac_cv_sys_ip_recverr" = yes ; then
  192. AC_DEFINE([HAVE_IP_RECVERR], 1,
  193. [Define to 1 if you have IP_RECVERR in <netinet/in.h>])
  194. fi
  195. ])dnl
  196. dnl ======================================================================
  197. dnl Check for IPV6_RECVERR option
  198. dnl ======================================================================
  199. AC_DEFUN([AC_SYS_IPV6_RECVERR], [
  200. AC_REQUIRE([AC_PROG_CC])
  201. AC_CACHE_CHECK([for IPV6_RECVERR],
  202. ac_cv_sys_ipv6_recverr, [
  203. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  204. #include <sys/types.h>
  205. #include <sys/socket.h>
  206. #include <netinet/in.h>
  207. ]], [[
  208. int one = 1;
  209. int s = 0;
  210. setsockopt(s, SOL_IPV6, IPV6_RECVERR, &one, sizeof(one));
  211. ]])],[ac_cv_sys_ipv6_recverr=yes],[ac_cv_sys_ipv6_recverr=no])])
  212. if test "$ac_cv_sys_ipv6_recverr" = yes ; then
  213. AC_DEFINE([HAVE_IPV6_RECVERR], 1,
  214. [Define to 1 if you have IPV6_RECVERR in <netinet/in6.h>])
  215. fi
  216. ])dnl
  217. dnl ======================================================================
  218. dnl @synopsis AC_C_VAR_FUNC
  219. dnl
  220. dnl This macro tests if the C compiler supports the C99 standard
  221. dnl __func__ indentifier.
  222. dnl
  223. dnl The new C99 standard for the C language stipulates that the
  224. dnl identifier __func__ shall be implictly declared by the compiler
  225. dnl as if, immediately following the opening brace of each function
  226. dnl definition, the declaration
  227. dnl
  228. dnl static const char __func__[] = "function-name";
  229. dnl
  230. dnl appeared, where function-name is the name of the function where
  231. dnl the __func__ identifier is used.
  232. dnl
  233. dnl @author Christopher Currie <christopher@currie.com>
  234. dnl @author Pekka Pessi <Pekka.Pessi@nokia.com>
  235. dnl ======================================================================
  236. AC_DEFUN([AC_C_VAR_FUNC],
  237. [AC_REQUIRE([AC_PROG_CC])
  238. AC_CACHE_CHECK(whether $CC recognizes __func__, ac_cv_c_var_func,
  239. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[char *s = __func__;
  240. ]])],[ac_cv_c_var_func=yes],[ac_cv_c_var_func=no]))
  241. if test $ac_cv_c_var_func = "yes"; then
  242. AC_DEFINE([HAVE_FUNC], 1, [Define to 1 if the C compiler supports __func__])
  243. fi
  244. ])dnl
  245. AC_DEFUN([AC_C_MACRO_FUNCTION],
  246. [AC_REQUIRE([AC_PROG_CC])
  247. AC_CACHE_CHECK(whether $CC recognizes __FUNCTION__, ac_cv_c_macro_function,
  248. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  249. char *s = __FUNCTION__;
  250. ]])],[ac_cv_c_macro_function=yes],[ac_cv_c_macro_function=no]))
  251. if test $ac_cv_c_macro_function = "yes"; then
  252. AC_DEFINE([HAVE_FUNCTION], 1, [Define to 1 if the C compiler supports __FUNCTION__])
  253. fi
  254. ])dnl
  255. dnl ======================================================================
  256. dnl AC_C_INLINE_DEFINE
  257. dnl ======================================================================
  258. AC_DEFUN([AC_C_INLINE_DEFINE], [
  259. AC_C_INLINE
  260. case "$ac_cv_c_inline" in *inline* | yes)
  261. AC_DEFINE([HAVE_INLINE], 1, [Define to 1 if you have inlining compiler]) ;;
  262. esac
  263. ])
  264. dnl ======================================================================
  265. dnl AC_C_KEYWORD_STRUCT
  266. dnl ======================================================================
  267. AC_DEFUN([AC_C_KEYWORD_STRUCT], [
  268. AC_REQUIRE([AC_PROG_CC])
  269. AC_CACHE_CHECK(whether $CC recognizes field names in struct initialization, ac_cv_c_keyword_struct,
  270. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  271. struct { int foo; char *bar; } test = { foo: 1, bar: "bar" };
  272. return 0;
  273. ]])],[ac_cv_c_keyword_struct=yes],[ac_cv_c_keyword_struct=no]))
  274. if test $ac_cv_c_keyword_struct = "yes"; then
  275. AC_DEFINE([HAVE_STRUCT_KEYWORDS], 1, [
  276. Define to 1 if your CC supports C99 struct initialization])
  277. fi
  278. ])
  279. dnl ======================================================================
  280. dnl autoconf-version
  281. dnl should be removed after automake conversion is finished
  282. dnl ======================================================================
  283. AC_DEFUN([AC_AUTOCONF_PARAM],
  284. [
  285. if autoconf --version | fgrep '2.13' > /dev/null ; then
  286. AUTOCONF_PARAM="-l"
  287. else
  288. AUTOCONF_PARAM="-I"
  289. fi
  290. AC_SUBST(AUTOCONF_PARAM)
  291. ])
  292. dnl ======================================================================
  293. dnl SAC_ENABLE_NDEBUG
  294. dnl ======================================================================
  295. AC_DEFUN([SAC_ENABLE_NDEBUG],[
  296. AC_REQUIRE([SAC_TOOL_CC])
  297. AC_ARG_ENABLE(ndebug,
  298. [ --enable-ndebug compile with NDEBUG [[disabled]]],
  299. , enable_ndebug=no)
  300. AM_CONDITIONAL(NDEBUG, test x$enable_ndebug = xyes)
  301. ])
  302. dnl ======================================================================
  303. dnl SAC_ENABLE_EXPENSIVE_CHECKS
  304. dnl ======================================================================
  305. AC_DEFUN([SAC_ENABLE_EXPENSIVE_CHECKS],[
  306. AC_ARG_ENABLE(expensive-checks,
  307. [ --enable-expensive-checks
  308. run also expensive checks [[disabled]]],
  309. , enable_expensive_checks=no)
  310. if test x$enable_expensive_checks != xno; then
  311. AC_SUBST([TESTS_ENVIRONMENT], [EXPENSIVE_CHECKS=1])
  312. fi
  313. AM_CONDITIONAL(EXPENSIVE_CHECKS, test x$enable_expensive_checks != xno)
  314. ])
  315. dnl ======================================================================
  316. dnl Check if we are using Windows with MinGW compiler
  317. dnl ======================================================================
  318. AC_DEFUN([AC_CHECK_COMPILATION_ENVIRONMENT], [
  319. AC_REQUIRE([AC_PROG_CC])
  320. AC_CACHE_CHECK([for compilation environment],
  321. ac_cv_cc_environment, [
  322. machine=`$CC -dumpmachine`
  323. if test "$machine" = mingw32 ; then
  324. ac_cc_environment=$machine
  325. fi
  326. ])
  327. if test "$ac_cc_environment" = mingw32 ; then
  328. CFLAGS="$CFLAGS -I\$(top_srcdir)/win32/pthread -DWINVER=0x0501 \
  329. -D_WIN32_WINNT=0x0501 -DIN_LIBSOFIA_SIP_UA -DIN_LIBSOFIA_SRES \
  330. -mms-bitfields \
  331. -pipe -mno-cygwin -mwindows -mconsole -Wall -g -O0"
  332. LDFLAGS="$LDFLAGS -Wl,--enable-auto-image-base"
  333. LIBS="-L\$(top_srcdir)/win32/pthread -lpthreadVC2 -lws2_32 \
  334. -lwsock32"
  335. MINGW_ENVIRONMENT=1
  336. AC_SUBST(MINGW_ENVIRONMENT)
  337. AC_DEFINE([HAVE_MINGW], [1], [Define to 1 if you are compiling in MinGW environment])
  338. AC_DEFINE([HAVE_WIN32], [1], [Define to 1 if you have WIN32])
  339. fi
  340. AM_CONDITIONAL([HAVE_MINGW32], [test "x$ac_cc_environment" != x])
  341. ])dnl
  342. dnl ======================================================================
  343. dnl Find long long (at least 64 bits)
  344. dnl ======================================================================
  345. AC_DEFUN([AC_TYPE_LONGLONG],[dnl
  346. AC_CHECK_TYPE([long long],[dnl
  347. AC_DEFINE([longlong], [long long], [Define to a at least 64-bit int type])dnl
  348. ifelse([$1], ,:, [$1])],[ifelse([$2], ,:, [$2])])])
  349. dnl ======================================================================
  350. dnl Check for /dev/urandom
  351. dnl ======================================================================
  352. AC_DEFUN([AC_DEV_URANDOM],[
  353. AC_CACHE_CHECK([/dev/urandom], [ac_cv_dev_urandom],
  354. [ac_cv_dev_urandom=no
  355. if test -r /dev/urandom; then ac_cv_dev_urandom=yes; fi])
  356. if test $ac_cv_dev_urandom = yes; then
  357. AC_DEFINE([HAVE_DEV_URANDOM], 1,
  358. [Define to 1 if you have /dev/urandom.])
  359. AC_DEFINE([DEV_URANDOM], 1,
  360. [Define to the random number source name.])
  361. fi
  362. ])