configure.ac 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. # $Id: configure.ac,v 1.5 2004/11/08 23:03:28 djm Exp $
  2. #
  3. # Copyright (c) 2004 Damien Miller
  4. #
  5. # Permission to use, copy, modify, and distribute this software for any
  6. # purpose with or without fee is hereby granted, provided that the above
  7. # copyright notice and this permission notice appear in all copies.
  8. #
  9. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. AC_INIT
  17. AC_CONFIG_SRCDIR([softflowd.c])
  18. AC_CONFIG_HEADER(config.h)
  19. AC_PROG_CC
  20. AC_PROG_INSTALL
  21. # Optional verbose warnings for gcc, see below
  22. WFLAGS="-Wall -Waggregate-return -Wcast-align -Wcast-qual"
  23. WFLAGS="$WFLAGS -Wmissing-declarations -Wmissing-prototypes"
  24. WFLAGS="$WFLAGS -Wno-conversion -Wpointer-arith -Wshadow"
  25. WFLAGS="$WFLAGS -Wuninitialized -Wcast-align -Wcast-qual"
  26. WFLAGS="$WFLAGS -WformatC=2 -Wformat-nonliteral -Wwrite-strings"
  27. # Process flag arguments early, so they are available for tests later
  28. AC_ARG_ENABLE(gcc-warnings,
  29. [ --enable-gcc-warnings Enable verbose warnings (only for gcc)],
  30. [ if test "x$enableval" = "xyes" ; then CFLAGS="$CFLAGS $WFLAGS"; fi ]
  31. )
  32. AC_ARG_WITH(cflags,
  33. [ --with-cflags Specify additional compiler flags],
  34. [ if test "x$withval" != "xno" ; then CFLAGS="$CFLAGS $withval"; fi ]
  35. )
  36. AC_ARG_WITH(cppflags,
  37. [ --with-cppflags Specify additional preprocessor flags] ,
  38. [ if test "x$withval" != "xno"; then CPPFLAGS="$CPPFLAGS $withval"; fi ]
  39. )
  40. AC_ARG_WITH(ldflags,
  41. [ --with-ldflags Specify additional linker flags],
  42. [ if test "x$withval" != "xno" ; then LDFLAGS="$LDFLAGS $withval"; fi ]
  43. )
  44. AC_ARG_WITH(libs,
  45. [ --with-libs Specify additional libraries to link with],
  46. [ if test "x$withval" != "xno" ; then LIBS="$LIBS $withval"; fi ]
  47. )
  48. AC_CHECK_HEADERS(net/bpf.h pcap.h pcap-bpf.h)
  49. dnl AC_CHECK_HEADERS(netinet/in_systm.h netinet/tcp.h netinet/udp.h)
  50. dnl
  51. dnl # This ugliness is because of autoconf's stupid default include list
  52. dnl AC_CHECK_HEADERS([netinet/ip.h],
  53. dnl [AC_DEFINE([HAVE_HAVE_NETINET_IP_H], 1, [has netinet/ip.h])], [],
  54. dnl [
  55. dnl #include <sys/types.h>
  56. dnl #include <netinet/in.h>
  57. dnl #if HAVE_NETINET_IN_SYSTM_H
  58. dnl #include <netinet/in_systm.h>
  59. dnl #endif
  60. dnl ])
  61. AC_CHECK_MEMBER([struct sockaddr.sa_len],
  62. [AC_DEFINE([SOCK_HAS_LEN], 1, [struct sockaddr contains length])], ,
  63. [#include <sys/types.h>
  64. #include <sys/socket.h>])
  65. AC_CHECK_MEMBER(struct ip6_ext.ip6e_nxt,
  66. [AC_DEFINE([HAVE_STRUCT_IP6_EXT], 1, [struct ip6_ext.ip6e_nxt exists])],
  67. [],
  68. [
  69. #include <sys/types.h>
  70. #include <sys/socket.h>
  71. #include <netinet/in.h>
  72. #include <netinet/ip6.h>
  73. ])
  74. AC_SEARCH_LIBS(daemon, bsd)
  75. AC_SEARCH_LIBS(gethostbyname, nsl)
  76. AC_SEARCH_LIBS(socket, socket)
  77. AC_CHECK_LIB(pcap, pcap_open_live)
  78. AC_CHECK_FUNCS(closefrom daemon setresuid setreuid setresgid setgid strlcpy strlcat)
  79. AC_CHECK_TYPES([u_int64_t, int64_t, uint64_t, u_int32_t, int32_t, uint32_t])
  80. AC_CHECK_TYPES([u_int16_t, int16_t, uint16_t, u_int8_t, int8_t, uint8_t])
  81. AC_CHECK_SIZEOF(char, 1)
  82. AC_CHECK_SIZEOF(short int, 2)
  83. AC_CHECK_SIZEOF(int, 4)
  84. AC_CHECK_SIZEOF(long int, 4)
  85. AC_CHECK_SIZEOF(long long int, 8)
  86. if test "x$ac_cv_type_uint8_t" = "xyes" ; then
  87. AC_DEFINE([OUR_CFG_U_INT8_T], [uint8_t], [8-bit unsigned int])
  88. elif test "x$ac_cv_sizeof_char" = "x1" ; then
  89. AC_DEFINE([OUR_CFG_U_INT8_T], [unsigned char], [8-bit unsigned int])
  90. else
  91. AC_MSG_ERROR([No 8-bit unsigned int type found])
  92. fi
  93. if test "x$ac_cv_sizeof_char" = "x1" ; then
  94. AC_DEFINE([OUR_CFG_INT8_T], [signed char], [8-bit signed int])
  95. else
  96. AC_MSG_ERROR([No 8-bit signed int type found])
  97. fi
  98. if test "x$ac_cv_type_uint16_t" = "xyes" ; then
  99. AC_DEFINE([OUR_CFG_U_INT16_T], [uint16_t], [16-bit unsigned int])
  100. elif test "x$ac_cv_sizeof_short_int" = "x2" ; then
  101. AC_DEFINE([OUR_CFG_U_INT16_T], [unsigned short int], [16-bit unsigned int])
  102. else
  103. AC_MSG_ERROR([No 16-bit unsigned int type found])
  104. fi
  105. if test "x$ac_cv_sizeof_short_int" = "x2" ; then
  106. AC_DEFINE([OUR_CFG_INT16_T], [short int], [16-bit signed int])
  107. else
  108. AC_MSG_ERROR([No 16-bit signed int type found])
  109. fi
  110. if test "x$ac_cv_type_uint32_t" = "xyes" ; then
  111. AC_DEFINE([OUR_CFG_U_INT32_T], [uint32_t], [32-bit unsigned int])
  112. elif test "x$ac_cv_sizeof_int" = "x4" ; then
  113. AC_DEFINE([OUR_CFG_U_INT32_T], [unsigned int], [32-bit unsigned int])
  114. else
  115. AC_MSG_ERROR([No 32-bit unsigned int type found])
  116. fi
  117. if test "x$ac_cv_sizeof_int" = "x4" ; then
  118. AC_DEFINE([OUR_CFG_INT32_T], [int], [32-bit signed int])
  119. else
  120. AC_MSG_ERROR([No 32-bit signed int type found])
  121. fi
  122. if test "x$ac_cv_type_uint64_t" = "xyes" ; then
  123. AC_DEFINE([OUR_CFG_U_INT64_T], [uint64_t], [64-bit unsigned int])
  124. elif test "x$ac_cv_sizeof_long_int" = "x8" ; then
  125. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long int], [64-bit unsigned int])
  126. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  127. AC_DEFINE([OUR_CFG_U_INT64_T], [unsigned long long int], [64-bit unsigned int])
  128. else
  129. AC_MSG_ERROR([No 64-bit unsigned int type found])
  130. fi
  131. if test "x$ac_cv_sizeof_long_int" = "x8" ; then
  132. AC_DEFINE([OUR_CFG_INT64_T], [long int], [64-bit signed int])
  133. elif test "x$ac_cv_sizeof_long_long_int" = "x8" ; then
  134. AC_DEFINE([OUR_CFG_INT64_T], [long long int], [64-bit signed int])
  135. else
  136. AC_MSG_ERROR([No 64-bit signed int type found])
  137. fi
  138. if test "x$ac_cv_header_pcap_bpf_h" != "xyes" && \
  139. test "x$ac_cv_header_net_bpf_h" != "xyes" ; then
  140. AC_MSG_ERROR([No BPF header found])
  141. fi
  142. if test "x$ac_cv_header_pcap_h" != "xyes" ; then
  143. AC_MSG_ERROR([No pcap.h header found])
  144. fi
  145. if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes" ; then
  146. AC_MSG_ERROR([libpcap not found])
  147. fi
  148. AC_EXEEXT
  149. AC_CONFIG_FILES([Makefile])
  150. AC_OUTPUT