configure.ac 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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.1.0])
  15. AC_CONFIG_SRCDIR([softflowd.c])
  16. AM_INIT_AUTOMAKE
  17. AC_CONFIG_HEADERS([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. AS_HELP_STRING([--enable-legacy],[enable legacy NetFlow implementation (default NO)]),
  33. [legacy=yes],[legacy=no])
  34. AC_ARG_ENABLE(pthread,
  35. AS_HELP_STRING([--enable-pthread],[enable pthread (default NO) (experimental, unstable)]),
  36. [pthread=yes],[pthread=no])
  37. AC_ARG_ENABLE(ntopng,
  38. AS_HELP_STRING([--enable-ntopng],[enable flow sending to ntopng with zeromq (default NO)]),
  39. [ntopng=yes],[ntopng=no])
  40. AC_ARG_ENABLE(ifname,
  41. AS_HELP_STRING([--enable-ifname],[enable flow reporting iface name in normal data of v9 and IPFIX (default NO)]),
  42. [ifname=yes],[ifname=no])
  43. AC_ARG_ENABLE(flow-spray,
  44. AS_HELP_STRING([--enable-flow-spray],[enable spray as flow tree type(default is RB)]),
  45. AC_DEFINE([FLOW_SPRAY], 1, [enable spray as flow tree type]),
  46. AC_DEFINE([FLOW_RB], 1, [enable RB(red-black) as flow tree type]))
  47. AC_ARG_ENABLE(expiry-spray,
  48. AS_HELP_STRING([--enable-expiry-spray],[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$ifname" = "xyes" ; then
  131. AC_DEFINE([ENABLE_IFNAME], 1, [enable reporting iface name])
  132. fi
  133. if test "x$ac_cv_type_uint8_t" = "xyes" ; then
  134. AC_DEFINE([OUR_CFG_U_INT8_T], [uint8_t], [8-bit unsigned int])
  135. elif test "x$ac_cv_sizeof_char" = "x1" ; then
  136. AC_DEFINE([OUR_CFG_U_INT8_T], [unsigned char], [8-bit unsigned int])
  137. else
  138. AC_MSG_ERROR([No 8-bit unsigned int type found])
  139. fi
  140. if test "x$ac_cv_sizeof_char" = "x1" ; then
  141. AC_DEFINE([OUR_CFG_INT8_T], [signed char], [8-bit signed int])
  142. else
  143. AC_MSG_ERROR([No 8-bit signed int type found])
  144. fi
  145. if test "x$ac_cv_type_uint16_t" = "xyes" ; then
  146. AC_DEFINE([OUR_CFG_U_INT16_T], [uint16_t], [16-bit unsigned int])
  147. elif test "x$ac_cv_sizeof_short_int" = "x2" ; then
  148. AC_DEFINE([OUR_CFG_U_INT16_T], [unsigned short int], [16-bit unsigned int])
  149. else
  150. AC_MSG_ERROR([No 16-bit unsigned int type found])
  151. fi
  152. if test "x$ac_cv_sizeof_short_int" = "x2" ; then
  153. AC_DEFINE([OUR_CFG_INT16_T], [short int], [16-bit signed int])
  154. else
  155. AC_MSG_ERROR([No 16-bit signed int type found])
  156. fi
  157. if test "x$ac_cv_type_uint32_t" = "xyes" ; then
  158. AC_DEFINE([OUR_CFG_U_INT32_T], [uint32_t], [32-bit unsigned int])
  159. elif test "x$ac_cv_sizeof_int" = "x4" ; then
  160. AC_DEFINE([OUR_CFG_U_INT32_T], [unsigned int], [32-bit unsigned int])
  161. else
  162. AC_MSG_ERROR([No 32-bit unsigned int type found])
  163. fi
  164. if test "x$ac_cv_sizeof_int" = "x4" ; then
  165. AC_DEFINE([OUR_CFG_INT32_T], [int], [32-bit signed int])
  166. else
  167. AC_MSG_ERROR([No 32-bit signed int type found])
  168. fi
  169. if test "x$ac_cv_type_uint64_t" = "xyes" ; then
  170. AC_DEFINE([OUR_CFG_U_INT64_T], [uint64_t], [64-bit unsigned int])
  171. elif test "x$ac_cv_sizeof_long_int" = "x8" ; then
  172. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long int], [64-bit unsigned int])
  173. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  174. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long long int], [64-bit unsigned int])
  175. else
  176. AC_MSG_ERROR([No 64-bit unsigned int type found])
  177. fi
  178. if test "x$ac_cv_sizeof_long_int" = "x8" ; then
  179. AC_DEFINE([OUR_CFG_INT64_T], [long int], [64-bit signed int])
  180. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  181. AC_DEFINE([OUR_CFG_INT64_T], [long long int], [64-bit signed int])
  182. else
  183. AC_MSG_ERROR([No 64-bit signed int type found])
  184. fi
  185. if test "x$ac_cv_header_pcap_bpf_h" != "xyes" && \
  186. test "x$ac_cv_header_net_bpf_h" != "xyes" ; then
  187. AC_MSG_ERROR([No BPF header found])
  188. fi
  189. if test "x$ac_cv_header_pcap_h" != "xyes" ; then
  190. AC_MSG_ERROR([No pcap.h header found])
  191. fi
  192. if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes" ; then
  193. AC_MSG_ERROR([libpcap not found])
  194. fi
  195. AC_CANONICAL_HOST
  196. case "$host_os" in
  197. linux-gnu*)
  198. AC_DEFINE([LINUX], [], [Linux OS])
  199. ;;
  200. esac
  201. AC_EXEEXT
  202. AC_CONFIG_FILES([Makefile])
  203. AC_OUTPUT