forked from PhirePhly/aprx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
316 lines (267 loc) · 10.2 KB
/
configure.in
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([aprx.h])
dnl For automake
VERSION="`cat VERSION`"
PACKAGE=aprx
dnl AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
AC_PROG_MAKE_SET
AC_CONFIG_HEADERS([config.h])
dnl Checks for programs.
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
dnl AC_PATH_PROG(LD, ld, ld)dnl
if test -z "$LD" ; then
LD="$CC"
fi
AC_SUBST(LD,"$LD")
dnl If on i686, we'll need -march=i686 to get the atomic instructions
dnl On FreeBSD, the architecture is i386.
MACHINE="`uname -m`"
if test "$MACHINE" == "i686" -o "$MACHINE" == "i386"; then
CFLAGS_ARCH="-march=i686"
fi
OS="`uname`"
if test "$OS" == "Darwin"; then
CFLAGS_ARCH=""
fi
AC_SUBST(CFLAGS_ARCH)
dnl Check for GNU make
AX_CHECK_GNU_MAKE()
dnl Check for headers.
AC_CHECK_HEADERS(time.h sys/time.h stdlib.h stddef.h stdint.h)
AC_CHECK_HEADERS(string.h strings.h)
AC_CHECK_HEADERS(pty.h)
AC_CHECK_HEADERS(pthread.h)
dnl Checks for system headers
AC_CHECK_HEADERS([alloca.h], AC_DEFINE([HAVE_ALLOCA_H]))
AC_CHECK_HEADERS([poll.h], AC_DEFINE([HAVE_POLL_H]))
dnl AC_CHECK_FUNC(ppoll,,[Probably have ppoll of Linux])
AC_CHECK_HEADERS([sys/epoll.h], AC_DEFINE([HAVE_SYS_EPOLL_H]))
dnl SCTP checks
AC_CHECK_HEADERS([netinet/sctp.h], AC_DEFINE([HAVE_NETINET_SCTP_H]))
dnl Check for varargs
AC_CHECK_HEADERS(stdarg.h varargs.h sys/wait.h)
AC_FUNC_VPRINTF
dnl This group must be after header tests
AC_MSG_RESULT([** Using C compiler: $CC])
AC_MSG_RESULT([** Using CFLAGS: $CFLAGS])
AC_MSG_RESULT([** Using CPPDEP: $CPPDEP])
AC_C_BIGENDIAN
dnl AC_INLINE
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(double)
dnl AC_DEFINE_UNQUOTED(CONFIGURE_CMD,"$0 $ac_configure_args")
AC_DEFINE_UNQUOTED(CONFIGURE_CMD,
"CC='$CC' CFLAGS='$CFLAGS' $0 $ac_configure_args",
[Configuration command line])
dnl Checks for libraries.
AC_SUBST(LIBM)
AC_CHECK_FUNCS(atan2f,,
AC_CHECK_LIB(m, atan2f,
[LIBM="-lm"]))
AC_CHECK_FUNCS(memchr memrchr gettimeofday)
dnl Checks for library functions.
AC_CHECK_FUNCS(openpty,,
AC_CHECK_LIB(util, openpty,
[AC_DEFINE(HAVE_OPENPTY,1,[])] [LIBS="$LIBS -lutil"]))
dnl Check for user options
dnl The "EMBEDDED" is now always on, replaced with --with-erlangstorage
AC_DEFINE(EMBEDDED,1,[Define for an embedded target])
AC_ARG_WITH(embedded, [ --with-embedded When desiring to target as embedded],
[AC_DEFINE(EMBEDDED,1,[Define for an embedded target]) EMBEDDED=1])
AC_ARG_WITH(erlangstorage, [ --with-erlangstorage When desiring a longer term backing storage on erlang datasets. NOT compatible with EMBEDDED, REQUIRES FILESYSTEM!],
[AC_DEFINE(ERLANGSTORAGE,1,[Define for a non-embedded system with filesystem based Erlang history storage]) ERLANGSTORAGE=1])
AC_ARG_ENABLE(igate, [ --disable-igate Disable all IGate codes],
[if test "${enable_igate}" = no ; then
AC_DEFINE(DISABLE_IGATE,1,[Define to 1 if you want to disable all IGATE codes.])
fi])
AC_ARG_ENABLE(agwpe, [ --enable-agwpe Enable AGWPE socket interface code.],
[if test "${enable_agwpe}" != no ; then
AC_DEFINE(ENABLE_AGWPE,1,[Define to 1 if you want to enable AGWPE socket interface.])
fi])
AC_ARG_WITH(pthread, [ --without-pthread When desiring not to use pthread subsystem],
[AC_DEFINE(DISABLE_PTHREAD,1,[Define for pthread(3p) disabling]) DISABLE_PTHREAD=1],
[AC_DEFINE(ENABLE_PTHREAD,1,[Define for pthread(3p) enabling]) ENABLE_PTHREAD=1])
AC_ARG_WITH(pthreads, [ --with-pthreads (mistyped pthread) When desiring use pthread subsystem],
[AC_DEFINE(ENABLE_PTHREAD,1,[Define for pthread(3p) enabling]) ENABLE_PTHREAD=1])
dnl search for pthread libs and compilation option
AC_SUBST(LIBPTHREAD)
AC_SUBST(CCPTHREAD)
if test "${ENABLE_PTHREAD}" = "1" ; then
AC_MSG_RESULT([The --without-pthread option is not set, looking for pthread_create() function.])
have_pthread=no
if test $have_pthread = no; then
t_oldLibs="$LIBS"
LIBS="$LIBS -pthread"
t_oldCflags="$CFLAGS"
CFLAGS="$CFLAGS -pthread"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],[[pthread_t pt;
pthread_attr_t pat;
int rc = pthread_create(&pt, &pat, NULL, NULL)]])],
[have_pthread=yes;AC_MSG_RESULT([Have pthread_create()])],
[AC_MSG_RESULT([Not have pthread_create()])])
if test $have_pthread = no ; then
AC_MSG_RESULT([Failure at HAVE_PTHREAD_CREATE])
else
AC_DEFINE(HAVE_PTHREAD_CREATE,1,[Have pthread_create() function])
AC_MSG_RESULT([Success at HAVE_PTHREAD_CREATE])
LIBPTHREAD="-pthread"
CCPTHREAD="-pthread"
fi
LIBS="$t_oldLibs"
CFLAGS="$t_oldCflags"
fi
if test $have_pthread = no; then
AC_MSG_RESULT([Failure at HAVE_PTHREAD_CREATE, trying second way.])
t_oldLibs="$LIBS"
LIBS="$LIBS -lpthread"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],[[pthread_t pt;
pthread_attr_t pat;
int rc = pthread_create(&pt, &pat, NULL, NULL)]])],
[have_pthread=yes;AC_MSG_RESULT([Have pthread_create()])],
[AC_MSG_RESULT([Not have pthread_create()])])
if test $have_pthread = no ; then
AC_MSG_RESULT([Failure at HAVE_PTHREAD_CREATE])
else
AC_DEFINE(HAVE_PTHREAD_CREATE,1,[Have pthread_create() function])
AC_MSG_RESULT([Success at HAVE_PTHREAD_CREATE])
LIBPTHREAD="-lpthread"
CCPTHREAD=""
fi
LIBS="$t_oldLibs"
CFLAGS="$t_oldCflags"
fi
if test $have_pthread = no; then
AC_MSG_RESULT([Still failure at HAVE_PTHREAD_CREATE, Run out of ways to set it up.])
fi
fi
dnl Check for clock_gettime, and a library to have it
AC_SUBST(LIBRT)
AC_SEARCH_LIBS([clock_gettime], [rt], [
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,[Have clock_gettime])
])
if test "$ac_cv_search_clock_gettime" = "-lrt"; then
LIBRT="-lrt"
fi
dnl Solaris resolver solution:
AC_SUBST(LIBGETADDRINFO)
AC_CHECK_FUNCS(getaddrinfo,,
AC_CHECK_LIB(nsl, getaddrinfo,
[LIBGETADDRINFO="-lnsl"]))
AC_SUBST(LIBSOCKET)dnl
AC_SUBST(LIBRESOLV)dnl
#
# We check for various libraries
# - SysVr4 style of "-lsocket" at first (unless in libc)
# The hallmark is connect() routine (we presume)
#
ac_cv_libsocket_both=1
AC_CHECK_FUNC(connect, ac_cv_libsocket_both=0)
AC_CHECK_FUNC(gethostbyname, ac_cv_libsocket_both=0)
if test "$ac_cv_libsocket_both" = 1 ; then
# Check cache
if test "$ac_cv_func_socket_lxnet" = yes ; then
AC_MSG_RESULT([need -lxnet library (cached)])
LIBSOCKET="-lnsl -lsocket -lxnet"
else
if test "$ac_cv_func_socket_lsocket" = yes ; then
AC_MSG_RESULT([need -lsocket library (cached)])
LIBSOCKET="-lsocket"
if test "$ac_cv_func_gethostbyname_lnsl" = yes ; then
LIBSOCKET="-lnsl -lsocket"
fi
else
# Well, will this work ? SysVR4, but not Sun Solaris ?
AC_CHECK_LIB(xnet, connect, [LIBSOCKET="-lnsl -lsocket -lxnet"
ac_cv_func_socket_lsocket=no
ac_cv_func_socket_lxnet=yes],[
AC_CHECK_LIB(socket, connect, [LIBSOCKET="-lsocket"
ac_cv_func_socket_lsocket=yes],
ac_cv_func_socket_lsocket=no)
if test "$ac_cv_func_socket_lsocket" = yes ; then
t_oldLibs="$LIBS"
LIBS="$LIBS -lsocket $LIBRESOLV"
AC_TRY_LINK([],[gethostbyname();], ,[
LIBS="$LIBS -lnsl" # Add this Solaris library..
AC_TRY_LINK([],[gethostbyname();],[
LIBSOCKET="-lsocket -lnsl"
ac_cv_func_gethostbyname_lnsl=yes
], [
AC_MSG_ERROR([Weird, '$LIBS' not enough to find gethostnyname() ?!])
])
])
LIBS="$t_oldLibs"
fi
])
fi
fi
fi
if test "x$LIBRESOLV" = "x"; then
# Ok, No -lresolv, is this enough for the _res to appear ?
t_oldLibs="$LIBS"
LIBS="$LIBS $LIBSOCKET"
ac_cv_var__res_options=no
# This following is for IRIX6.4, and I sincerely hope it
# will not fail on other systems... It did! It did!
# Many systems don't have idemponent headers, they need specific
# includes before latter ones, or the latter ones won't be successful...
AC_TRY_LINK([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>],
[_res.options = RES_INIT;],
ac_cv_var__res_options=yes);
if test "$ac_cv_var__res_options" != "yes"; then
AC_MSG_RESULT([Can't do without -lresolv to link resolver's _res.options])
LIBS="$LIBS -lresolv"
fi
LIBS="$t_oldLibs"
fi
# See about the routines that possibly exist at the libraries..
LIBS="$t_oldLibs $LIBSOCKET"
AC_CHECK_FUNCS(socket socketpair)
LIBS="$t_oldLibs"
if test "$ac_cv_func_socket" = no -a "$LIBSOCKET" != ""; then
LIBS="$LIBS $LIBSOCKET"
AC_TRY_LINK([],[socket();], ac_cv_func_socket=yes)
if test $ac_cv_func_socket = yes; then
AC_DEFINE(HAVE_SOCKET)
AC_MSG_RESULT([Has socket() when using $LIBSOCKET])
fi
LIBS="$t_oldLibs"
fi
if test "$ac_cv_func_socketpair" = no -a "$LIBSOCKET" != ""; then
LIBS="$LIBS $LIBSOCKET"
AC_TRY_LINK([],[socketpair();], ac_cv_func_socketpair=yes)
if test $ac_cv_func_socketpair = yes; then
AC_DEFINE(HAVE_SOCKETPAIR)
AC_MSG_RESULT([Has socketpair() when using $LIBSOCKET])
fi
LIBS="$t_oldLibs"
fi
dnl Check for openssl
AC_ARG_WITH(openssl, [ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.7)], [with_openssl=$withval], [with_openssl=no])
AC_SUBST(LIBSSL)
AC_SUBST(LIBCRYPTO)
if test "$with_openssl" != "no" ; then
AC_CHECK_HEADERS([openssl/ssl.h])
AC_SEARCH_LIBS(TLSv1_server_method, ssl, AC_DEFINE(HAVE_TLSV1_SERVER_METHOD, 1, [OpenSSL 0.9.7 or later]))
AC_SEARCH_LIBS(X509_free, crypto, AC_DEFINE(HAVE_X509_FREE, 1, [OpenSSL 0.9.7 or later]))
if test "$ac_cv_search_TLSv1_server_method" = "-lssl"; then
LIBSSL="-lssl"
fi
if test "$ac_cv_search_X509_free" = "-lcrypto"; then
LIBCRYPTO="-lcrypto"
fi
fi
dnl Define compilation variables supplying version information
t_vers="`cat VERSION`"
AC_SUBST(VERSION_STRING, "`cat VERSION`")
dnl Output files
AC_CONFIG_FILES([Makefile])
AC_OUTPUT