forked from mongodb/libbson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
370 lines (306 loc) · 11.7 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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
dnl **************************************************************************
dnl Versioning Macros
dnl **************************************************************************
m4_define([bson_major_version], [0])
m4_define([bson_minor_version], [4])
m4_define([bson_micro_version], [1])
m4_define([bson_version], [bson_major_version.bson_minor_version.bson_micro_version])
# bump up by 1 for every micro release with no API changes, otherwise
# set to 0. after release, bump up by 1
m4_define([bson_interface_age], [1])
m4_define([bson_binary_age], [m4_eval(100 * bson_minor_version + bson_micro_version)])
m4_define([lt_current], [m4_eval(100 * bson_minor_version + bson_micro_version - bson_interface_age)])
m4_define([lt_revision], [bson_interface_age])
m4_define([lt_age], [m4_eval(bson_binary_age - bson_interface_age)])
dnl **************************************************************************
dnl Initialize Automake
dnl **************************************************************************
AC_PREREQ([2.61])
AC_INIT([libbson],[bson_version],[https://github.com/mongodb/libbson/issues])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES],
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
AS_AM_REALLY_SILENT
# Initialize libtool
LT_PREREQ([2.2])
LT_INIT
AM_INIT_AUTOMAKE([1.10])
AM_PROG_CC_C_O
dnl **************************************************************************
dnl Versioning Definitions
dnl **************************************************************************
BSON_MAJOR_VERSION=bson_major_version
BSON_MINOR_VERSION=bson_minor_version
BSON_MICRO_VERSION=bson_micro_version
BSON_API_VERSION=1.0
BSON_VERSION=bson_version
AC_SUBST(BSON_MAJOR_VERSION)
AC_SUBST(BSON_MINOR_VERSION)
AC_SUBST(BSON_MICRO_VERSION)
AC_SUBST(BSON_API_VERSION)
AC_SUBST(BSON_VERSION)
BSON_LT_CURRENT=lt_current
BSON_LT_REVISION=lt_revision
BSON_LT_AGE=lt_age
BSON_LT_VERSION="$BSON_LT_CURRENT:$BSON_LT_REVISION:$BSON_LT_AGE"
BSON_LT_LDFLAGS="-version-info $BSON_LT_VERSION"
dnl **************************************************************************
dnl Platform Checks
dnl **************************************************************************
platform_linux=no
platform_solaris=no
platform_win32=no
BSON_OS=1
AC_CANONICAL_HOST
AC_MSG_CHECKING([if building for some Win32 platform])
AS_CASE([$host],
[*-*-mingw*|*-*-cygwin*],
[
BSON_LT_LDFLAGS="$BSON_LT_LDFLAGS -no-undefined"
platform_win32=yes
BSON_OS=2
],
[*-*-linux*],
[
platform_linux=yes
],
[*-*-solaris*],
[
platform_solaris=yes
],
[]
)
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL(OS_LINUX, [test "$platform_linux" = "yes"])
AM_CONDITIONAL(OS_SOLARIS, [test "$platform_solaris" = "yes"])
AM_CONDITIONAL(OS_WIN32, [test "$platform_win32" = "yes"])
AC_SUBST([BSON_OS])
dnl **************************************************************************
dnl Symbolic Linking options
dnl **************************************************************************
# Check for -Bsymbolic-functions to avoid intra-library PLT jumps
AC_ARG_ENABLE([Bsymbolic],
[AS_HELP_STRING([--disable-Bsymbolic],
[Avoid linking with -Bsymbolic])],
[],
[
saved_LDFLAGS="${LDFLAGS}"
AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
LDFLAGS=-Wl,-Bsymbolic-functions
AC_TRY_LINK([], [int main (void) { return 0; }],
[
AC_MSG_RESULT([yes])
enable_Bsymbolic=yes
],
[
AC_MSG_RESULT([no])
enable_Bsymbolic=no
])
LDFLAGS="${saved_LDFLAGS}"
])
AS_IF([test "x$enable_Bsymbolic" = "xyes"], [BSON_LINK_FLAGS=-Wl[,]-Bsymbolic-functions])
BSON_LT_LDFLAGS="$BSON_LT_LDFLAGS $BSON_LINK_FLAGS"
AC_SUBST(BSON_LT_LDFLAGS)
dnl **************************************************************************
dnl Check for Required Headers
dnl **************************************************************************
AC_CREATE_STDINT_H([bson/bson-stdint.h])
dnl **************************************************************************
dnl Check for Python Support
dnl **************************************************************************
AC_ARG_ENABLE(
[python],
[AC_HELP_STRING([--enable-python=@<:no/yes@:>@],
[Enable support for experimental python bindings. @<:@default=no@:>@])],
[], [
enable_python=no
ax_python_header=no
]
)
AS_IF([test "x$enable_python" = "xyes"], [
AX_PYTHON
])
AM_CONDITIONAL([HAVE_PYTHON], [test "x$ax_python_header" != "xno"])
dnl **************************************************************************
dnl Check for necessary libraries.
dnl **************************************************************************
AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
[AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
[CLOCK_LIB=])])
AC_SUBST([CLOCK_LIB])
AC_CHECK_FUNCS(posix_memalign memalign)
dnl **************************************************************************
dnl Check if pthread_mutex synchronisation needed
dnl **************************************************************************
if test "$platform_solaris" = "yes"; then
pthread_flag="-pthreads"
else
pthread_flag="-pthread"
fi
AX_PTHREAD([
PTHREAD_LIB="-lpthread"
AC_TRY_LINK([#include <stdint.h>],
[uint32_t seq = __sync_fetch_and_add_4(&seq, 1);],
,
AC_DEFINE([WITH_OID32_PT], [],
[pthread locking for bson_context_get_oid_seq32_threadsafe()])
PTHREAD_CFLAGS="$pthread_flag"
PTHREAD_LDFLAGS="$pthread_flag"
)
AC_TRY_LINK([#include <stdint.h>],
[uint64_t seq = __sync_fetch_and_add_8(&seq, 1);],
,
AC_DEFINE([WITH_OID64_PT], [],
[pthread locking for bson_context_get_oid_seq64_threadsafe()])
PTHREAD_CFLAGS="$pthread_flag"
PTHREAD_LDFLAGS="$pthread_flag"
)
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
AC_SUBST(PTHREAD_LIB)
enable_pthreads=yes
],[
enable_pthreads=no
])
AM_CONDITIONAL(HAVE_PTHREADS, test "x$enable_pthreads" = "xyes")
dnl **************************************************************************
dnl Check Host Endianness
dnl **************************************************************************
AC_C_BIGENDIAN
if test "x$ac_cv_c_bigendian" = "xyes"; then
BSON_BYTE_ORDER=4321
host_endianness="Big Endian"
else
BSON_BYTE_ORDER=1234
host_endianness="Little Endian"
fi
CPPFLAGS="$CPPFLAGS -DBSON_BYTE_ORDER=$BSON_BYTE_ORDER"
AC_SUBST([BSON_BYTE_ORDER])
dnl **************************************************************************
dnl Optionally check for Asciidoc and xmlto for documentation
dnl **************************************************************************
AC_ARG_VAR([XMLTO], [Path to xmlto command])
AC_PATH_PROG([XMLTO], [xmlto])
AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
AC_PATH_PROG([ASCIIDOC], [asciidoc])
BSON_CHECK_DOC_BUILD
dnl **************************************************************************
dnl Enable extra debugging options
dnl **************************************************************************
m4_define([debug_default], [m4_if(m4_eval(bson_minor_version % 2), [1], [yes], [minimum])])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@],
[turn on debugging @<:@default=debug_default@:>@])],
[],
[enable_debug=debug_default])
AS_CASE([$enable_debug],
[yes], [
BSON_DEBUG_CFLAGS="-DBSON_ENABLE_DEBUG"
],
[minimum], [
BSON_DEBUG_CFLAGS="-DBSON_ENABLE_DEBUG -DBSON_DISABLE_ASSERT"
],
[no], [
BSON_DEBUG_CFLAGS="-DBSON_DISABLE_ASSERT -DBSON_DISABLE_CHECKS"
],
[AC_MSG_ERROR([Unknown argument to --enable-debug])])
AC_SUBST([BSON_DEBUG_CFLAGS])
dnl **************************************************************************
dnl Enable strict compiler flags
dnl **************************************************************************
# use strict compiler flags only on development releases
m4_define([maintainer_flags_default], [m4_if(m4_eval(bson_minor_version % 2), [1], [yes], [no])])
AC_ARG_ENABLE([maintainer-flags],
[AS_HELP_STRING([--enable-maintainer-flags=@<:@no/yes@:>@],
[Use strict compiler flags @<:@default=]maintainer_flags_default[@:>@])],
[],
[enable_maintainer_flags=maintainer_flags_default])
AS_IF([test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"],
[AS_COMPILER_FLAGS([MAINTAINER_CFLAGS],
["-Wall
-Waggregate-return
-Wcast-align
-Wdeclaration-after-statement
-Wempty-body
-Wformat
-Wformat-nonliteral
-Wformat-security
-Winit-self
-Winline
-Wmissing-include-dirs
-Wno-strict-aliasing
-Wno-uninitialized
-Wredundant-decls
-Wreturn-type
-Wshadow
-Wswitch-default
-Wswitch-enum
-Wundef
-Wunused-but-set-parameter
-Wuninitialized
"])]
)
MAINTAINER_CFLAGS="${MAINTAINER_CFLAGS#* }"
AC_SUBST([MAINTAINER_CFLAGS])
dnl **************************************************************************
dnl Pthread workarounds
dnl **************************************************************************
# The following is borrowed from the guile configure script.
#
# On past versions of Solaris, believe 8 through 10 at least, you
# had to write "pthread_once_t foo = { PTHREAD_ONCE_INIT };".
# This is contrary to POSIX:
# http://www.opengroup.org/onlinepubs/000095399/functions/pthread_once.html
# Check here if this style is required.
#
# glibc (2.3.6 at least) works both with or without braces, so the
# test checks whether it works without.
#
AC_SUBST(NEED_BRACES_ON_PTHREAD_ONCE_INIT, 0)
AC_CACHE_CHECK([whether PTHREAD_ONCE_INIT needs braces],
bson_cv_need_braces_on_pthread_once_init,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
pthread_once_t foo = PTHREAD_ONCE_INIT;]])],
[bson_cv_need_braces_on_pthread_once_init=no],
[bson_cv_need_braces_on_pthread_once_init=yes])])
if test "$bson_cv_need_braces_on_pthread_once_init" = yes; then
CFLAGS="$CFLAGS -D_PTHREAD_ONCE_INIT_NEEDS_BRACES"
fi
dnl **************************************************************************
dnl Output
dnl **************************************************************************
AC_CONFIG_FILES([
Makefile
bson/bson-version.h
bson/bson-config.h
bson/libbson-1.0.pc
])
AC_OUTPUT
if test $(( ${BSON_MINOR_VERSION} % 2 )) -eq 1; then
cat << EOF
*** IMPORTANT ***
This is an unstable version of libbson.
It is for test purposes only.
Please, DO NOT use it in a production environment.
It will probably crash and you will lose your data.
Additionally, the API/ABI may change during the course
of development.
Thanks,
The libbson team.
*** END OF WARNING ***
EOF
fi
echo ""
echo "libbson-$VERSION"
echo ""
echo " Prefix ....................: ${prefix}"
echo " Endianness ................: ${host_endianness}"
echo " Debug Level ...............: ${enable_debug}"
echo " CFLAGS ....................: ${CFLAGS}"
echo " Maintainer ................: ${enable_maintainer_flags}"
echo ""
echo "Experimental Bindings"
echo ""
echo " Python ....................: ${ax_python_header}"
echo ""