James Kuszmaul | 4cb043c | 2021-01-17 11:25:51 -0800 | [diff] [blame^] | 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 | |
| 31 | AC_INIT([libusrsctp], [0.9.3.0]) |
| 32 | AM_INIT_AUTOMAKE |
| 33 | |
| 34 | AC_PROG_CC |
| 35 | AC_PROG_LIBTOOL |
| 36 | AC_CANONICAL_HOST |
| 37 | AC_CONFIG_MACRO_DIR([m4]) |
| 38 | |
| 39 | LIBCFLAGS="-DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__" |
| 40 | case $host_os in |
| 41 | darwin*) |
| 42 | CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292" |
| 43 | LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin" |
| 44 | ;; |
| 45 | dragonfly*) |
| 46 | CFLAGS="$CFLAGS -std=c99 -pthread" |
| 47 | LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly" |
| 48 | ;; |
| 49 | freebsd*) |
| 50 | CFLAGS="$CFLAGS -std=c99 -pthread" |
| 51 | if $CC --version | grep -q clang; then |
| 52 | LDFLAGS="$LDFLAGS -Qunused-arguments" |
| 53 | fi |
| 54 | LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD" |
| 55 | ;; |
| 56 | linux*) |
| 57 | CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE" |
| 58 | LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux" |
| 59 | ;; |
| 60 | netbsd*) |
| 61 | CFLAGS="$CFLAGS -std=c99 -pthread" |
| 62 | LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD" |
| 63 | ;; |
| 64 | openbsd*) |
| 65 | CFLAGS="$CFLAGS -std=c99 -pthread" |
| 66 | LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD" |
| 67 | ;; |
| 68 | solaris*) |
| 69 | CFLAGS="$CFLAGS -D_XPG4_2" |
| 70 | ;; |
| 71 | esac |
| 72 | |
| 73 | if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then |
| 74 | ac_supports_gcc_flags=yes |
| 75 | fi |
| 76 | |
| 77 | if test "x$ac_supports_gcc_flags" = "xyes" ; then |
| 78 | CFLAGS="$CFLAGS -pedantic -Wall" |
| 79 | fi |
| 80 | |
| 81 | AC_MSG_CHECKING(whether we should treat compiler warnings as errors) |
| 82 | AC_ARG_ENABLE(warnings-as-errors, |
| 83 | AC_HELP_STRING( [--enable-warnings-as-errors], |
| 84 | [treat warnings as errors (only for GCC or clang) @<:@default=yes@:>@]), |
| 85 | enable_warnings_as_errors=$enableval,enable_warnings_as_errors=yes) |
| 86 | if test "x$ac_supports_gcc_flags" = "xyes" -a x$enable_warnings_as_errors = xyes; then |
| 87 | AC_MSG_RESULT(yes) |
| 88 | CFLAGS="$CFLAGS -Werror" |
| 89 | else |
| 90 | AC_MSG_RESULT(no) |
| 91 | fi |
| 92 | |
| 93 | AC_ARG_ENABLE(invariants, |
| 94 | AC_HELP_STRING( [--enable-invariants], |
| 95 | [add additional runtime checks @<:@default=no@:>@]), |
| 96 | enable_invariants=$enableval,enable_invariants=no) |
| 97 | if test x$enable_invariants = xyes; then |
| 98 | AC_DEFINE(INVARIANTS, 1, [Add additional runtime checks]) |
| 99 | fi |
| 100 | |
| 101 | AC_ARG_ENABLE(debug, |
| 102 | AC_HELP_STRING( [--enable-debug], |
| 103 | [provide debug information @<:@default=yes@:>@]), |
| 104 | enable_debug=$enableval,enable_debug=yes) |
| 105 | if test x$enable_debug = xyes; then |
| 106 | AC_DEFINE(SCTP_DEBUG, 1, [Provide debug information]) |
| 107 | CFLAGS="$CFLAGS -g -O0" |
| 108 | fi |
| 109 | |
| 110 | AC_ARG_ENABLE(inet, |
| 111 | AC_HELP_STRING( [--enable-inet], |
| 112 | [Support IPv4 @<:@default=yes@:>@]), |
| 113 | enable_inet=$enableval,enable_inet=yes) |
| 114 | if test x$enable_inet = xyes; then |
| 115 | AC_DEFINE(INET, 1, [Support IPv4]) |
| 116 | fi |
| 117 | |
| 118 | AC_ARG_ENABLE(inet6, |
| 119 | AC_HELP_STRING( [--enable-inet6], |
| 120 | [Support IPv6 @<:@default=yes@:>@]), |
| 121 | enable_inet6=$enableval,enable_inet6=yes) |
| 122 | if test x$enable_inet6 = xyes; then |
| 123 | AC_DEFINE(INET6, 1, [Support IPv6]) |
| 124 | fi |
| 125 | |
| 126 | AC_CHECK_TYPE(size_t) |
| 127 | AC_CHECK_TYPE(ssize_t) |
| 128 | |
| 129 | AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket)) |
| 130 | AC_CHECK_FUNCS(inet_addr, , AC_CHECK_LIB(nsl, inet_addr)) |
| 131 | |
| 132 | AC_CHECK_HEADERS(stdatomic.h) |
| 133 | AC_CHECK_HEADERS(sys/queue.h) |
| 134 | AC_CHECK_HEADERS(linux/if_addr.h, [], [], [#include <sys/socket.h>]) |
| 135 | AC_CHECK_HEADERS(linux/rtnetlink.h, [], [], [#include <sys/socket.h>]) |
| 136 | AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [], [#include <netinet/ip.h>]) |
| 137 | |
| 138 | AC_CHECK_MEMBER(struct sockaddr.sa_len, |
| 139 | AC_DEFINE(HAVE_SA_LEN, 1, [Define this if your stack has sa_len in sockaddr struct.]),, |
| 140 | [#ifdef HAVE_SYS_TYPES_H |
| 141 | #include <sys/types.h> |
| 142 | #endif |
| 143 | #include <sys/socket.h>]) |
| 144 | |
| 145 | AC_CHECK_MEMBER(struct sockaddr_in.sin_len, |
| 146 | AC_DEFINE(HAVE_SIN_LEN, 1, [Define this if your IPv4 has sin_len in sockaddr_in struct.]),, |
| 147 | [#ifdef HAVE_SYS_TYPES_H |
| 148 | #include <sys/types.h> |
| 149 | #endif |
| 150 | #include <netinet/in.h>]) |
| 151 | |
| 152 | AC_CHECK_MEMBER(struct sockaddr_in6.sin6_len, |
| 153 | AC_DEFINE(HAVE_SIN6_LEN, 1, [Define this if your IPv6 has sin6_len in sockaddr_in6 struct.]),, |
| 154 | [#ifdef HAVE_SYS_TYPES_H |
| 155 | #include <sys/types.h> |
| 156 | #endif |
| 157 | #include <netinet/in.h>]) |
| 158 | |
| 159 | AC_CHECK_MEMBER(struct sockaddr_conn.sconn_len, |
| 160 | AC_DEFINE(HAVE_SCONN_LEN, 1, [Define this if your userland stack has sconn_len in sockaddr_conn struct.]),, |
| 161 | [#include "usrsctplib/usrsctp.h"]) |
| 162 | |
| 163 | AC_MSG_CHECKING(for socklen_t) |
| 164 | AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H |
| 165 | #include <sys/types.h> |
| 166 | #endif |
| 167 | #include <sys/socket.h>], |
| 168 | [socklen_t x; x = 1; return ((int)x);], |
| 169 | [AC_MSG_RESULT(yes)], |
| 170 | [AC_MSG_RESULT(int) |
| 171 | AC_DEFINE(socklen_t, int, [Define a type for socklen_t.])]) |
| 172 | |
| 173 | AC_C_BIGENDIAN |
| 174 | |
| 175 | AC_SUBST([LIBCFLAGS]) |
| 176 | AC_OUTPUT(Makefile usrsctplib/Makefile programs/Makefile) |