A clone of btpd with my configuration changes.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

382 lignes
8.5 KiB

  1. dnl configure.in for libevent
  2. AC_INIT(event.c)
  3. AM_INIT_AUTOMAKE(libevent,1.3b)
  4. AM_CONFIG_HEADER(config.h)
  5. AM_MAINTAINER_MODE
  6. dnl Initialize prefix.
  7. if test "$prefix" = "NONE"; then
  8. prefix="/usr/local"
  9. fi
  10. dnl Checks for programs.
  11. AC_PROG_CC
  12. AC_PROG_INSTALL
  13. AC_PROG_LN_S
  14. AC_PROG_GCC_TRADITIONAL
  15. if test "$GCC" = yes ; then
  16. CFLAGS="$CFLAGS -Wall"
  17. fi
  18. AC_PROG_RANLIB
  19. dnl Uncomment "AC_DISABLE_SHARED" to make shared librraries not get
  20. dnl built by default. You can also turn shared libs on and off from
  21. dnl the command line with --enable-shared and --disable-shared.
  22. dnl AC_DISABLE_SHARED
  23. dnl AC_SUBST(LIBTOOL_DEPS)
  24. dnl Check for optional stuff
  25. AC_ARG_WITH(rtsig,
  26. [ --with-rtsig compile with support for real time signals (experimental)],
  27. [usertsig=yes], [usertsig=no])
  28. dnl Checks for libraries.
  29. AC_CHECK_LIB(socket, socket)
  30. dnl Checks for header files.
  31. AC_HEADER_STDC
  32. AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/ioctl.h sys/devpoll.h port.h netinet/in6.h)
  33. if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
  34. AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
  35. AC_EGREP_CPP(yes,
  36. [
  37. #include <sys/queue.h>
  38. #ifdef TAILQ_FOREACH
  39. yes
  40. #endif
  41. ], [AC_MSG_RESULT(yes)
  42. AC_DEFINE(HAVE_TAILQFOREACH, 1,
  43. [Define if TAILQ_FOREACH is defined in <sys/queue.h>])],
  44. AC_MSG_RESULT(no)
  45. )
  46. fi
  47. if test "x$ac_cv_header_sys_time_h" = "xyes"; then
  48. AC_MSG_CHECKING(for timeradd in sys/time.h)
  49. AC_EGREP_CPP(yes,
  50. [
  51. #include <sys/time.h>
  52. #ifdef timeradd
  53. yes
  54. #endif
  55. ], [ AC_DEFINE(HAVE_TIMERADD, 1,
  56. [Define if timeradd is defined in <sys/time.h>])
  57. AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
  58. )
  59. fi
  60. if test "x$ac_cv_header_sys_time_h" = "xyes"; then
  61. AC_MSG_CHECKING(for timercmp in sys/time.h)
  62. AC_EGREP_CPP(yes,
  63. [
  64. #include <sys/time.h>
  65. #ifdef timercmp
  66. yes
  67. #endif
  68. ], [ AC_DEFINE(HAVE_TIMERCMP, 1,
  69. [Define if timercmp is defined in <sys/time.h>])
  70. AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
  71. )
  72. fi
  73. if test "x$ac_cv_header_sys_time_h" = "xyes"; then
  74. AC_MSG_CHECKING(for timerclear in sys/time.h)
  75. AC_EGREP_CPP(yes,
  76. [
  77. #include <sys/time.h>
  78. #ifdef timerclear
  79. yes
  80. #endif
  81. ], [ AC_DEFINE(HAVE_TIMERCLEAR, 1,
  82. [Define if timerclear is defined in <sys/time.h>])
  83. AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
  84. )
  85. fi
  86. if test "x$ac_cv_header_sys_time_h" = "xyes"; then
  87. AC_MSG_CHECKING(for timerisset in sys/time.h)
  88. AC_EGREP_CPP(yes,
  89. [
  90. #include <sys/time.h>
  91. #ifdef timerisset
  92. yes
  93. #endif
  94. ], [ AC_DEFINE(HAVE_TIMERISSET, 1,
  95. [Define if timerisset is defined in <sys/time.h>])
  96. AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
  97. )
  98. fi
  99. dnl - check if the macro WIN32 is defined on this compiler.
  100. dnl - (this is how we check for a windows version of GCC)
  101. AC_MSG_CHECKING(for WIN32)
  102. AC_TRY_COMPILE(,
  103. [
  104. #ifndef WIN32
  105. #error
  106. #endif
  107. ],
  108. bwin32=true; AC_MSG_RESULT(yes),
  109. bwin32=false; AC_MSG_RESULT(no),
  110. )
  111. AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue)
  112. dnl Checks for typedefs, structures, and compiler characteristics.
  113. AC_C_CONST
  114. AC_C_INLINE
  115. AC_HEADER_TIME
  116. dnl Checks for library functions.
  117. AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy inet_ntop)
  118. if test "x$ac_cv_func_clock_gettime" = "xyes"; then
  119. AC_DEFINE(DNS_USE_CPU_CLOCK_FOR_ID, 1, [Define if clock_gettime is available in libc])
  120. else
  121. AC_DEFINE(DNS_USE_GETTIMEOFDAY_FOR_ID, 1, [Define is no secure id variant is available])
  122. fi
  123. AC_MSG_CHECKING(for F_SETFD in fcntl.h)
  124. AC_EGREP_CPP(yes,
  125. [
  126. #define _GNU_SOURCE
  127. #include <fcntl.h>
  128. #ifdef F_SETFD
  129. yes
  130. #endif
  131. ], [ AC_DEFINE(HAVE_SETFD, 1,
  132. [Define if F_SETFD is defined in <fcntl.h>])
  133. AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no))
  134. needsignal=no
  135. haveselect=no
  136. AC_CHECK_FUNCS(select, [haveselect=yes], )
  137. if test "x$haveselect" = "xyes" ; then
  138. AC_LIBOBJ(select)
  139. needsignal=yes
  140. fi
  141. havepoll=no
  142. havertsig=no
  143. AC_CHECK_FUNCS(poll, [havepoll=yes], )
  144. if test "x$havepoll" = "xyes" ; then
  145. AC_LIBOBJ(poll)
  146. needsignal=yes
  147. if test "x$usertsig" = "xyes" ; then
  148. AC_CHECK_FUNCS(sigtimedwait, [havertsig=yes], )
  149. fi
  150. fi
  151. if test "x$havertsig" = "xyes" ; then
  152. AC_MSG_CHECKING(for F_SETSIG in fcntl.h)
  153. AC_EGREP_CPP(yes,
  154. [
  155. #define _GNU_SOURCE
  156. #include <fcntl.h>
  157. #ifdef F_SETSIG
  158. yes
  159. #endif
  160. ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no); havertsig=no])
  161. fi
  162. if test "x$havertsig" = "xyes" ; then
  163. AC_DEFINE(HAVE_RTSIG, 1, [Define if your system supports POSIX realtime signals])
  164. AC_LIBOBJ(rtsig)
  165. AC_MSG_CHECKING(for working rtsig on pipes)
  166. AC_TRY_RUN(
  167. [
  168. #define _GNU_SOURCE
  169. #include <fcntl.h>
  170. #include <signal.h>
  171. #include <unistd.h>
  172. int sigio()
  173. {
  174. exit(0);
  175. }
  176. int main()
  177. {
  178. int fd[2];
  179. pipe(fd);
  180. signal(SIGIO, sigio);
  181. fcntl(fd[0], F_SETOWN, getpid());
  182. fcntl(fd[0], F_SETSIG, SIGIO);
  183. fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL) | O_ASYNC);
  184. write(fd[1], "", 1);
  185. return 1;
  186. }
  187. ], [ AC_MSG_RESULT(yes)
  188. AC_DEFINE(HAVE_WORKING_RTSIG, 1, [Define if realtime signals work on pipes])],
  189. AC_MSG_RESULT(no))
  190. fi
  191. haveepoll=no
  192. AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
  193. if test "x$haveepoll" = "xyes" ; then
  194. AC_DEFINE(HAVE_EPOLL, 1,
  195. [Define if your system supports the epoll system calls])
  196. AC_LIBOBJ(epoll)
  197. needsignal=yes
  198. fi
  199. havedevpoll=no
  200. if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then
  201. AC_DEFINE(HAVE_DEVPOLL, 1,
  202. [Define if /dev/poll is available])
  203. AC_LIBOBJ(devpoll)
  204. fi
  205. havekqueue=no
  206. if test "x$ac_cv_header_sys_event_h" = "xyes"; then
  207. AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
  208. if test "x$havekqueue" = "xyes" ; then
  209. AC_MSG_CHECKING(for working kqueue)
  210. AC_TRY_RUN(
  211. #include <sys/types.h>
  212. #include <sys/time.h>
  213. #include <sys/event.h>
  214. #include <stdio.h>
  215. #include <unistd.h>
  216. #include <fcntl.h>
  217. int
  218. main(int argc, char **argv)
  219. {
  220. int kq;
  221. int n;
  222. int fd[[2]];
  223. struct kevent ev;
  224. struct timespec ts;
  225. char buf[[8000]];
  226. if (pipe(fd) == -1)
  227. exit(1);
  228. if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1)
  229. exit(1);
  230. while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf))
  231. ;
  232. if ((kq = kqueue()) == -1)
  233. exit(1);
  234. ev.ident = fd[[1]];
  235. ev.filter = EVFILT_WRITE;
  236. ev.flags = EV_ADD | EV_ENABLE;
  237. n = kevent(kq, &ev, 1, NULL, 0, NULL);
  238. if (n == -1)
  239. exit(1);
  240. read(fd[[0]], buf, sizeof(buf));
  241. ts.tv_sec = 0;
  242. ts.tv_nsec = 0;
  243. n = kevent(kq, NULL, 0, &ev, 1, &ts);
  244. if (n == -1 || n == 0)
  245. exit(1);
  246. exit(0);
  247. }, [AC_MSG_RESULT(yes)
  248. AC_DEFINE(HAVE_WORKING_KQUEUE, 1,
  249. [Define if kqueue works correctly with pipes])
  250. AC_LIBOBJ(kqueue)], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
  251. fi
  252. fi
  253. haveepollsyscall=no
  254. if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
  255. if test "x$haveepoll" = "xno" ; then
  256. AC_MSG_CHECKING(for epoll system call)
  257. AC_TRY_RUN(
  258. #include <stdint.h>
  259. #include <sys/param.h>
  260. #include <sys/types.h>
  261. #include <sys/syscall.h>
  262. #include <sys/epoll.h>
  263. #include <unistd.h>
  264. int
  265. epoll_create(int size)
  266. {
  267. return (syscall(__NR_epoll_create, size));
  268. }
  269. int
  270. main(int argc, char **argv)
  271. {
  272. int epfd;
  273. epfd = epoll_create(256);
  274. exit (epfd == -1 ? 1 : 0);
  275. }, [AC_MSG_RESULT(yes)
  276. AC_DEFINE(HAVE_EPOLL, 1,
  277. [Define if your system supports the epoll system calls])
  278. needsignal=yes
  279. AC_LIBOBJ(epoll_sub)
  280. AC_LIBOBJ(epoll)], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
  281. fi
  282. fi
  283. haveeventports=no
  284. AC_CHECK_FUNCS(port_create, [haveeventports=yes], )
  285. if test "x$haveeventports" = "xyes" ; then
  286. AC_DEFINE(HAVE_EVENT_PORTS, 1,
  287. [Define if your system supports event ports])
  288. AC_LIBOBJ(evport)
  289. needsignal=yes
  290. fi
  291. if test "x$needsignal" = "xyes" ; then
  292. AC_LIBOBJ(signal)
  293. fi
  294. AC_TYPE_PID_T
  295. AC_TYPE_SIZE_T
  296. AC_CHECK_TYPE(u_int64_t, unsigned long long)
  297. AC_CHECK_TYPE(u_int32_t, unsigned int)
  298. AC_CHECK_TYPE(u_int16_t, unsigned short)
  299. AC_CHECK_TYPE(u_int8_t, unsigned char)
  300. AC_CHECK_TYPES([struct in6_addr], , ,
  301. [#ifdef WIN32
  302. #include <winsock2.h>
  303. #else
  304. #include <sys/types.h>
  305. #include <netinet/in.h>
  306. #include <sys/socket.h>
  307. #endif
  308. #ifdef HAVE_NETINET_IN6_H
  309. #include <netinet/in6.h>
  310. #endif])
  311. AC_MSG_CHECKING([for socklen_t])
  312. AC_TRY_COMPILE([
  313. #include <sys/types.h>
  314. #include <sys/socket.h>],
  315. [socklen_t x;],
  316. AC_MSG_RESULT([yes]),
  317. [AC_MSG_RESULT([no])
  318. AC_DEFINE(socklen_t, unsigned int,
  319. [Define to unsigned int if you dont have it])]
  320. )
  321. AC_MSG_CHECKING([whether our compiler supports __func__])
  322. AC_TRY_COMPILE([],
  323. [void foo() { const char *cp = __func__; }],
  324. AC_MSG_RESULT([yes]),
  325. AC_MSG_RESULT([no])
  326. AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
  327. AC_TRY_COMPILE([],
  328. [void foo() { const char *cp = __FUNCTION__; }],
  329. AC_MSG_RESULT([yes])
  330. AC_DEFINE(__func__, __FUNCTION__,
  331. [Define to appropriate substitue if compiler doesnt have __func__]),
  332. AC_MSG_RESULT([no])
  333. AC_DEFINE(__func__, __FILE__,
  334. [Define to appropriate substitue if compiler doesnt have __func__])))
  335. AC_OUTPUT(Makefile)