PageRenderTime 62ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/echoping-6.0.2/acinclude.m4

#
m4 | 270 lines | 223 code | 19 blank | 28 comment | 0 complexity | b8c1d264a01711fba7cad0f12412bc47 MD5 | raw file
Possible License(s): GPL-2.0
  1. dnl $Id: acinclude.m4 377 2007-03-12 20:48:05Z bortz $
  2. dnl Macros beginning with CF_ (mostly) stolen from Lynx
  3. dnl Thanks to "T.E.Dickey" <dickey@clark.net>
  4. dnl ---------------------------------------------------------------------------
  5. dnl Make an uppercase version of a variable
  6. dnl $1=uppercase($2)
  7. AC_DEFUN([CF_UPPER],
  8. [
  9. changequote(,)dnl
  10. $1=`echo $2 | tr '[a-z]' '[A-Z]'`
  11. changequote([,])dnl
  12. ])dnl
  13. dnl ---------------------------------------------------------------------------
  14. dnl Check for existence of external data in the current set of libraries. If
  15. dnl we can modify it, it's real enough.
  16. dnl $1 = the name to check
  17. dnl $2 = its type
  18. AC_DEFUN([CF_CHECK_EXTERN_DATA],
  19. [
  20. AC_MSG_CHECKING(if external $1 exists)
  21. AC_CACHE_VAL(cf_cv_have_$1,[
  22. AC_TRY_LINK([
  23. #undef $1
  24. extern $2 $1;
  25. ],
  26. [$1 = 2],
  27. [eval 'cf_cv_have_'$1'=yes'],
  28. [eval 'cf_cv_have_'$1'=no'])])
  29. eval 'cf_result=$cf_cv_have_'$1
  30. AC_MSG_RESULT($cf_result)
  31. if test "$cf_result" = yes ; then
  32. eval 'cf_result=HAVE_'$1
  33. CF_UPPER(cf_result,$cf_result)
  34. AC_DEFINE_UNQUOTED($cf_result)
  35. fi
  36. ])dnl
  37. dnl ---------------------------------------------------------------------------
  38. dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
  39. dnl the 'errno' variable. Define a DECL_xxx symbol if we must declare it
  40. dnl ourselves.
  41. dnl
  42. dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a
  43. dnl loop from CF_SYS_ERRLIST).
  44. dnl
  45. dnl $1 = the name to check
  46. AC_DEFUN([CF_CHECK_ERRNO],
  47. [
  48. AC_MSG_CHECKING(if external $1 is declared)
  49. AC_CACHE_VAL(cf_cv_dcl_$1,[
  50. AC_TRY_COMPILE([
  51. #ifdef HAVE_STDLIB_H
  52. #include <stdlib.h>
  53. #endif
  54. #include <stdio.h>
  55. #include <sys/types.h>
  56. #include <errno.h> ],
  57. [long x = (long) $1],
  58. [eval 'cf_cv_dcl_'$1'=yes'],
  59. [eval 'cf_cv_dcl_'$1'=no]')
  60. ])
  61. eval 'cf_result=$cf_cv_dcl_'$1
  62. AC_MSG_RESULT($cf_result)
  63. if test "$cf_result" = no ; then
  64. eval 'cf_result=DECL_'$1
  65. CF_UPPER(cf_result,$cf_result)
  66. AC_DEFINE_UNQUOTED($cf_result)
  67. fi
  68. # It's possible (for near-UNIX clones) that the data doesn't exist
  69. CF_CHECK_EXTERN_DATA($1,int)
  70. ])dnl
  71. dnl Useful macros to check libraries which are not implicit
  72. dnl in Solaris, for instance.
  73. AC_DEFUN([CF_LIB_NSL],
  74. [
  75. AC_CHECK_LIB(nsl,gethostbyname,
  76. [
  77. AC_MSG_CHECKING(if libnsl is mandatory)
  78. AC_TRY_LINK([#include <sys/types.h>
  79. #include <netinet/in.h>
  80. char *domain; ],
  81. [gethostbyname(domain)], dnl
  82. [AC_MSG_RESULT(no)], dnl
  83. [AC_MSG_RESULT(yes); LIBS="${LIBS} -lnsl"])
  84. ])
  85. ])
  86. AC_DEFUN([CF_LIB_SOCKET],
  87. [
  88. AC_CHECK_LIB(socket,socket,
  89. [
  90. AC_MSG_CHECKING(if libsocket is mandatory)
  91. AC_TRY_LINK([#include <sys/types.h>
  92. #include <netinet/in.h>
  93. union
  94. {
  95. HEADER hdr;
  96. u_char buf[512];
  97. }
  98. response;
  99. char *domain;
  100. int requested_type; ],
  101. [socket (AF_INET, SOCK_STREAM, 0) ], dnl
  102. [AC_MSG_RESULT(no)], dnl
  103. [AC_MSG_RESULT(yes); LIBS="${LIBS} -lsocket"])
  104. ])
  105. ])
  106. AC_DEFUN([CF_LIB_MATH],
  107. [
  108. AC_CHECK_LIB(m,pow,
  109. [
  110. AC_MSG_CHECKING(if libmath is mandatory)
  111. AC_TRY_LINK([#include <math.h>
  112. double a,b; ],
  113. [pow(a,b)], dnl
  114. [AC_MSG_RESULT(no)], dnl
  115. [AC_MSG_RESULT(yes); LIBS="${LIBS} -lm"])
  116. ])
  117. ])
  118. dnl Check the port name for HTTP. Everyone should declare "http" but
  119. dnl not everyone does. This test is BUGgy, we should use a program
  120. dnl which calls getservbyname() otherwise we miss NIS tables, for
  121. dnl instance.
  122. AC_DEFUN([CF_CHECK_SERVICES],
  123. [
  124. AC_MSG_CHECKING(what is the name of the HTTP port in your services database)
  125. dnl BUG: We should test it is really the good port and not any mention of "http"
  126. if grep http /etc/services > /dev/null; then
  127. AC_DEFINE(HTTP_TCP_PORT,"http")
  128. AC_MSG_RESULT(http)
  129. else
  130. dnl BUG: Trap on Solaris with a port whose name begins with "www"...
  131. if grep www /etc/services > /dev/null; then
  132. AC_DEFINE(HTTP_TCP_PORT,"www")
  133. AC_MSG_RESULT(www)
  134. else
  135. AC_DEFINE(HTTP_TCP_PORT,"undefined:use_:80")
  136. AC_MSG_RESULT([undefined, you should add it in your database])
  137. fi
  138. fi
  139. AC_MSG_CHECKING(what is the name of the ICP port in your services database)
  140. if grep icp /etc/services > /dev/null; then
  141. AC_DEFINE(ICP_UDP_PORT,"icp")
  142. AC_MSG_RESULT(icp)
  143. else
  144. AC_DEFINE(ICP_UDP_PORT,"undefined:use_:3130")
  145. AC_MSG_RESULT([undefined, you should add it in your database])
  146. fi
  147. ])
  148. # Check GNU libidn
  149. # TODO: check the patched libc with AI_IDN. See libidn, in libc/getaddrinfo-idn.txt.
  150. AC_DEFUN([CF_LIB_LIBIDN],
  151. [
  152. AC_CHECK_LIB(idn,idna_to_ascii_8z,
  153. [LIBS="${LIBS} -lidn"],
  154. [AC_ERROR([Get the GNU libidn library (http://www.josefsson.org/libidn/) in order to use Unicode - multi-script - domain names or use --without-libidn to disable it])], dnl
  155. )])
  156. # Check OpenSSL
  157. AC_DEFUN([CF_LIB_OPENSSL],
  158. [
  159. AC_CHECK_LIB(ssl,SSL_CTX_new,
  160. [LIBS="${LIBS} -lssl -lcrypto"],
  161. [AC_ERROR([Get the OpenSSL library (http://www.openssl.org/)])], dnl
  162. -lcrypto
  163. )])
  164. # Check GNU TLS
  165. AC_DEFUN([CF_LIB_GNUTLS],
  166. [
  167. AC_CHECK_LIB(gnutls,gnutls_global_init,
  168. [LIBS="${LIBS} `libgnutls-config --libs`"],
  169. [AC_ERROR([Get the GNU TLS library (http://www.gnutls.org/)])], dnl
  170. )])
  171. dnl experimental
  172. AC_DEFUN([CF_CHECK_TCP_SERVICE],
  173. [
  174. AC_TRY_RUN([
  175. #include <stdio.h>
  176. #include <stdlib.h>
  177. #include <sys/types.h>
  178. #include <netdb.h>
  179. #include <sys/socket.h>
  180. #include <netinet/in.h>
  181. #include <arpa/inet.h>
  182. #include <unistd.h>
  183. int
  184. main (argc, argv)
  185. int argc;
  186. char *argv[];
  187. {
  188. struct servent *sp;
  189. if ((sp = getservbyname ("$1", "tcp")) == 0)
  190. exit (1);
  191. else
  192. exit (0);
  193. }
  194. ],
  195. ac_last_port=$1
  196. ,
  197. ac_last_port=
  198. )])
  199. dnl Our (W. Richard Stevens') macro to check for a function prototype in
  200. dnl a given header.
  201. AC_DEFUN([AC_CHECK_FUNC_PROTO],
  202. [AC_CACHE_CHECK(for $1 function prototype in $2, ac_cv_have_$1_proto,
  203. AC_EGREP_HEADER($1, $2,
  204. ac_cv_have_$1_proto=yes,
  205. ac_cv_have_$1_proto=no))
  206. if test $ac_cv_have_$1_proto = yes ; then
  207. ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`_PROTO
  208. AC_DEFINE_UNQUOTED($ac_tr_func)
  209. fi
  210. ])
  211. dnl BROKEN: do not use
  212. dnl Copied from autoconf and edited to add an argument: an include file
  213. dnl AC_CHECK_FUNC_WITH_HEADER(FUNCTION, HEADER, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
  214. AC_DEFUN([AC_CHECK_FUNC_WITH_HEADER],
  215. [AC_MSG_CHECKING([for $1])
  216. AC_CACHE_VAL(ac_cv_func_$1,
  217. [AC_TRY_LINK(
  218. dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
  219. dnl which includes <sys/select.h> which contains a prototype for
  220. dnl select. Similarly for bzero.
  221. [/* System header to define __stub macros and hopefully few prototypes,
  222. which can conflict with char $1(); below. */
  223. #include <assert.h>
  224. /* Override any gcc2 internal prototype to avoid an error. */
  225. ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
  226. extern "C"
  227. #endif
  228. ])dnl
  229. [/* We use char because int might match the return type of a gcc2
  230. builtin and then its argument prototype would still apply. */
  231. char $1();
  232. #include <$2>
  233. ], [
  234. /* The GNU C library defines this for functions which it implements
  235. to always fail with ENOSYS. Some functions are actually named
  236. something starting with __ and the normal name is an alias. */
  237. #if defined (__stub_$1) || defined (__stub___$1)
  238. choke me
  239. #else
  240. $1();
  241. #endif
  242. ], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")])
  243. if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
  244. AC_MSG_RESULT(yes)
  245. ifelse([$3], , :, [$3])
  246. else
  247. AC_MSG_RESULT(no)
  248. ifelse([$4], , , [$4
  249. ])dnl
  250. fi
  251. ])