configure.ac 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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
  15. AC_CONFIG_SRCDIR([softflowd.c])
  16. AC_CONFIG_HEADER(config.h)
  17. AC_PROG_CC
  18. AC_PROG_INSTALL
  19. # Optional verbose warnings for gcc, see below
  20. WFLAGS="-Wall -Waggregate-return -Wcast-align -Wcast-qual"
  21. WFLAGS="$WFLAGS -Wmissing-declarations -Wmissing-prototypes"
  22. WFLAGS="$WFLAGS -Wno-conversion -Wpointer-arith -Wshadow"
  23. WFLAGS="$WFLAGS -Wuninitialized -Wcast-align -Wcast-qual"
  24. WFLAGS="$WFLAGS -Wformat=2 -Wformat-nonliteral -Wwrite-strings"
  25. # Process flag arguments early, so they are available for tests later
  26. AC_ARG_ENABLE(gcc-warnings,
  27. [ --enable-gcc-warnings Enable verbose warnings (only for gcc)],
  28. [ if test "x$enableval" = "xyes" ; then CFLAGS="$CFLAGS $WFLAGS"; fi ]
  29. )
  30. AC_ARG_WITH(cflags,
  31. [ --with-cflags Specify additional compiler flags],
  32. [ if test "x$withval" != "xno" ; then CFLAGS="$CFLAGS $withval"; fi ]
  33. )
  34. AC_ARG_WITH(cppflags,
  35. [ --with-cppflags Specify additional preprocessor flags] ,
  36. [ if test "x$withval" != "xno"; then CPPFLAGS="$CPPFLAGS $withval"; fi ]
  37. )
  38. AC_ARG_WITH(ldflags,
  39. [ --with-ldflags Specify additional linker flags],
  40. [ if test "x$withval" != "xno" ; then LDFLAGS="$LDFLAGS $withval"; fi ]
  41. )
  42. AC_ARG_WITH(libs,
  43. [ --with-libs Specify additional libraries to link with],
  44. [ if test "x$withval" != "xno" ; then LIBS="$LIBS $withval"; fi ]
  45. )
  46. AC_ARG_WITH(chrootdir,
  47. [ --with-chrootdir Specify chroot directory],
  48. [ AC_DEFINE_UNQUOTED([PRIVDROP_CHROOT_DIR], ["${withval}"], [privdrop chroot directory]) ]
  49. )
  50. AC_CHECK_HEADERS(net/bpf.h pcap.h pcap-bpf.h)
  51. dnl AC_CHECK_HEADERS(netinet/in_systm.h netinet/tcp.h netinet/udp.h)
  52. dnl
  53. dnl # This ugliness is because of autoconf's stupid default include list
  54. dnl AC_CHECK_HEADERS([netinet/ip.h],
  55. dnl [AC_DEFINE([HAVE_HAVE_NETINET_IP_H], 1, [has netinet/ip.h])], [],
  56. dnl [
  57. dnl #include <sys/types.h>
  58. dnl #include <netinet/in.h>
  59. dnl #if HAVE_NETINET_IN_SYSTM_H
  60. dnl #include <netinet/in_systm.h>
  61. dnl #endif
  62. dnl ])
  63. AC_CHECK_MEMBER([struct sockaddr.sa_len],
  64. [AC_DEFINE([SOCK_HAS_LEN], 1, [struct sockaddr contains length])], ,
  65. [#include <sys/types.h>
  66. #include <sys/socket.h>])
  67. AC_CHECK_MEMBER(struct ip6_ext.ip6e_nxt,
  68. [AC_DEFINE([HAVE_STRUCT_IP6_EXT], 1, [struct ip6_ext.ip6e_nxt exists])],
  69. [],
  70. [
  71. #include <sys/types.h>
  72. #include <sys/socket.h>
  73. #include <netinet/in.h>
  74. #include <netinet/ip6.h>
  75. ])
  76. AC_SEARCH_LIBS(daemon, bsd)
  77. AC_SEARCH_LIBS(gethostbyname, nsl)
  78. AC_SEARCH_LIBS(socket, socket)
  79. AC_CHECK_LIB(pcap, pcap_open_live)
  80. AC_CHECK_FUNCS(closefrom daemon setresuid setreuid setresgid setgid strlcpy strlcat)
  81. AC_CHECK_TYPES([u_int64_t, int64_t, uint64_t, u_int32_t, int32_t, uint32_t])
  82. AC_CHECK_TYPES([u_int16_t, int16_t, uint16_t, u_int8_t, int8_t, uint8_t])
  83. AC_CHECK_SIZEOF(char, 1)
  84. AC_CHECK_SIZEOF(short int, 2)
  85. AC_CHECK_SIZEOF(int, 4)
  86. AC_CHECK_SIZEOF(long int, 4)
  87. AC_CHECK_SIZEOF(long long int, 8)
  88. if test "x$ac_cv_type_uint8_t" = "xyes" ; then
  89. AC_DEFINE([OUR_CFG_U_INT8_T], [uint8_t], [8-bit unsigned int])
  90. elif test "x$ac_cv_sizeof_char" = "x1" ; then
  91. AC_DEFINE([OUR_CFG_U_INT8_T], [unsigned char], [8-bit unsigned int])
  92. else
  93. AC_MSG_ERROR([No 8-bit unsigned int type found])
  94. fi
  95. if test "x$ac_cv_sizeof_char" = "x1" ; then
  96. AC_DEFINE([OUR_CFG_INT8_T], [signed char], [8-bit signed int])
  97. else
  98. AC_MSG_ERROR([No 8-bit signed int type found])
  99. fi
  100. if test "x$ac_cv_type_uint16_t" = "xyes" ; then
  101. AC_DEFINE([OUR_CFG_U_INT16_T], [uint16_t], [16-bit unsigned int])
  102. elif test "x$ac_cv_sizeof_short_int" = "x2" ; then
  103. AC_DEFINE([OUR_CFG_U_INT16_T], [unsigned short int], [16-bit unsigned int])
  104. else
  105. AC_MSG_ERROR([No 16-bit unsigned int type found])
  106. fi
  107. if test "x$ac_cv_sizeof_short_int" = "x2" ; then
  108. AC_DEFINE([OUR_CFG_INT16_T], [short int], [16-bit signed int])
  109. else
  110. AC_MSG_ERROR([No 16-bit signed int type found])
  111. fi
  112. if test "x$ac_cv_type_uint32_t" = "xyes" ; then
  113. AC_DEFINE([OUR_CFG_U_INT32_T], [uint32_t], [32-bit unsigned int])
  114. elif test "x$ac_cv_sizeof_int" = "x4" ; then
  115. AC_DEFINE([OUR_CFG_U_INT32_T], [unsigned int], [32-bit unsigned int])
  116. else
  117. AC_MSG_ERROR([No 32-bit unsigned int type found])
  118. fi
  119. if test "x$ac_cv_sizeof_int" = "x4" ; then
  120. AC_DEFINE([OUR_CFG_INT32_T], [int], [32-bit signed int])
  121. else
  122. AC_MSG_ERROR([No 32-bit signed int type found])
  123. fi
  124. if test "x$ac_cv_type_uint64_t" = "xyes" ; then
  125. AC_DEFINE([OUR_CFG_U_INT64_T], [uint64_t], [64-bit unsigned int])
  126. elif test "x$ac_cv_sizeof_long_int" = "x8" ; then
  127. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long int], [64-bit unsigned int])
  128. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  129. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long long int], [64-bit unsigned int])
  130. else
  131. AC_MSG_ERROR([No 64-bit unsigned int type found])
  132. fi
  133. if test "x$ac_cv_sizeof_long_int" = "x8" ; then
  134. AC_DEFINE([OUR_CFG_INT64_T], [long int], [64-bit signed int])
  135. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  136. AC_DEFINE([OUR_CFG_INT64_T], [long long int], [64-bit signed int])
  137. else
  138. AC_MSG_ERROR([No 64-bit signed int type found])
  139. fi
  140. if test "x$ac_cv_header_pcap_bpf_h" != "xyes" && \
  141. test "x$ac_cv_header_net_bpf_h" != "xyes" ; then
  142. AC_MSG_ERROR([No BPF header found])
  143. fi
  144. if test "x$ac_cv_header_pcap_h" != "xyes" ; then
  145. AC_MSG_ERROR([No pcap.h header found])
  146. fi
  147. if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes" ; then
  148. AC_MSG_ERROR([libpcap not found])
  149. fi
  150. AC_EXEEXT
  151. AC_CONFIG_FILES([Makefile])
  152. AC_OUTPUT