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.

373 lignes
8.3 KiB

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