1dnl
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([foreign])
33
34AC_PROG_CC
35AC_PROG_LIBTOOL
36AC_CANONICAL_HOST
37AC_CONFIG_MACRO_DIR([m4])
38
39dnl Disable pkg_config support for now
40dnl PKG_PROG_PKG_CONFIG
41dnl PKG_INSTALLDIR
42
43LIBCFLAGS="-DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__"
44APPCFLAGS=""
45
46case $host_os in
47darwin*)
48  CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
49  LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin"
50  ;;
51dragonfly*)
52  CFLAGS="$CFLAGS -std=c99 -pthread"
53  LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly"
54  ;;
55freebsd*)
56  CFLAGS="$CFLAGS -std=c99 -pthread"
57  if $CC --version | grep -q clang; then
58    CFLAGS="$CFLAGS -Wno-unknown-warning-option"
59    LDFLAGS="$LDFLAGS -Qunused-arguments"
60  fi
61  LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD"
62  ;;
63linux*)
64  CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member"
65  LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
66  ;;
67netbsd*)
68  CFLAGS="$CFLAGS -std=c99 -pthread"
69  LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD"
70  ;;
71openbsd*)
72  CFLAGS="$CFLAGS -std=c99 -pthread"
73  LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD"
74  ;;
75solaris*)
76  CFLAGS="$CFLAGS -D_XPG4_2"
77  ;;
78esac
79
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
100AC_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
108AC_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])
114        CFLAGS="$CFLAGS -g -O0"
115fi
116
117AC_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
122        APPCFLAGS="$APPCFLAGS -DINET"
123        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
131        APPCFLAGS="$APPCFLAGS -DINET6"
132        AC_DEFINE(INET6, 1, [Support IPv6])
133fi
134
135AC_ARG_ENABLE(programs,
136  AC_HELP_STRING( [--enable-programs],
137                  [build example programs @<:@default=yes@:>@]),
138    enable_programs=$enableval,enable_programs=yes)
139AM_CONDITIONAL([COND_PROGRAMS], [test "$enable_programs" = yes])
140
141AC_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
147AC_CHECK_HEADERS(stdatomic.h)
148AC_CHECK_HEADERS(sys/queue.h)
149AC_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>])
152
153AC_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
158                 #include <sys/socket.h>])
159
160AC_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
167AC_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.]),,
176                [#include "usrsctplib/usrsctp.h"])
177
178AC_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>],
183               [socklen_t x; x = 1; return ((int)x);],
184               [AC_MSG_RESULT(yes)],
185               [AC_MSG_RESULT(int)
186                AC_DEFINE(socklen_t, int, [Define a type for socklen_t.])])
187
188AC_C_BIGENDIAN
189
190AC_SUBST([LIBCFLAGS])
191AC_SUBST([APPCFLAGS])
192dnl AC_CONFIG_FILES([usrsctp.pc])
193AC_CONFIG_FILES(usrsctplib/Makefile programs/Makefile Makefile)
194AC_OUTPUT
195