forked from nanomsg/nanomsg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
353 lines (307 loc) · 11.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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# Copyright (c) 2013 Luca Barbato
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
################################################################################
# Start the configuration phase. #
################################################################################
AC_PREREQ([2.53])
AC_INIT([nanomsg], [m4_esyscmd([./package_version.sh])],
[[email protected]], [nanomsg], [http://nanomsg.org/])
AC_CONFIG_SRCDIR([src/nn.h])
AM_INIT_AUTOMAKE([1.6 foreign subdir-objects tar-ustar dist-zip])
m4_ifdef([AM_SILENT_RULES], [
AM_SILENT_RULES([yes])
])
AC_CANONICAL_HOST
################################################################################
# Retrieve the versions. #
################################################################################
AC_PROG_SED
AC_PROG_AWK
NN_ABI_VERSION=m4_esyscmd([./abi_version.sh])
NN_PACKAGE_VERSION=m4_esyscmd([./package_version.sh])
NN_LIBTOOL_VERSION=m4_esyscmd([./abi_version.sh -libtool])
AC_SUBST(NN_ABI_VERSION)
AC_SUBST(NN_PACKAGE_VERSION)
AC_SUBST(NN_LIBTOOL_VERSION)
AC_MSG_NOTICE([nanomsg package version: $NN_PACKAGE_VERSION])
AC_MSG_NOTICE([nanomsg ABI version: $NN_ABI_VERSION])
################################################################################
# Check the compilers. #
################################################################################
AC_PROG_CC_C99
AM_PROG_CC_C_O
################################################################################
# Check whether GCC compiler is used. #
################################################################################
AS_IF([test x"$GCC" = xyes],
[AC_DEFINE([NN_HAVE_GCC])]
)
################################################################################
# Check whether ICC compiler is used. #
################################################################################
AC_CACHE_CHECK([whether we are using ICC compiler],
[ac_cv_icc_compiler],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __INTEL_COMPILER
#error
#endif
]])],
[ac_icc_compiler=yes],
[ac_icc_compiler=no])
ac_cv_icc_compiler=$ac_icc_compiler])
AS_IF([test x"$ac_cv_icc_compiler" = xyes],
[AC_DEFINE([NN_HAVE_ICC])]
)
################################################################################
# Check whether Sun Studio compiler is used. #
################################################################################
AC_CACHE_CHECK([whether we are using Sun Studio compiler],
[ac_cv_sun_studio_compiler],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __SUNPRO_C
#error
#endif
]])],
[ac_sun_studio_compiler=yes],
[ac_sun_studio_compiler=no])
ac_cv_sun_studio_compiler=$ac_sun_studio_compiler])
AS_IF([test x"$ac_cv_sun_studio_compiler" = xyes],
[AC_DEFINE([NN_HAVE_SUN_STUDIO])]
)
################################################################################
# Check whether clang compiler is used. #
################################################################################
AC_CACHE_CHECK([whether we are using clang compiler],
[ac_cv_clang_compiler],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
#error
#endif
]])],
[ac_clang_compiler=yes],
[ac_clang_compiler=no])
ac_cv_clang_compiler=$ac_clang_compiler])
AS_IF([test x"$ac_cv_clang_compiler" = xyes],
[AC_DEFINE([NN_HAVE_CLANG])]
)
################################################################################
# Check whether HP aCC compiler is used. #
################################################################################
AC_CACHE_CHECK([whether we are using HP aCC compiler],
[ac_cv_hpacc_compiler],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __HP_cc
#error
#endif
]])],
[ac_hpacc_compiler=yes],
[ac_hpacc_compiler=no])
ac_cv_hpacc_compiler=$ac_hpacc_compiler])
AS_IF([test x"$ac_cv_hpacc_compiler" = xyes],
[AC_DEFINE([NN_HAVE_HPACC])]
)
################################################################################
# If --enable-debug is specified set appropriate compiler options. #
################################################################################
AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],
[Enable debugging information [default=no]])])
if test "x$enable_debug" = "xyes"; then
if test "x$GCC" = "xyes" -o \
"x$ac_cv_icc_compiler" = "xyes" -o \
"x$ac_cv_clang_compiler" = "xyes"; then
CFLAGS="-g -O0 "
elif test "x$ac_cv_sun_studio_compiler" = "xyes"; then
CFLAGS="-g0 "
elif test "x$ac_cv_hpacc_compiler" = "xyes"; then
CFLAGS="-g +O0 "
fi
ORIG_CFLAGS="${CFLAGS:-none}"
if test "x$ORIG_CFLAGS" != "xnone"; then
CFLAGS="${CFLAGS} ${ORIG_CFLAGS}"
fi
AC_DEFINE([NN_DEBUG])
fi
################################################################################
# Build the documentation. #
################################################################################
AC_ARG_ENABLE([doc],
AS_HELP_STRING([--enable-doc], [Build documentation [default=no]])
)
AS_IF([test x"$enable_doc" = "xyes"], [
AC_CHECK_PROGS([ASCIIDOC], [asciidoc])
AS_IF([test x"$ASCIIDOC" = "x"],[
AC_MSG_ERROR([Please install asciidoc to build the documentation])
])
AC_CHECK_PROGS([XMLTO], [xmlto])
AS_IF([test x"$XMLTO" = "x"], [
AC_MSG_ERROR([Please install xmlto to build the documentation])
])
AS_IF([test ! -d "doc"], [
AC_PROG_MKDIR_P
AS_MKDIR_P("doc")
])
])
AM_CONDITIONAL([DOC], [test x"$ASCIIDOC" != "x" -a x"$XMLTO" != "x" ])
################################################################################
# Build the nanocat
################################################################################
AC_ARG_ENABLE([nanocat],
AS_HELP_STRING([--enable-nanocat], [Build nanocat executable [default=yes]])
)
AC_ARG_ENABLE([symlinks],
AS_HELP_STRING([--enable-symlinks],
[Make nn_xxx symlinks for nanocat [default=yes]])
)
AS_IF([test x"$enable_nanocat" != "xno" -a x"$enable_symlinks" != x"no"], [
AC_PROG_LN_S
])
AM_CONDITIONAL([NANOCAT], [test x"$enable_nanocat" != "xno" ])
AM_CONDITIONAL([SYMLINKS], [test x"$enable_symlinks" != "xno" ])
################################################################################
# Check which OS we are building for. #
################################################################################
AS_CASE([${host_os}],
[*linux*], [AC_DEFINE([NN_HAVE_LINUX])],
[*mingw32*], [
AC_DEFINE([NN_HAVE_WINDOWS])
AC_DEFINE([NN_HAVE_MINGW])
AC_DEFINE([_WIN32_WINNT],0x0600)
LIBS="$LIBS -lws2_32 -lMswsock"
],
[*darwin*], [AC_DEFINE([NN_HAVE_OSX])],
[*freebsd*], [AC_DEFINE([NN_HAVE_FREEBSD])],
[*netbsd*], [AC_DEFINE([NN_HAVE_NETBSD])],
[*openbsd*], [AC_DEFINE([NN_HAVE_OPENBSD])],
[*hpux*], [AC_DEFINE([NN_HAVE_HPUX])],
[*solaris*], [
AC_DEFINE([NN_HAVE_SOLARIS])
AC_CHECK_LIB([socket], [socket])
AC_CHECK_LIB([nsl], [gethostbyname])
],
[*nto-qnx*], [
AC_DEFINE([NN_HAVE_QNX])
AC_CHECK_LIB([socket], [socket])
]
)
################################################################################
# Feature checks. #
################################################################################
AX_PTHREAD([
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
])
AC_CHECK_HEADERS([netinet/in.h])
AC_CHECK_HEADERS([netdb.h])
AC_CHECK_HEADERS([arpa/inet.h])
AC_CHECK_HEADERS([unistd.h])
AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([stdint.h], [AC_DEFINE([NN_HAVE_STDINT])])
AC_CHECK_FUNCS([eventfd], [AC_DEFINE([NN_HAVE_EVENTFD])])
AC_CHECK_FUNCS([pipe], [AC_DEFINE([NN_HAVE_PIPE])])
AC_CHECK_FUNCS([pipe2], [
AC_DEFINE([NN_HAVE_PIPE2])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])
AC_CHECK_FUNCS([gethrtime], [AC_DEFINE([NN_HAVE_GETHRTIME])])
AC_MSG_CHECKING([for CLOCK_MONOTONIC])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <time.h>
]], [[
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return 0;
]])], [
AC_MSG_RESULT([yes])
AC_DEFINE([NN_HAVE_CLOCK_MONOTONIC])
], [
AC_MSG_RESULT([no])
])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_FUNCS([poll], [AC_DEFINE([NN_HAVE_POLL])])
AC_CHECK_FUNCS([epoll_create], [AC_DEFINE([NN_USE_EPOLL])], [
AC_CHECK_FUNCS([kqueue], [AC_DEFINE([NN_USE_KQUEUE])], [
AC_DEFINE([NN_USE_POLL])
])
])
AC_CHECK_FUNCS([getifaddrs], [AC_DEFINE([NN_USE_IFADDRS])], [
AC_EGREP_HEADER([SIOCGIFADDR], [sys/ioctl.h], [
AC_DEFINE([NN_USE_SIOCGIFADDR])
], [
AC_DEFINE([NN_USE_LITERAL_IFADDR])
])
])
AC_CHECK_FUNCS([accept4], [
AC_DEFINE([NN_HAVE_ACCEPT4])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])
AC_SEARCH_LIBS([getaddrinfo_a], [anl], [
AC_DEFINE([NN_HAVE_GETADDRINFO_A])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])
AC_SEARCH_LIBS([socketpair], [], [
AC_DEFINE([NN_HAVE_SOCKETPAIR])
])
AC_SEARCH_LIBS([sem_wait], [rt pthread], [
AC_DEFINE([NN_HAVE_SEMAPHORE])
])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
#include <stdint.h>
int main()
{
volatile uint32_t n = 0;
__sync_fetch_and_add (&n, 1);
__sync_fetch_and_sub (&n, 1);
return 0;
}
]])], [
AC_DEFINE([NN_HAVE_GCC_ATOMIC_BUILTINS])
])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <atomic.h>]],
[[uint32_t value; atomic_cas_32 (&value, 0, 0); return 0;]])],[
AC_DEFINE([NN_HAVE_ATOMIC_SOLARIS])],[])
AS_IF([test x"$ac_cv_func_eventfd" = xyes], [
AC_DEFINE([NN_USE_EVENTFD])], [
AS_IF([test x"$ac_cv_func_pipe" = xyes], [
AC_DEFINE([NN_USE_PIPE])], [
AS_IF([test x"$ac_cv_func_socketpair" = xyes], [
AC_DEFINE([NN_USE_SOCKETPAIR])]
)
])
])
LT_INIT
DOLT
################################################################################
# Finish the configuration phase. #
################################################################################
AC_CONFIG_MACRO_DIR([m4])
AC_OUTPUT([
Makefile
libnanomsg.pc
])
cp confdefs.h config.h