blob: e2bdf5a2c72817cfffc90b29024cd3c292591be2 [file] [log] [blame]
James Kuszmaul4cb043c2021-01-17 11:25:51 -08001dnl
2dnl Copyright (C) 2011-2012 Michael Tuexen
3dnl
4dnl All rights reserved.
5dnl
6dnl Redistribution and use in source and binary forms, with or without
7dnl modification, are permitted provided that the following conditions
8dnl are met:
9dnl 1. Redistributions of source code must retain the above copyright
10dnl notice, this list of conditions and the following disclaimer.
11dnl 2. Redistributions in binary form must reproduce the above copyright
12dnl notice, this list of conditions and the following disclaimer in the
13dnl documentation and/or other materials provided with the distribution.
14dnl 3. Neither the name of the project nor the names of its contributors
15dnl may be used to endorse or promote products derived from this software
16dnl without specific prior written permission.
17dnl
18dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28dnl SUCH DAMAGE.
29dnl
30
31AC_INIT([libusrsctp], [0.9.3.0])
32AM_INIT_AUTOMAKE
33
34AC_PROG_CC
35AC_PROG_LIBTOOL
36AC_CANONICAL_HOST
37AC_CONFIG_MACRO_DIR([m4])
38
39LIBCFLAGS="-DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__"
40case $host_os in
41darwin*)
42 CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
43 LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin"
44 ;;
45dragonfly*)
46 CFLAGS="$CFLAGS -std=c99 -pthread"
47 LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly"
48 ;;
49freebsd*)
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 ;;
56linux*)
57 CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE"
58 LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
59 ;;
60netbsd*)
61 CFLAGS="$CFLAGS -std=c99 -pthread"
62 LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD"
63 ;;
64openbsd*)
65 CFLAGS="$CFLAGS -std=c99 -pthread"
66 LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD"
67 ;;
68solaris*)
69 CFLAGS="$CFLAGS -D_XPG4_2"
70 ;;
71esac
72
73if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
74 ac_supports_gcc_flags=yes
75fi
76
77if test "x$ac_supports_gcc_flags" = "xyes" ; then
78 CFLAGS="$CFLAGS -pedantic -Wall"
79fi
80
81AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
82AC_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)
86if test "x$ac_supports_gcc_flags" = "xyes" -a x$enable_warnings_as_errors = xyes; then
87 AC_MSG_RESULT(yes)
88 CFLAGS="$CFLAGS -Werror"
89else
90 AC_MSG_RESULT(no)
91fi
92
93AC_ARG_ENABLE(invariants,
94 AC_HELP_STRING( [--enable-invariants],
95 [add additional runtime checks @<:@default=no@:>@]),
96 enable_invariants=$enableval,enable_invariants=no)
97if test x$enable_invariants = xyes; then
98 AC_DEFINE(INVARIANTS, 1, [Add additional runtime checks])
99fi
100
101AC_ARG_ENABLE(debug,
102 AC_HELP_STRING( [--enable-debug],
103 [provide debug information @<:@default=yes@:>@]),
104 enable_debug=$enableval,enable_debug=yes)
105if test x$enable_debug = xyes; then
106 AC_DEFINE(SCTP_DEBUG, 1, [Provide debug information])
107 CFLAGS="$CFLAGS -g -O0"
108fi
109
110AC_ARG_ENABLE(inet,
111 AC_HELP_STRING( [--enable-inet],
112 [Support IPv4 @<:@default=yes@:>@]),
113 enable_inet=$enableval,enable_inet=yes)
114if test x$enable_inet = xyes; then
115 AC_DEFINE(INET, 1, [Support IPv4])
116fi
117
118AC_ARG_ENABLE(inet6,
119 AC_HELP_STRING( [--enable-inet6],
120 [Support IPv6 @<:@default=yes@:>@]),
121 enable_inet6=$enableval,enable_inet6=yes)
122if test x$enable_inet6 = xyes; then
123 AC_DEFINE(INET6, 1, [Support IPv6])
124fi
125
126AC_CHECK_TYPE(size_t)
127AC_CHECK_TYPE(ssize_t)
128
129AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
130AC_CHECK_FUNCS(inet_addr, , AC_CHECK_LIB(nsl, inet_addr))
131
132AC_CHECK_HEADERS(stdatomic.h)
133AC_CHECK_HEADERS(sys/queue.h)
134AC_CHECK_HEADERS(linux/if_addr.h, [], [], [#include <sys/socket.h>])
135AC_CHECK_HEADERS(linux/rtnetlink.h, [], [], [#include <sys/socket.h>])
136AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [], [#include <netinet/ip.h>])
137
138AC_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
145AC_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
152AC_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
159AC_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
163AC_MSG_CHECKING(for socklen_t)
164AC_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
173AC_C_BIGENDIAN
174
175AC_SUBST([LIBCFLAGS])
176AC_OUTPUT(Makefile usrsctplib/Makefile programs/Makefile)