configure.ac 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. # Copyright (c) 2004 Damien Miller
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. AC_INIT([softflowd], [1.0.0])
  15. AC_CONFIG_SRCDIR([softflowd.c])
  16. AM_INIT_AUTOMAKE
  17. AC_CONFIG_HEADER(config.h)
  18. AC_PROG_CC
  19. AC_PROG_INSTALL
  20. # Optional verbose warnings for gcc, see below
  21. WFLAGS="-Wall -Waggregate-return -Wcast-align -Wcast-qual"
  22. WFLAGS="$WFLAGS -Wmissing-declarations -Wmissing-prototypes"
  23. WFLAGS="$WFLAGS -Wno-conversion -Wpointer-arith -Wshadow"
  24. WFLAGS="$WFLAGS -Wuninitialized -Wcast-align -Wcast-qual"
  25. WFLAGS="$WFLAGS -Wformat=2 -Wformat-nonliteral -Wwrite-strings"
  26. # Process flag arguments early, so they are available for tests later
  27. AC_ARG_ENABLE(gcc-warnings,
  28. [ --enable-gcc-warnings Enable verbose warnings (only for gcc)],
  29. [ if test "x$enableval" = "xyes" ; then CFLAGS="$CFLAGS $WFLAGS"; fi ]
  30. )
  31. AC_ARG_ENABLE(legacy,
  32. AC_HELP_STRING([--enable-legacy],
  33. [enable legacy NetFlow implementation (default NO)]),
  34. [legacy=yes],[legacy=no])
  35. AC_ARG_ENABLE(pthread,
  36. AC_HELP_STRING([--enable-pthread], [enable pthread (default NO) (experimental, unstable)]),
  37. [pthread=yes],[pthread=no])
  38. AC_ARG_ENABLE(ntopng,
  39. AC_HELP_STRING([--enable-ntopng], [enable flow sending to ntopng with zeromq (default NO)]),
  40. [ntopng=yes],[ntopng=no])
  41. AC_ARG_ENABLE(flow-spray,
  42. AC_HELP_STRING([--enable-flow-spray],
  43. [enable spray as flow tree type(default is RB)]),
  44. AC_DEFINE([FLOW_SPRAY], 1, [enable spray as flow tree type]),
  45. AC_DEFINE([FLOW_RB], 1, [enable RB(red-black) as flow tree type]))
  46. AC_ARG_ENABLE(expiry-spray,
  47. AC_HELP_STRING([--enable-expiry-spray],
  48. [enable spray as expiry tree type (default is RB)]),
  49. AC_DEFINE([EXPIRY_SPRAY], 1, [enable spray as flow tree type]),
  50. AC_DEFINE([EXPIRY_RB], 1, [enable RB(red-black) as flow tree type]))
  51. AC_ARG_WITH(cflags,
  52. [ --with-cflags Specify additional compiler flags],
  53. [ if test "x$withval" != "xno" ; then CFLAGS="$CFLAGS $withval"; fi ]
  54. )
  55. AC_ARG_WITH(cppflags,
  56. [ --with-cppflags Specify additional preprocessor flags] ,
  57. [ if test "x$withval" != "xno"; then CPPFLAGS="$CPPFLAGS $withval"; fi ]
  58. )
  59. AC_ARG_WITH(ldflags,
  60. [ --with-ldflags Specify additional linker flags],
  61. [ if test "x$withval" != "xno" ; then LDFLAGS="$LDFLAGS $withval"; fi ]
  62. )
  63. AC_ARG_WITH(libs,
  64. [ --with-libs Specify additional libraries to link with],
  65. [ if test "x$withval" != "xno" ; then LIBS="$LIBS $withval"; fi ]
  66. )
  67. AC_ARG_WITH(chrootdir,
  68. [ --with-chrootdir Specify chroot directory],
  69. [ AC_DEFINE_UNQUOTED([PRIVDROP_CHROOT_DIR], ["${withval}"], [privdrop chroot directory]) ]
  70. )
  71. AC_DEFINE([_BSD_SOURCE], [], [Define BSD SOURCE for Linux])
  72. AC_CHECK_HEADERS(net/bpf.h pcap.h pcap-bpf.h sys/endian.h endian.h)
  73. dnl AC_CHECK_HEADERS(netinet/in_systm.h netinet/tcp.h netinet/udp.h)
  74. dnl
  75. dnl # This ugliness is because of autoconf's stupid default include list
  76. dnl AC_CHECK_HEADERS([netinet/ip.h],
  77. dnl [AC_DEFINE([HAVE_HAVE_NETINET_IP_H], 1, [has netinet/ip.h])], [],
  78. dnl [
  79. dnl #include <sys/types.h>
  80. dnl #include <netinet/in.h>
  81. dnl #if HAVE_NETINET_IN_SYSTM_H
  82. dnl #include <netinet/in_systm.h>
  83. dnl #endif
  84. dnl ])
  85. AC_CHECK_MEMBER([struct sockaddr.sa_len],
  86. [AC_DEFINE([SOCK_HAS_LEN], 1, [struct sockaddr contains length])], ,
  87. [#include <sys/types.h>
  88. #include <sys/socket.h>])
  89. AC_CHECK_MEMBER(struct ip6_ext.ip6e_nxt,
  90. [AC_DEFINE([HAVE_STRUCT_IP6_EXT], 1, [struct ip6_ext.ip6e_nxt exists])],
  91. [],
  92. [
  93. #include <sys/types.h>
  94. #include <sys/socket.h>
  95. #include <netinet/in.h>
  96. #include <netinet/ip6.h>
  97. ])
  98. AC_SEARCH_LIBS(daemon, bsd)
  99. AC_SEARCH_LIBS(gethostbyname, nsl)
  100. AC_SEARCH_LIBS(socket, socket)
  101. AC_CHECK_LIB(pcap, pcap_open_live)
  102. AC_CHECK_FUNCS(closefrom daemon setresuid setreuid setresgid setgid strlcpy strlcat strsep)
  103. AC_CHECK_DECLS([htobe64, htonll])
  104. AC_CHECK_TYPES([u_int64_t, int64_t, uint64_t, u_int32_t, int32_t, uint32_t])
  105. AC_CHECK_TYPES([u_int16_t, int16_t, uint16_t, u_int8_t, int8_t, uint8_t])
  106. AC_CHECK_SIZEOF(char, 1)
  107. AC_CHECK_SIZEOF(short int, 2)
  108. AC_CHECK_SIZEOF(int, 4)
  109. AC_CHECK_SIZEOF(long int, 4)
  110. AC_CHECK_SIZEOF(long long int, 8)
  111. if test "x$legacy" = "xyes" ; then
  112. AC_DEFINE([ENABLE_LEGACY], 1, [enable legacy NetFlow implementation])
  113. LEGACY='netflow9.$(OBJEXT) netflow1.$(OBJEXT)'
  114. AC_SUBST([LEGACY])
  115. fi
  116. AM_CONDITIONAL([ENABLE_LEGACY], [test x$legacy = xyes])
  117. if test "x$pthread" = "xyes" ; then
  118. AC_DEFINE([ENABLE_PTHREAD], 1, [enable pthread])
  119. AC_CHECK_LIB(pthread, pthread_create, [],[AC_MSG_ERROR([pthread.h not found])])
  120. AC_CHECK_HEADERS(pthread.h, [],[AC_MSG_ERROR([pthread.h not found])])
  121. fi
  122. if test "x$ntopng" = "xyes" ; then
  123. AC_DEFINE([ENABLE_NTOPNG], 1, [enable ntopng])
  124. AC_CHECK_LIB(zmq, zmq_connect, [],[AC_MSG_ERROR([libzmq not found])])
  125. AC_CHECK_HEADERS(zmq.h, [],[AC_MSG_ERROR([zmq.h not found])])
  126. NTOPNG='ntopng.$(OBJEXT)'
  127. AC_SUBST([NTOPNG])
  128. fi
  129. AM_CONDITIONAL([ENABLE_NTOPNG], [test x$ntopng = xyes])
  130. if test "x$ac_cv_type_uint8_t" = "xyes" ; then
  131. AC_DEFINE([OUR_CFG_U_INT8_T], [uint8_t], [8-bit unsigned int])
  132. elif test "x$ac_cv_sizeof_char" = "x1" ; then
  133. AC_DEFINE([OUR_CFG_U_INT8_T], [unsigned char], [8-bit unsigned int])
  134. else
  135. AC_MSG_ERROR([No 8-bit unsigned int type found])
  136. fi
  137. if test "x$ac_cv_sizeof_char" = "x1" ; then
  138. AC_DEFINE([OUR_CFG_INT8_T], [signed char], [8-bit signed int])
  139. else
  140. AC_MSG_ERROR([No 8-bit signed int type found])
  141. fi
  142. if test "x$ac_cv_type_uint16_t" = "xyes" ; then
  143. AC_DEFINE([OUR_CFG_U_INT16_T], [uint16_t], [16-bit unsigned int])
  144. elif test "x$ac_cv_sizeof_short_int" = "x2" ; then
  145. AC_DEFINE([OUR_CFG_U_INT16_T], [unsigned short int], [16-bit unsigned int])
  146. else
  147. AC_MSG_ERROR([No 16-bit unsigned int type found])
  148. fi
  149. if test "x$ac_cv_sizeof_short_int" = "x2" ; then
  150. AC_DEFINE([OUR_CFG_INT16_T], [short int], [16-bit signed int])
  151. else
  152. AC_MSG_ERROR([No 16-bit signed int type found])
  153. fi
  154. if test "x$ac_cv_type_uint32_t" = "xyes" ; then
  155. AC_DEFINE([OUR_CFG_U_INT32_T], [uint32_t], [32-bit unsigned int])
  156. elif test "x$ac_cv_sizeof_int" = "x4" ; then
  157. AC_DEFINE([OUR_CFG_U_INT32_T], [unsigned int], [32-bit unsigned int])
  158. else
  159. AC_MSG_ERROR([No 32-bit unsigned int type found])
  160. fi
  161. if test "x$ac_cv_sizeof_int" = "x4" ; then
  162. AC_DEFINE([OUR_CFG_INT32_T], [int], [32-bit signed int])
  163. else
  164. AC_MSG_ERROR([No 32-bit signed int type found])
  165. fi
  166. if test "x$ac_cv_type_uint64_t" = "xyes" ; then
  167. AC_DEFINE([OUR_CFG_U_INT64_T], [uint64_t], [64-bit unsigned int])
  168. elif test "x$ac_cv_sizeof_long_int" = "x8" ; then
  169. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long int], [64-bit unsigned int])
  170. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  171. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long long int], [64-bit unsigned int])
  172. else
  173. AC_MSG_ERROR([No 64-bit unsigned int type found])
  174. fi
  175. if test "x$ac_cv_sizeof_long_int" = "x8" ; then
  176. AC_DEFINE([OUR_CFG_INT64_T], [long int], [64-bit signed int])
  177. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  178. AC_DEFINE([OUR_CFG_INT64_T], [long long int], [64-bit signed int])
  179. else
  180. AC_MSG_ERROR([No 64-bit signed int type found])
  181. fi
  182. if test "x$ac_cv_header_pcap_bpf_h" != "xyes" && \
  183. test "x$ac_cv_header_net_bpf_h" != "xyes" ; then
  184. AC_MSG_ERROR([No BPF header found])
  185. fi
  186. if test "x$ac_cv_header_pcap_h" != "xyes" ; then
  187. AC_MSG_ERROR([No pcap.h header found])
  188. fi
  189. if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes" ; then
  190. AC_MSG_ERROR([libpcap not found])
  191. fi
  192. AC_EXEEXT
  193. AC_CONFIG_FILES([Makefile])
  194. AC_OUTPUT