configure.ac 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. dnl
  2. dnl Copyright (C) 2011-2012 Michael Tuexen
  3. dnl
  4. dnl All rights reserved.
  5. dnl
  6. dnl Redistribution and use in source and binary forms, with or without
  7. dnl modification, are permitted provided that the following conditions
  8. dnl are met:
  9. dnl 1. Redistributions of source code must retain the above copyright
  10. dnl notice, this list of conditions and the following disclaimer.
  11. dnl 2. Redistributions in binary form must reproduce the above copyright
  12. dnl notice, this list of conditions and the following disclaimer in the
  13. dnl documentation and/or other materials provided with the distribution.
  14. dnl 3. Neither the name of the project nor the names of its contributors
  15. dnl may be used to endorse or promote products derived from this software
  16. dnl without specific prior written permission.
  17. dnl
  18. dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  19. dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  22. dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. dnl SUCH DAMAGE.
  29. dnl
  30. AC_INIT([libusrsctp], [0.9.5.0])
  31. AM_INIT_AUTOMAKE([foreign])
  32. AC_PROG_CC
  33. AC_PROG_LIBTOOL
  34. AC_CANONICAL_HOST
  35. AC_CONFIG_MACRO_DIR([m4])
  36. dnl Disable pkg_config support for now
  37. dnl PKG_PROG_PKG_CONFIG
  38. dnl PKG_INSTALLDIR
  39. LIBCFLAGS="-DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__"
  40. APPCFLAGS=""
  41. case $host_os in
  42. darwin*)
  43. CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
  44. ;;
  45. dragonfly*)
  46. CFLAGS="$CFLAGS -std=c99 -pthread"
  47. ;;
  48. freebsd*)
  49. CFLAGS="$CFLAGS -std=c99 -pthread"
  50. if $CC --version | grep -q clang; then
  51. CFLAGS="$CFLAGS -Wno-unknown-warning-option"
  52. LDFLAGS="$LDFLAGS -Qunused-arguments"
  53. fi
  54. ;;
  55. linux*)
  56. CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member"
  57. ;;
  58. netbsd*)
  59. CFLAGS="$CFLAGS -std=c99 -pthread"
  60. ;;
  61. openbsd*)
  62. CFLAGS="$CFLAGS -std=c99 -pthread"
  63. ;;
  64. solaris*)
  65. CFLAGS="$CFLAGS -D_XPG4_2"
  66. ;;
  67. esac
  68. if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
  69. ac_supports_gcc_flags=yes
  70. fi
  71. if test "x$ac_supports_gcc_flags" = "xyes" ; then
  72. CFLAGS="$CFLAGS -pedantic -Wall"
  73. fi
  74. AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
  75. AC_ARG_ENABLE(warnings-as-errors,
  76. AC_HELP_STRING( [--enable-warnings-as-errors],
  77. [treat warnings as errors (only for GCC or clang) @<:@default=yes@:>@]),
  78. enable_warnings_as_errors=$enableval,enable_warnings_as_errors=yes)
  79. if test "x$ac_supports_gcc_flags" = "xyes" -a x$enable_warnings_as_errors = xyes; then
  80. AC_MSG_RESULT(yes)
  81. CFLAGS="$CFLAGS -Werror"
  82. else
  83. AC_MSG_RESULT(no)
  84. fi
  85. AC_ARG_ENABLE(invariants,
  86. AC_HELP_STRING( [--enable-invariants],
  87. [add additional runtime checks @<:@default=no@:>@]),
  88. enable_invariants=$enableval,enable_invariants=no)
  89. if test x$enable_invariants = xyes; then
  90. AC_DEFINE(INVARIANTS, 1, [Add additional runtime checks])
  91. fi
  92. AC_ARG_ENABLE(debug,
  93. AC_HELP_STRING( [--enable-debug],
  94. [provide debug information @<:@default=yes@:>@]),
  95. enable_debug=$enableval,enable_debug=yes)
  96. if test x$enable_debug = xyes; then
  97. AC_DEFINE(SCTP_DEBUG, 1, [Provide debug information])
  98. CFLAGS="$CFLAGS -g -O0"
  99. fi
  100. AC_ARG_ENABLE(inet,
  101. AC_HELP_STRING( [--enable-inet],
  102. [Support IPv4 @<:@default=yes@:>@]),
  103. enable_inet=$enableval,enable_inet=yes)
  104. if test x$enable_inet = xyes; then
  105. APPCFLAGS="$APPCFLAGS -DINET"
  106. AC_DEFINE(INET, 1, [Support IPv4])
  107. fi
  108. AC_ARG_ENABLE(inet6,
  109. AC_HELP_STRING( [--enable-inet6],
  110. [Support IPv6 @<:@default=yes@:>@]),
  111. enable_inet6=$enableval,enable_inet6=yes)
  112. if test x$enable_inet6 = xyes; then
  113. APPCFLAGS="$APPCFLAGS -DINET6"
  114. AC_DEFINE(INET6, 1, [Support IPv6])
  115. fi
  116. AC_ARG_ENABLE(programs,
  117. AC_HELP_STRING( [--enable-programs],
  118. [build example programs @<:@default=yes@:>@]),
  119. enable_programs=$enableval,enable_programs=yes)
  120. AM_CONDITIONAL([COND_PROGRAMS], [test "$enable_programs" = yes])
  121. AC_CHECK_TYPE(size_t)
  122. AC_CHECK_TYPE(ssize_t)
  123. AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
  124. AC_CHECK_FUNCS(inet_addr, , AC_CHECK_LIB(nsl, inet_addr))
  125. AC_CHECK_HEADERS(stdatomic.h)
  126. AC_CHECK_HEADERS(sys/queue.h)
  127. AC_CHECK_HEADERS(linux/if_addr.h, [], [], [#include <sys/socket.h>])
  128. AC_CHECK_HEADERS(linux/rtnetlink.h, [], [], [#include <sys/socket.h>])
  129. AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [], [#include <netinet/ip.h>])
  130. AC_CHECK_HEADERS(net/route.h, [], [],
  131. [#ifdef HAVE_SYS_TYPES_H
  132. #include <sys/types.h>
  133. #endif
  134. #include <sys/socket.h>])
  135. AC_CHECK_MEMBER(struct sockaddr.sa_len,
  136. AC_DEFINE(HAVE_SA_LEN, 1, [Define this if your stack has sa_len in sockaddr struct.]),,
  137. [#ifdef HAVE_SYS_TYPES_H
  138. #include <sys/types.h>
  139. #endif
  140. #include <sys/socket.h>])
  141. AC_CHECK_MEMBER(struct sockaddr_in.sin_len,
  142. AC_DEFINE(HAVE_SIN_LEN, 1, [Define this if your IPv4 has sin_len in sockaddr_in struct.]),,
  143. [#ifdef HAVE_SYS_TYPES_H
  144. #include <sys/types.h>
  145. #endif
  146. #include <netinet/in.h>])
  147. AC_CHECK_MEMBER(struct sockaddr_in6.sin6_len,
  148. AC_DEFINE(HAVE_SIN6_LEN, 1, [Define this if your IPv6 has sin6_len in sockaddr_in6 struct.]),,
  149. [#ifdef HAVE_SYS_TYPES_H
  150. #include <sys/types.h>
  151. #endif
  152. #include <netinet/in.h>])
  153. AC_CHECK_MEMBER(struct sockaddr_conn.sconn_len,
  154. AC_DEFINE(HAVE_SCONN_LEN, 1, [Define this if your userland stack has sconn_len in sockaddr_conn struct.]),,
  155. [#include "usrsctplib/usrsctp.h"])
  156. AC_MSG_CHECKING(for socklen_t)
  157. AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
  158. #include <sys/types.h>
  159. #endif
  160. #include <sys/socket.h>],
  161. [socklen_t x; x = 1; return ((int)x);],
  162. [AC_MSG_RESULT(yes)],
  163. [AC_MSG_RESULT(int)
  164. AC_DEFINE(socklen_t, int, [Define a type for socklen_t.])])
  165. AC_C_BIGENDIAN
  166. AC_SUBST([LIBCFLAGS])
  167. AC_SUBST([APPCFLAGS])
  168. dnl AC_CONFIG_FILES([usrsctp.pc])
  169. AC_CONFIG_FILES(usrsctplib/Makefile programs/Makefile Makefile)
  170. AC_OUTPUT