forked from mongodb/libbson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.ac
More file actions
288 lines (242 loc) · 8.59 KB
/
configure.ac
File metadata and controls
288 lines (242 loc) · 8.59 KB
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
dnl **************************************************************************
dnl Versioning Macros
dnl **************************************************************************
m4_define([bson_major_version], [0])
m4_define([bson_minor_version], [2])
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], [0])
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_win32=no
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
],
[*-*-linux*],
[
platform_linux=yes
],
[]
)
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL(OS_LINUX, [test "$platform_linux" = "yes"])
AM_CONDITIONAL(OS_WIN32, [test "$platform_win32" = "yes"])
# 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_NEED_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])
dnl **************************************************************************
dnl Check if pthread_mutex synchronisation needed
dnl **************************************************************************
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"
PTHREAD_LDFLAGS="-pthread"
)
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"
PTHREAD_LDFLAGS="-pthread"
)
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 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], [
CFLAGS="$CFLAGS -Wall"
CFLAGS="$CFLAGS -Werror"
],
[minimum], [
CFLAGS="$CFLAGS -Wold-style-definition"
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
CFLAGS="$CFLAGS -Wredundant-decls"
CFLAGS="$CFLAGS -Wmissing-noreturn"
CFLAGS="$CFLAGS -Wcast-align"
CFLAGS="$CFLAGS -Wwrite-strings"
CFLAGS="$CFLAGS -Winline"
CFLAGS="$CFLAGS -Wformat"
CFLAGS="$CFLAGS -Wformat-nonliteral"
CFLAGS="$CFLAGS -Wformat-security"
CFLAGS="$CFLAGS -Wswitch-enum"
CFLAGS="$CFLAGS -Wswitch-default"
CFLAGS="$CFLAGS -Winit-self"
CFLAGS="$CFLAGS -Wmissing-include-dirs"
CFLAGS="$CFLAGS -Wundef"
CFLAGS="$CFLAGS -Waggregate-return"
CFLAGS="$CFLAGS -Wmissing-format-attribute"
CFLAGS="$CFLAGS -Wnested-externs"
CFLAGS="$CFLAGS -Wshadow"
CFLAGS="$CFLAGS -Wreturn-type"
CFLAGS="$CFLAGS -Wunused-but-set-parameter"
CFLAGS="$CFLAGS -Wuninitialized"
],
[no], [
CFLAGS="$CFLAGS -DBSON_DISABLE_ASSERT"
CFLAGS="$CFLAGS -DBSON_DISABLE_CHECKS"
],
[AC_MSG_ERROR([Unknown argument to --enable-debug])]
)
dnl **************************************************************************
dnl Output
dnl **************************************************************************
AC_CONFIG_FILES([
Makefile
libbson-1.0.pc
bson/bson-version.h
])
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 ""
echo "Experimental Bindings"
echo ""
echo " Python ....................: ${ax_python_header}"
echo ""