blob: 8825fb91e7190e93f83189591dd18789f117c2c2 [file] [log] [blame]
tuexenbdbed9a2012-05-23 09:13:55 +00001dnl
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
Michael Tuexend553a032016-04-08 11:10:11 -030031AC_INIT([libusrsctp], [0.9.3.0])
Christian Wright899b19a2018-09-12 11:30:58 +120032AM_INIT_AUTOMAKE([foreign])
tuexend37aa5e2011-11-01 20:19:04 +000033
Michael Tuexen09aadc62015-09-04 10:01:54 +020034AC_PROG_CC
tuexenf45025c2011-11-01 23:00:31 +000035AC_PROG_LIBTOOL
tuexend37aa5e2011-11-01 20:19:04 +000036AC_CANONICAL_HOST
tuexen8e332e72011-11-04 06:59:54 +000037AC_CONFIG_MACRO_DIR([m4])
tuexend37aa5e2011-11-01 20:19:04 +000038
Michael Tuexen96f26062017-01-09 12:59:53 +010039dnl Disable pkg_config support for now
40dnl PKG_PROG_PKG_CONFIG
41dnl PKG_INSTALLDIR
Michael Tuexen8679f2b2017-01-06 13:16:03 +010042
t00fcxena336e832013-09-02 23:00:20 +000043LIBCFLAGS="-DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__"
Michael Tuexen8679f2b2017-01-06 13:16:03 +010044APPCFLAGS=""
45
tuexend37aa5e2011-11-01 20:19:04 +000046case $host_os in
tuexenf45025c2011-11-01 23:00:31 +000047darwin*)
Michael Tuexena37b2e82017-10-14 12:08:00 +020048 CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
t00fcxen5cbc6832012-09-04 18:22:18 +000049 LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin"
tuexenf45025c2011-11-01 23:00:31 +000050 ;;
t00fcxen652291c2013-12-27 19:21:25 +000051dragonfly*)
Michael Tuexen078ff322015-09-26 17:26:47 +020052 CFLAGS="$CFLAGS -std=c99 -pthread"
t00fcxen652291c2013-12-27 19:21:25 +000053 LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly"
tuexenf45025c2011-11-01 23:00:31 +000054 ;;
55freebsd*)
Michael Tuexen078ff322015-09-26 17:26:47 +020056 CFLAGS="$CFLAGS -std=c99 -pthread"
t00fcxen5628b4c2012-09-16 07:43:07 +000057 if $CC --version | grep -q clang; then
Michael Tuexena37b2e82017-10-14 12:08:00 +020058 CFLAGS="$CFLAGS -Wno-unknown-warning-option"
t00fcxen8795d462012-09-16 07:14:53 +000059 LDFLAGS="$LDFLAGS -Qunused-arguments"
t00fcxenb130f0a2012-09-15 19:10:42 +000060 fi
t00fcxen5cbc6832012-09-04 18:22:18 +000061 LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD"
tuexenf45025c2011-11-01 23:00:31 +000062 ;;
t00fcxen652291c2013-12-27 19:21:25 +000063linux*)
Michael Tuexen078ff322015-09-26 17:26:47 +020064 CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE"
65 LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
t00fcxen652291c2013-12-27 19:21:25 +000066 ;;
67netbsd*)
Michael Tuexen078ff322015-09-26 17:26:47 +020068 CFLAGS="$CFLAGS -std=c99 -pthread"
t00fcxen652291c2013-12-27 19:21:25 +000069 LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD"
70 ;;
t00fcxen8f236c52013-02-27 12:53:23 +000071openbsd*)
Michael Tuexen078ff322015-09-26 17:26:47 +020072 CFLAGS="$CFLAGS -std=c99 -pthread"
t00fcxen8f236c52013-02-27 12:53:23 +000073 LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD"
74 ;;
tuexend37aa5e2011-11-01 20:19:04 +000075solaris*)
76 CFLAGS="$CFLAGS -D_XPG4_2"
77 ;;
78esac
Michael Tuexen078ff322015-09-26 17:26:47 +020079
80if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
81 ac_supports_gcc_flags=yes
82fi
83
84if test "x$ac_supports_gcc_flags" = "xyes" ; then
85 CFLAGS="$CFLAGS -pedantic -Wall"
86fi
87
88AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
89AC_ARG_ENABLE(warnings-as-errors,
90 AC_HELP_STRING( [--enable-warnings-as-errors],
91 [treat warnings as errors (only for GCC or clang) @<:@default=yes@:>@]),
92 enable_warnings_as_errors=$enableval,enable_warnings_as_errors=yes)
93if test "x$ac_supports_gcc_flags" = "xyes" -a x$enable_warnings_as_errors = xyes; then
94 AC_MSG_RESULT(yes)
95 CFLAGS="$CFLAGS -Werror"
96else
97 AC_MSG_RESULT(no)
98fi
99
Michael Tuexen700f96c2015-11-03 22:11:18 +0100100AC_ARG_ENABLE(invariants,
101 AC_HELP_STRING( [--enable-invariants],
102 [add additional runtime checks @<:@default=no@:>@]),
103 enable_invariants=$enableval,enable_invariants=no)
104if test x$enable_invariants = xyes; then
105 AC_DEFINE(INVARIANTS, 1, [Add additional runtime checks])
106fi
107
tuexen3a9fb2f2011-11-04 08:27:30 +0000108AC_ARG_ENABLE(debug,
109 AC_HELP_STRING( [--enable-debug],
110 [provide debug information @<:@default=yes@:>@]),
111 enable_debug=$enableval,enable_debug=yes)
112if test x$enable_debug = xyes; then
113 AC_DEFINE(SCTP_DEBUG, 1, [Provide debug information])
Michael Tuexen1e3c3902015-11-07 20:40:16 +0100114 CFLAGS="$CFLAGS -g -O0"
tuexen3a9fb2f2011-11-04 08:27:30 +0000115fi
116
tuexen08d7ac62012-06-28 16:54:10 +0000117AC_ARG_ENABLE(inet,
118 AC_HELP_STRING( [--enable-inet],
119 [Support IPv4 @<:@default=yes@:>@]),
120 enable_inet=$enableval,enable_inet=yes)
121if test x$enable_inet = xyes; then
Michael Tuexen8679f2b2017-01-06 13:16:03 +0100122 APPCFLAGS="$APPCFLAGS -DINET"
tuexen08d7ac62012-06-28 16:54:10 +0000123 AC_DEFINE(INET, 1, [Support IPv4])
124fi
125
126AC_ARG_ENABLE(inet6,
127 AC_HELP_STRING( [--enable-inet6],
128 [Support IPv6 @<:@default=yes@:>@]),
129 enable_inet6=$enableval,enable_inet6=yes)
130if test x$enable_inet6 = xyes; then
Michael Tuexen8679f2b2017-01-06 13:16:03 +0100131 APPCFLAGS="$APPCFLAGS -DINET6"
tuexen08d7ac62012-06-28 16:54:10 +0000132 AC_DEFINE(INET6, 1, [Support IPv6])
133fi
134
Michael Tuexen281024f2017-07-24 09:01:35 +0200135AC_ARG_ENABLE(programs,
136 AC_HELP_STRING( [--enable-programs],
137 [build example programs @<:@default=yes@:>@]),
138 enable_programs=$enableval,enable_programs=yes)
Christian Wrightb92b2a52018-09-12 11:33:58 +1200139AM_CONDITIONAL([COND_PROGRAMS], [test "$enable_programs" = yes])
Michael Tuexen281024f2017-07-24 09:01:35 +0200140
tuexend37aa5e2011-11-01 20:19:04 +0000141AC_CHECK_TYPE(size_t)
142AC_CHECK_TYPE(ssize_t)
143
144AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
145AC_CHECK_FUNCS(inet_addr, , AC_CHECK_LIB(nsl, inet_addr))
146
Michael Tuexen0f628812016-11-23 17:19:53 +0100147AC_CHECK_HEADERS(stdatomic.h)
t00fcxend22e2982015-03-16 21:26:43 +0000148AC_CHECK_HEADERS(sys/queue.h)
t00fcxenc9859102015-02-16 12:23:06 +0000149AC_CHECK_HEADERS(linux/if_addr.h, [], [], [#include <sys/socket.h>])
150AC_CHECK_HEADERS(linux/rtnetlink.h, [], [], [#include <sys/socket.h>])
151AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [], [#include <netinet/ip.h>])
t00fcxen0cd71862012-09-04 20:21:12 +0000152
t00fcxena8a26f62012-09-12 19:24:54 +0000153AC_CHECK_MEMBER(struct sockaddr.sa_len,
154 AC_DEFINE(HAVE_SA_LEN, 1, [Define this if your stack has sa_len in sockaddr struct.]),,
155 [#ifdef HAVE_SYS_TYPES_H
156 #include <sys/types.h>
157 #endif
t00fcxen12b6c0c2012-09-14 18:50:54 +0000158 #include <sys/socket.h>])
t00fcxena8a26f62012-09-12 19:24:54 +0000159
tuexend37aa5e2011-11-01 20:19:04 +0000160AC_CHECK_MEMBER(struct sockaddr_in.sin_len,
161 AC_DEFINE(HAVE_SIN_LEN, 1, [Define this if your IPv4 has sin_len in sockaddr_in struct.]),,
162 [#ifdef HAVE_SYS_TYPES_H
163 #include <sys/types.h>
164 #endif
165 #include <netinet/in.h>])
166
t00fcxen8fbaee32012-09-04 16:41:39 +0000167AC_CHECK_MEMBER(struct sockaddr_in6.sin6_len,
168 AC_DEFINE(HAVE_SIN6_LEN, 1, [Define this if your IPv6 has sin6_len in sockaddr_in6 struct.]),,
169 [#ifdef HAVE_SYS_TYPES_H
170 #include <sys/types.h>
171 #endif
172 #include <netinet/in.h>])
173
174AC_CHECK_MEMBER(struct sockaddr_conn.sconn_len,
175 AC_DEFINE(HAVE_SCONN_LEN, 1, [Define this if your userland stack has sconn_len in sockaddr_conn struct.]),,
t00fcxen12b6c0c2012-09-14 18:50:54 +0000176 [#include "usrsctplib/usrsctp.h"])
t00fcxen8fbaee32012-09-04 16:41:39 +0000177
tuexend37aa5e2011-11-01 20:19:04 +0000178AC_MSG_CHECKING(for socklen_t)
179AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
180 #include <sys/types.h>
181 #endif
182 #include <sys/socket.h>],
t00fcxenb39e8c82012-09-14 18:22:18 +0000183 [socklen_t x; x = 1; return ((int)x);],
tuexend37aa5e2011-11-01 20:19:04 +0000184 [AC_MSG_RESULT(yes)],
185 [AC_MSG_RESULT(int)
tuexen218ed842012-04-19 15:40:50 +0000186 AC_DEFINE(socklen_t, int, [Define a type for socklen_t.])])
tuexend37aa5e2011-11-01 20:19:04 +0000187
t00fcxen8bfe4502012-09-04 20:56:36 +0000188AC_C_BIGENDIAN
189
t00fcxen5cbc6832012-09-04 18:22:18 +0000190AC_SUBST([LIBCFLAGS])
Michael Tuexen8679f2b2017-01-06 13:16:03 +0100191AC_SUBST([APPCFLAGS])
Michael Tuexen96f26062017-01-09 12:59:53 +0100192dnl AC_CONFIG_FILES([usrsctp.pc])
Christian Wrightb92b2a52018-09-12 11:33:58 +1200193AC_CONFIG_FILES(usrsctplib/Makefile programs/Makefile Makefile)
194AC_OUTPUT