configure.ac 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. ##################################################################
  2. #
  3. # uEcho for C
  4. #
  5. # Copyright (C) Satoshi Konno 2015
  6. #
  7. # This is licensed under BSD-style license, see file COPYING.
  8. #
  9. ##################################################################
  10. AC_CONFIG_AUX_DIR(config)
  11. AC_CONFIG_HEADERS(config.h)
  12. AC_INIT([uecho],[1.2.2])
  13. AC_CONFIG_SRCDIR([include/uecho/typedef.h])
  14. AM_INIT_AUTOMAKE([subdir-objects])
  15. ##############################
  16. # Checks for programs.
  17. ##############################
  18. AC_PROG_CC
  19. AC_PROG_CXX
  20. AC_PROG_INSTALL
  21. AC_PROG_AWK
  22. #AC_PROG_LIBTOOL
  23. AC_PROG_RANLIB
  24. ##############################
  25. # Checks for header files.
  26. ##############################
  27. AC_CHECK_HEADERS([stdbool.h])
  28. ##############################
  29. # Checks for pthread
  30. ##############################
  31. AC_CHECK_HEADERS([pthread.h],,[AC_MSG_ERROR(uEcho needs POSIX thread library)])
  32. AC_CHECK_LIB([pthread],[main])
  33. ##############################
  34. # Checks for Network functions
  35. ##############################
  36. AC_CHECK_FUNCS([socket])
  37. AC_CHECK_FUNCS([inet_ntoa])
  38. AC_CHECK_HEADERS([ifaddrs.h])
  39. AC_CHECK_FUNCS([getifaddrs])
  40. ##### socklen_t ####
  41. AC_MSG_CHECKING(for socklen_t)
  42. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  43. #include <sys/types.h>
  44. #include <sys/socket.h>
  45. socklen_t foosocket;
  46. ]], [[]])],[AC_MSG_RESULT(yes)
  47. AC_DEFINE([HAVE_SOCKLEN_T],1,[SOCKLEN_T])],[AC_MSG_RESULT(no)
  48. ])
  49. ##### SIOCGIFHWADDR ####
  50. AC_MSG_CHECKING(for SIOCGIFHWADDR)
  51. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  52. #include <stdio.h>
  53. #include <string.h>
  54. #include <sys/types.h>
  55. #include <sys/socket.h>
  56. #include <sys/ioctl.h>
  57. #include <netinet/in.h>
  58. #include <net/if.h>
  59. void func()
  60. {
  61. int sock;
  62. struct ifreq ifr;
  63. sock = socket(AF_INET, SOCK_DGRAM, 0);
  64. strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);
  65. ifr.ifr_addr.sa_family = AF_INET;
  66. ioctl(sock, SIOCGIFHWADDR, &ifr);
  67. }
  68. ]], [[]])],[AC_MSG_RESULT(yes)
  69. AC_DEFINE([HAVE_SIOCGIFHWADDR],1,[SIOCGIFHWADDR])],[AC_MSG_RESULT(no)
  70. ])
  71. ##### sockaddr_dl ####
  72. AC_MSG_CHECKING(for sockaddr_dl)
  73. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  74. #include <sys/types.h>
  75. #include <sys/socket.h>
  76. void func()
  77. {
  78. struct ifaddrs *ifaddr;
  79. struct ifaddrs *i;
  80. struct sockaddr_dl *dl;
  81. unsigned char *macaddr;
  82. getifaddrs(&ifaddr);
  83. dl = (struct sockaddr_dl *)(ifaddr->ifa_addr);
  84. LLADDR(dl);
  85. freeifaddrs(ifaddr);
  86. }
  87. ]], [[]])],[AC_MSG_RESULT(yes)
  88. AC_DEFINE([HAVE_SOCKADDR_DL],1,[SOCKADDR_DL])],[AC_MSG_RESULT(no)
  89. ])
  90. ##### IP_PKTINFO ####
  91. AC_MSG_CHECKING(for IP_PKTINFO)
  92. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  93. #include <sys/types.h>
  94. #include <sys/socket.h>
  95. void func()
  96. {
  97. int on=1;
  98. setsockopt(0, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
  99. }
  100. ]], [[]])],[AC_MSG_RESULT(yes)
  101. AC_DEFINE([HAVE_IP_PKTINFO],1,[IP_PKTINFO])],[AC_MSG_RESULT(no)
  102. ])
  103. ##### SO_NOSIGPIPE ####
  104. AC_MSG_CHECKING(for SO_NOSIGPIPE)
  105. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  106. #include <sys/types.h>
  107. #include <sys/socket.h>
  108. void func()
  109. {
  110. int on=1;
  111. setsockopt(0, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
  112. }
  113. ]], [[]])],[AC_MSG_RESULT(yes)
  114. AC_DEFINE([HAVE_SO_NOSIGPIPE],1,[SO_NOSIGPIPES])],[AC_MSG_RESULT(no)
  115. ])
  116. ##############################
  117. # Debug
  118. ##############################
  119. AC_ARG_ENABLE(
  120. [debug],
  121. AS_HELP_STRING([--enable-debug],[ enable debugging (default = no) ]),
  122. [case "${enableval}" in
  123. yes | no ) enable_debug="${enableval}" ;;
  124. esac],
  125. []
  126. )
  127. if [ test "$enable_debug" = yes ]; then
  128. AC_DEFINE([DEBUG],1,[Define to 1 if you want to debug])
  129. fi
  130. ##############################
  131. # Testing
  132. ##############################
  133. AC_ARG_ENABLE(
  134. [test],
  135. AS_HELP_STRING([--enable-test],[ build tests (default = no) ]),
  136. [case "${enableval}" in
  137. yes | no ) build_test="${enableval}" ;;
  138. esac],
  139. []
  140. )
  141. AM_CONDITIONAL(UECHO_ENABLE_TEST,test "$build_test" = yes)
  142. if [ test "$build_test" = yes ]; then
  143. AC_CHECK_LIB([boost_system-mt],[main],,
  144. [AC_CHECK_LIB([boost_system],[main],,[AC_MSG_ERROR(uEcho needs boost::system)])])
  145. AC_CHECK_LIB([boost_unit_test_framework-mt],[main],,
  146. [AC_CHECK_LIB([boost_unit_test_framework],[main],,[AC_MSG_ERROR(uEcho needs boost::unit_test_framework)])])
  147. fi
  148. ##############################
  149. # Examples
  150. ##############################
  151. AC_ARG_ENABLE(
  152. [examples],
  153. AS_HELP_STRING([--enable-examples],[ build examples (default = yes) ]),
  154. [case "${enableval}" in
  155. yes | no ) build_examples="${enableval}" ;;
  156. esac],
  157. [build_examples="yes"]
  158. )
  159. AM_CONDITIONAL(UECHO_ENABLE_EXAMPLES,test "$build_examples" = yes)
  160. ##############################
  161. # Makefiles
  162. ##############################
  163. AC_CONFIG_FILES([
  164. Makefile
  165. include/Makefile
  166. lib/Makefile
  167. lib/unix/Makefile
  168. test/Makefile
  169. test/unix/Makefile
  170. examples/Makefile
  171. examples/controller/Makefile
  172. examples/controller/uechosearch/Makefile
  173. examples/controller/uechosearch/unix/Makefile
  174. examples/controller/uechodump/Makefile
  175. examples/controller/uechodump/unix/Makefile
  176. examples/controller/uechopost/Makefile
  177. examples/controller/uechopost/unix/Makefile
  178. examples/device/Makefile
  179. examples/device/uecholight/Makefile
  180. examples/device/uecholight/unix/Makefile
  181. ])
  182. AC_OUTPUT