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.

151 lignes
3.9 KiB

  1. AC_PREREQ(2.61)
  2. AC_INIT(btpd, 0.13+, btpd@murmeldjur.se)
  3. AM_INIT_AUTOMAKE([1.10 foreign subdir-objects])
  4. AC_CONFIG_FILES([Makefile])
  5. AC_PROG_CC
  6. AM_PROG_CC_C_O
  7. AC_PROG_RANLIB
  8. AC_USE_SYSTEM_EXTENSIONS
  9. AC_DEFUN([PROG_SILENT_IFELSE],
  10. ac_output=`$1 2>&1`
  11. if test x"$ac_output" != x; then
  12. [$3]
  13. else
  14. [$2]
  15. fi)
  16. AC_DEFUN([CC_ARGS_OK_IFELSE],
  17. AC_LANG_PUSH(C)
  18. AC_LANG_CONFTEST([int foo(void) { return 12; }])
  19. AC_LANG_POP(C)
  20. PROG_SILENT_IFELSE([$CC $1 -c conftest.c],
  21. rm -f conftest.c conftest.$OBJEXT
  22. [$2],
  23. rm -f conftest.c conftest.$OBJEXT
  24. [$3]))
  25. AC_ARG_WITH(openssl,
  26. [ --with-openssl=dir use openssl installed in dir],
  27. [
  28. AC_SUBST(openssl_LDFLAGS,["-L${withval}/lib -Wl,-R,${withval}/lib"])
  29. AC_SUBST(openssl_CPPFLAGS,"-I${withval}/include")
  30. ])
  31. AC_ARG_WITH(evloop-method,
  32. [ --with-evloop-method select evloop method (epoll,poll,kqueue)],
  33. evloop_methods=$withval,
  34. evloop_methods="epoll kqueue poll")
  35. old_LIBS=$LIBS
  36. LIBS=""
  37. AC_SEARCH_LIBS(inet_ntop, nsl,,AC_MSG_FAILURE(btpd needs inet_ntop))
  38. AC_SEARCH_LIBS(bind, socket,,AC_MSG_FAILURE(btpd needs bind))
  39. AC_SUBST(INETLIBS,$LIBS)
  40. LIBS=$old_LIBS
  41. AC_CHECK_FUNCS(asprintf)
  42. AC_MSG_CHECKING(for CLOCK_MONOTONIC)
  43. AC_COMPILE_IFELSE([
  44. #include <sys/time.h>
  45. #include <time.h>
  46. int main(void) { return clock_gettime(CLOCK_MONOTONIC, (void *)0); }
  47. ], clock_gettime=yes, clock_gettime=no)
  48. AC_MSG_RESULT($clock_gettime)
  49. if test $clock_gettime == yes; then
  50. old_LIBS=$LIBS
  51. LIBS=""
  52. AC_SEARCH_LIBS(clock_gettime,rt,clock_gettime=yes,clock_gettime=no)
  53. AC_SUBST(CLOCKLIB,$LIBS)
  54. LIBS=$old_LIBS
  55. AC_DEFINE(HAVE_CLOCK_MONOTONIC)
  56. fi
  57. if test $clock_gettime == no; then
  58. AC_CHECK_FUNCS(mach_absolute_time,,
  59. AC_MSG_FAILURE(no supported time mechanism found))
  60. fi
  61. AC_MSG_CHECKING(whether compiler accepts -Wno-pointer-sign)
  62. CC_ARGS_OK_IFELSE(-Wno-pointer-sign,
  63. AC_SUBST(WARNNPS,"-Wno-pointer-sign")
  64. AC_MSG_RESULT(yes)
  65. ,
  66. AC_MSG_RESULT(no))
  67. old_LDFLAGS="$LDFLAGS"
  68. LDFLAGS="$LDFLAGS $openssl_LDFLAGS"
  69. AC_CHECK_LIB(crypto, SHA1_Final,:,AC_MSG_FAILURE(btpd needs openssl's libraries and headers))
  70. LDFLAGS=$old_LDFLAGS
  71. for m in $evloop_methods; do
  72. case $m in
  73. epoll)
  74. AC_CHECK_FUNC(epoll_wait,[
  75. AC_SUBST(EVLOOP_IMPL,"evloop/epoll.${OBJEXT}")
  76. AC_SUBST(EVLOOP_METHOD,EVLOOP_EPOLL)
  77. break])
  78. ;;
  79. kqueue)
  80. AC_CHECK_FUNC(kqueue,[
  81. AC_SUBST(EVLOOP_IMPL,"evloop/kqueue.${OBJEXT}")
  82. AC_SUBST(EVLOOP_METHOD,EVLOOP_KQUEUE)
  83. break])
  84. ;;
  85. poll)
  86. AC_CHECK_FUNC(poll,[
  87. AC_SUBST(EVLOOP_IMPL,"evloop/poll.${OBJEXT}")
  88. AC_SUBST(EVLOOP_METHOD,EVLOOP_POLL)
  89. break])
  90. break
  91. ;;
  92. *)
  93. AC_MSG_ERROR($m is not a valid evloop method)
  94. exit 1
  95. ;;
  96. esac
  97. done
  98. if test x"$EVLOOP_METHOD" == x; then
  99. AC_MSG_FAILURE(no suitable evloop method found)
  100. exit 1
  101. else
  102. AC_MSG_NOTICE(selected evloop method $EVLOOP_METHOD)
  103. fi
  104. for i in 0 1 2 3 4 5 6; do
  105. case $i in
  106. 0) if test x"$TD_CFLAGS$TD_LIBS" == x; then continue; fi;;
  107. 1) TD_CFLAGS=-pthread;;
  108. 2) TD_CFLAGS=-pthreads;;
  109. 3) TD_CFLAGS=-kthread;;
  110. 4) TD_CFLAGS=-mt;;
  111. 5) TD_LIBS=-lpthread;;
  112. 6) AC_MSG_FAILURE(how do you build with pthreads on this system?);;
  113. esac
  114. AC_MSG_CHECKING(whether pthreads compiles with flags \"$TD_CFLAGS $TD_LIBS\")
  115. CC_ARGS_OK_IFELSE($TD_CFLAGS $CFLAGS $TD_LIBS $LIBS,,
  116. AC_MSG_RESULT(no)
  117. TD_CFLAGS=""; TD_LIBS=""
  118. continue)
  119. old_CFLAGS=$CFLAGS; old_LIBS=$LIBS
  120. CFLAGS="$TD_CFLAGS $CFLAGS"; LIBS="$TD_LIBS $LIBS"
  121. AC_LINK_IFELSE([
  122. #include <pthread.h>
  123. int main(void) { return pthread_create(0,0,0,0);}
  124. ], [
  125. AC_MSG_RESULT(yes)
  126. CFLAGS=$old_CFLAGS; LIBS=$old_LIBS
  127. break
  128. ], [
  129. AC_MSG_RESULT(no)
  130. TD_CFLAGS=""; TD_LIBS=""
  131. CFLAGS=$old_CFLAGS; LIBS=$old_LIBS
  132. ])
  133. done
  134. AC_SUBST(TD_CFLAGS)
  135. AC_SUBST(TD_LIBS)
  136. AC_OUTPUT