-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
290 lines (252 loc) · 10.8 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# ======================== initialization ===============================
AC_INIT([SIPp], [see-include/version.h], [[email protected]], [sipp])
# Load non-standard m4 files from ./m4/*.m4.
# AC_CONFIG_MACRO_DIR([m4]) does not work on pre-1.13 aclocal, so we
# have to include all files by hand.
m4_include([m4/am_git_version.m4])
m4_include([m4/ax_check_compile_flag.m4])
m4_include([m4/ax_config_feature.m4])
m4_include([m4/ax_cxx_compile_stdcxx.m4])
m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
m4_include([m4/ax_have_epoll.m4])
AC_CANONICAL_TARGET
AC_CONFIG_SRCDIR([src/sipp.cpp])
AC_CONFIG_HEADERS([include/config.h])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_ARG_WITH([openssl],AC_HELP_STRING([--with-openssl], [build with OpenSSL support]), [openssl="$withval"],[openssl="no"])
AC_ARG_WITH([pcap],AC_HELP_STRING([--with-pcap], [build with pcap support]), [pcap="$withval"],[pcap="no"])
AC_ARG_WITH([sctp],AC_HELP_STRING([--with-sctp], [build with SCTP support]), [sctp="$withval"],[sctp="no"])
AC_ARG_WITH([gsl],AC_HELP_STRING([--with-gsl], [build with GSL (GNU Scientific Library) support]), [gsl="$withval"],[gsl="no"])
AC_ARG_WITH([rtpstream],AC_HELP_STRING([--without-rtpstream], [build without RTP streaming support]), [rtp="$withval"],[rtp="yes"])
AC_ARG_ENABLE([epoll],
AC_HELP_STRING([--enable-epoll], [build with epoll backend]),
[case "$enableval" in
yes | no) epoll="$enableval" ;;
*) AC_MSG_ERROR(bad value $enableval for --enable-epoll) ;;
esac],
[epoll="yes"])
AC_PATH_PROG([HELP2MAN], help2man)
AM_CONDITIONAL([HAVE_HELP2MAN], [test -n "$HELP2MAN"])
if test x"$HELP2MAN" = x; then
AC_MSG_WARN([cannot find help2man, you will not be able to generate manpages])
fi
# ==================== basic compiler settings ==========================
AC_PROG_CC
AC_PROG_CXX
AC_HEADER_STDC
# Prefer ext (gnu++11) over noext (c++11) because on some platforms the
# noext (stricter) mode disables non-posix features like stdio fileno().
AX_CXX_COMPILE_STDCXX_11(ext,optional)
AX_CHECK_COMPILE_FLAG([-std=gnu11],
[CFLAGS+=" -std=gnu11"],
[])
case "$host" in
*-linux*)
CFLAGS="$CFLAGS -D__LINUX"
CPPFLAGS="$CPPFLAGS -D__LINUX"
;;
*-darwin*)
CFLAGS="$CFLAGS -D__DARWIN"
CPPFLAGS="$CPPFLAGS -D__DARWIN"
;;
*-hpux*)
CFLAGS="$CFLAGS -D__HPUX"
CPPFLAGS="$CPPFLAGS -D__HPUX"
;;
*-freebsd*)
CFLAGS="$CFLAGS -D__LINUX -I/usr/local/include"
CPPFLAGS="$CPPFLAGS -D__LINUX -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
;;
*-sunos*|*-solaris2*)
CFLAGS="$CFLAGS -D__SUNOS"
CPPFLAGS="$CPPFLAGS -D__SUNOS"
;;
*-cygwin*)
CFLAGS="$CFLAGS -D__CYGWIN -I /usr/include/ncurses -I /usr/lib/WpdPack/Include -I /usr/include/SctpDrv"
CPPFLAGS="$CPPFLAGS -D__CYGWIN -I /usr/include/ncurses -I /usr/lib/WpdPack/Include -I /usr/include/SctpDrv"
LDFLAGS="$LDFLAGS -L /usr/lib/WpdPack/Lib -L /usr/lib/SctpDrv"
;;
*-tru64*)
CFLAGS="$CFLAGS -D__OSF1"
CPPFLAGS="$CPPFLAGS -D__OSF1"
;;
esac
# ==================== checks for libraries =============================
AC_CHECK_LIB(curses,initscr)
if test x$ac_cv_lib_curses_initscr = xno; then
AC_CHECK_LIB(ncurses,initscr)
if test x$ac_cv_lib_ncurses_initscr = xno; then
AC_MSG_ERROR([ncurses library missing])
fi
fi
AC_CHECK_LIB(pthread, pthread_mutex_init, THREAD_LIBS="-lpthread",
AC_MSG_ERROR(pthread library needed!))
# For Linux and SunOS
AC_SEARCH_LIBS([dlopen], [dl])
AC_SEARCH_LIBS([dlerror], [dl])
AC_SEARCH_LIBS([dlsym], [dl])
# For glibc pre-2.17 we need -rt
AC_SEARCH_LIBS([clock_gettime], [rt])
# For SunOS
AC_SEARCH_LIBS([inet_addr], [nsl])
AC_SEARCH_LIBS([inet_ntoa], [nsl])
AC_SEARCH_LIBS([pthread_mutex_init], [pthread])
AC_SEARCH_LIBS([pthread_mutex_destroy], [pthread])
AC_SEARCH_LIBS([pthread_mutex_lock], [pthread])
AC_SEARCH_LIBS([pthread_mutex_unlock], [pthread])
AC_SEARCH_LIBS([pthread_self], [pthread])
AC_SEARCH_LIBS([pthread_cancel], [pthread])
AC_SEARCH_LIBS([pthread_join], [pthread])
AC_SEARCH_LIBS([pthread_attr_init], [pthread])
AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread])
AC_SEARCH_LIBS([pthread_create], [pthread])
AC_SEARCH_LIBS([pthread_attr_destroy], [pthread])
AC_SEARCH_LIBS([pthread_setschedparam], [pthread])
AC_SEARCH_LIBS([pthread_setcancelstate], [pthread])
AC_SEARCH_LIBS([pthread_setcanceltype], [pthread])
AC_SEARCH_LIBS([pthread_exit], [pthread])
AC_SEARCH_LIBS([pthread_sigmask], [pthread])
#AC_SEARCH_LIBS([pthread_cleanup_push], [pthread]) <- macro
#AC_SEARCH_LIBS([pthread_cleanup_pop], [pthread]) <- macro
AC_SEARCH_LIBS([floor], [m])
AC_SEARCH_LIBS([pow], [m])
# For SunOS
AC_SEARCH_LIBS([htons], [socket])
AC_SEARCH_LIBS([ntohs], [socket])
AC_SEARCH_LIBS([bind], [socket])
AC_SEARCH_LIBS([freeaddrinfo], [socket])
AC_SEARCH_LIBS([getaddrinfo], [socket])
AC_SEARCH_LIBS([listen], [socket])
AC_SEARCH_LIBS([recvfrom], [socket])
AC_SEARCH_LIBS([shutdown], [socket])
# For Linux, SunOS and Cygwin
#AC_CHECK_LIB(stdc++,main,,[AC_MSG_ERROR([stdc++ library missing])])
# Conditional build with OpenSSL
if test "$openssl" = 'yes'; then
AC_CHECK_HEADERS([openssl/bio.h],,[AC_MSG_ERROR([<openssl/bio.h> header missing])])
AC_CHECK_HEADERS([openssl/err.h],,[AC_MSG_ERROR([<openssl/err.h> header missing])])
AC_CHECK_HEADERS([openssl/rand.h],,[AC_MSG_ERROR([<openssl/rand.h> header missing])])
AC_CHECK_HEADERS([openssl/ssl.h],,[AC_MSG_ERROR([<openssl/ssl.h> header missing])])
AC_CHECK_HEADERS([openssl/x509v3.h],,[AC_MSG_ERROR([<openssl/x509v3.h> header missing])])
AC_CHECK_LIB([ssl], [SSL_library_init],,[AC_MSG_ERROR([ssl library missing])])
AC_CHECK_LIB([crypto], [CRYPTO_num_locks],,[AC_MSG_ERROR([crypto library missing])])
fi
# For Makefile.am
AM_CONDITIONAL(HAVE_OPENSSL, test "$openssl" = "yes")
# Conditional build with SCTP
if test "$sctp" = 'yes'; then
AC_CHECK_HEADERS([netinet/sctp.h],,[AC_MSG_WARN([<netinet/sctp.h> header missing, but this is acceptable on Mac OS X Lion])])
AC_SEARCH_LIBS([sctp_send],[sctp sctpsp],,[AC_MSG_ERROR([SCTP library missing])])
AC_SEARCH_LIBS([sctp_freepaddrs],[sctp sctpsp],,[AC_MSG_ERROR([SCTP library missing])])
AC_SEARCH_LIBS([sctp_bindx],[sctp sctpsp],,[AC_MSG_ERROR([SCTP library missing])])
AC_SEARCH_LIBS([sctp_recvmsg],[sctp sctpsp],,[AC_MSG_ERROR([SCTP library missing])])
fi
# For Makefile.am
AM_CONDITIONAL(HAVE_SCTP, test "$sctp" = "yes")
# Conditional build with pcap
if test "$pcap" = 'yes'; then
AC_CHECK_HEADERS([pcap.h],,[AC_MSG_ERROR([<pcap.h> header missing])])
AC_SEARCH_LIBS([pcap_open_offline],[pcap wpcap],,[AC_MSG_ERROR([pcap library missing])])
AC_SEARCH_LIBS([pcap_next],[pcap wpcap],,[AC_MSG_ERROR([pcap library missing])])
AC_SEARCH_LIBS([pcap_close],[pcap wpcap],,[AC_MSG_ERROR([pcap library missing])])
AC_CHECK_LIB([pcap],[pcap_next_ex],AC_DEFINE([HAVE_PCAP_NEXT_EX],[1],[Define to 1 if libpcap has the pcap_next_ex function.]))
fi
# For Makefile.am
AM_CONDITIONAL(HAVE_PCAP, test "$pcap" = "yes")
AM_CONDITIONAL(HAVE_RTP, test "$rtp" = "yes")
# Conditional build with pcap
if test "$gsl" = 'yes'; then
AC_CHECK_HEADERS([gsl/gsl_randist.h],,[AC_MSG_ERROR([<gsl/gsl_randist.h> header missing])])
AC_CHECK_HEADERS([gsl/gsl_rng.h],,[AC_MSG_ERROR([<gsl/gsl_rng.h> header missing])])
AC_CHECK_HEADERS([gsl/gsl_cdf.h],,[AC_MSG_ERROR([<gsl/gsl_cdf.h> header missing])])
AC_CHECK_LIB([m],[cos])
AC_CHECK_LIB([gslcblas], [cblas_dgemm])
AC_CHECK_LIB([gsl], [gsl_rng_alloc],
[
GSL_CFLAGS=`pkg-config gsl --cflags`
GSL_CXXFLAGS=`pkg-config gsl --cflags`
GSL_LIBS=`pkg-config gsl --libs`
AC_SUBST([GSL_CFLAGS])
AC_SUBST([GSL_CXXFLAGS])
AC_SUBST([GSL_LIBS])
]
,[AC_MSG_ERROR([gsl library missing])])
fi
# For Makefile.am
AM_CONDITIONAL(HAVE_GSL, test "$gsl" = "yes")
if test "$epoll" = 'yes'; then
AX_HAVE_EPOLL([AX_CONFIG_FEATURE_ENABLE(epoll)],
[AX_CONFIG_FEATURE_DISABLE(epoll)])
AX_CONFIG_FEATURE([epoll], [This platform supports epoll(7)],
[HAVE_EPOLL], [This platform supports epoll(7).],
[epoll="yes"], [epoll="no"])
fi
AM_CONDITIONAL(HAVE_EPOLL, test "$epoll" = "yes")
# ==================== checks for header files ==========================
AC_FUNC_ALLOCA
AC_CHECK_HEADERS([arpa/inet.h endian.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/endian.h sys/socket.h sys/time.h unistd.h])
# ===== checks for typedefs, structures and compiler characteristics ====
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# These conflict with netinet/in.h typedefs.
#AC_TYPE_UINT16_T
#AC_TYPE_UINT32_T
#AC_TYPE_UINT8_T
# ==================== checks for library functions =====================
AC_FUNC_FORK
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
#AC_FUNC_STRTOD
AC_CHECK_FUNCS([alarm dup2 floor gethostname gettimeofday inet_ntoa memmove memset pow regcomp socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strrchr strstr strtol strtoul strtoull])
# Check for le16toh in both endian.h and sys/endian.h (for BSD).
AC_CHECK_DECLS([le16toh], [], [],
[#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif
#ifdef HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif])
# ==================== check for clang/gmock workaround =================
# clang++ falls over the use of is_default_constructible, suggesting
# is_nothrow_constructible instead.
#
# ./gmock/include/gmock/gmock-actions.h:107:19: error: no template named
# 'is_default_constructible' in namespace 'std'; did you mean
# 'is_nothrow_constructible'?
# T, ::std::is_default_constructible<T>::value>::Get();
# ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# is_nothrow_constructible
# /usr/include/c++/4.6/type_traits:705:12: note:
# 'is_nothrow_constructible' declared here
#
AC_DEFUN([AX_CXX_HAS_IS_DEFAULT_CONSTRUCTIBLE], [dnl
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports is_default_constructible (used by gmock),
ax_cv_cxx_has_is_default_constructible,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <type_traits>
template <class T>
void test_is_default_constructible() {
static_assert(std::is_default_constructible<T>::value, "");
}
int main() {
test_is_default_constructible<int>();
return 0;
}
])],
[ax_cv_cxx_has_is_default_constructible=yes],
[ax_cv_cxx_has_is_default_constructible=no])])
if test x$ax_cv_cxx_has_is_default_constructible = xno; then
CPPFLAGS="$CPPFLAGS -Dis_default_constructible=is_nothrow_constructible"
fi
AC_LANG_POP([C++])
])
AX_CXX_HAS_IS_DEFAULT_CONSTRUCTIBLE()
# ==================== generate files ===================================
AC_CONFIG_FILES([Makefile])
AC_OUTPUT