forked from etotheipi/BitcoinArmory
-
Notifications
You must be signed in to change notification settings - Fork 174
/
configure.ac
executable file
·406 lines (354 loc) · 14 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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
AC_PREREQ([2.69])
AC_INIT([BitcoinArmory],[0.96.99],[moothecowlord@gmail.com])
AM_INIT_AUTOMAKE([1.11 subdir-objects foreign -Wall -Werror])
AM_PROG_AR
LT_INIT()
AC_CANONICAL_HOST
# Reset these flags if they are the system default "-g -02".
AS_IF([test "$CFLAGS" = "-g -O2"] ,[AC_SUBST(CFLAGS, [ ])])
AS_IF([test "$CXXFLAGS" = "-g -O2"] ,[AC_SUBST(CXXFLAGS, [ ])])
#build tests arg
AC_ARG_ENABLE([tests],
AS_HELP_STRING([--enable-tests],
[build with test suites @<:@default=no@:>@]),
[want_tests="$enableval"], [want_tests=no])
#build benchmarks
AC_ARG_ENABLE([benchmark],
AS_HELP_STRING([--enable-benchmark],
[build with benchmark suites @<:@default=no@:>@]),
[want_benchmark=$enableval], [want_benchmark=no])
#build debug arg
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug],
[compile with debug symbols @<:@default=no@:>@]),
[want_debug="$enableval"], [want_debug=no])
#build client arg
AC_ARG_WITH([client],
AS_HELP_STRING([--without-client],
[do not build client @<:@default=no@:>@]),
[with_client="$withval"], [with_client=yes])
# Custom libwebsockets path. This will be a mandatory flag, even if the user
# uses /usr/local. The problem is that Ubuntu has a pretty old version of LWS.
# We should just use a newer version and link it in.
AC_ARG_WITH([own-lws],
AS_HELP_STRING([--with-own-lws],
[pass path of your own lws binary and headers @<:@default=no@:>@]),
[with_own_lws="$withval"], [with_own_lws=no])
# Custom libbtc path
AC_ARG_WITH([own-libbtc],
AS_HELP_STRING([--with-own-libbtc],
[pass path of your own libbtc binary and headers @<:@default=no@:>@]),
[with_own_libbtc="$withval"], [with_own_libbtc=no])
if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
CFLAGS="$CFLAGS -O0 -g3"
CXXFLAGS="$CXXFLAGS -O0 -g3"
AC_DEFINE([DEBUG], 1, [Define for debugging])
else
CFLAGS="$CFLAGS -O2"
CXXFLAGS="$CXXFLAGS -O2"
fi
AS_IF([test "x$with_client" = "xyes"], [build_client=yes],
[build_client=no])
AM_CONDITIONAL([BUILD_CLIENT], [test x$build_client = xyes])
# Building the GUI requires the client.
AS_IF([test "x$with_client$with_gui" = "xyesyes"], [build_gui=yes],
[build_gui=no])
AM_CONDITIONAL([BUILD_GUI], [test x$build_gui = xyes])
AC_PROG_CC
AC_PROG_CXX
AM_CONDITIONAL([HAVE_GCC], [test $CXX = g++])
AC_CHECK_SIZEOF([long unsigned int])
AM_CONDITIONAL([HAVE_64BIT], [test $ac_cv_sizeof_long_unsigned_int = 8])
AC_CONFIG_MACRO_DIR([build-aux/m4])
m4_include([build-aux/m4/ax_check_compile_flag.m4])
m4_include([build-aux/m4/ax_cxx_compile_stdcxx.m4])
#check for c++17
AX_CXX_COMPILE_STDCXX_17([noext], [mandatory])
# Make the compilation flags quiet unless V=1 is used.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_SUBST([CXX_STANDARD], $CXX_STANDARD)
# Tinkering with LDFLAGS hopefully won't be needed, but just in case....
#LDFLAGS="${LDFLAGS} -static"
dnl Determine build OS and do other OS-specific things.
case $host in
*darwin*)
BUILD_OS=darwin
# Handle Mac OS X SDK flags.
AC_ARG_WITH(macosx-sdk,
[AS_HELP_STRING([--with-macosx-sdk=DIR],
[compile using the SDK in DIR])])
if test "${with_macosx_sdk}" != "" ; then
test ! -d "${with_macosx_sdk}" && AC_MSG_ERROR([SDK "${with_macosx_sdk}" not found])
CFLAGS="${CFLAGS} -isysroot ${with_macosx_sdk}"
CXXFLAGS="${CXXFLAGS} -isysroot ${with_macosx_sdk}"
OBJC="${OBJC} -isysroot ${with_macosx_sdk}"
fi
AC_ARG_WITH(macosx-version-min,
[AS_HELP_STRING([--with-macosx-version-min=VERSION],
[compile for Mac OS X VERSION and above])])
if test "${with_macosx_version_min}" != "" ; then
CFLAGS="${CFLAGS} -mmacosx-version-min=${with_macosx_version_min}"
CXXFLAGS="${CXXFLAGS} -mmacosx-version-min=${with_macosx_version_min}"
OBJC="${OBJC} -mmacosx-version-min=${with_macosx_version_min}"
fi
AC_CHECK_PROG([BREW],brew, brew)
if test x$BREW = xbrew; then
if test x$with_own_lws = xno; then
use_pkgconfig=yes
libwebsockets_prefix=`$BREW --prefix libwebsockets 2>/dev/null`
if test x$libwebsockets_prefix != x; then
PKG_CONFIG_PATH="$libwebsockets_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
fi
fi
openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
if test x$openssl_prefix != x; then
PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
fi
libuv_prefix=`$BREW --prefix libuv 2>/dev/null`
if test x$openssl_prefix != x; then
PKG_CONFIG_PATH="$libuv_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
fi
libevent_prefix=`$BREW --prefix libevent 2>/dev/null`
if test x$libevent_prefix != x; then
PKG_CONFIG_PATH="$libevent_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
fi
protobuf_prefix=`$BREW --prefix protobuf 2>/dev/null`
if test x$protobuf_prefix != x; then
PKG_CONFIG_PATH="$protobuf_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH
fi
fi
# Just FYI, here are some linker flags, used and unused, that are noteworthy.
# In the future, making sure install_name_tool usage is minimized would be
# ideal. (Some usage may be necessary. See https://lists.gnu.org/archive/html/libtool-patches/2010-09/msg00308.html
# for an example.)
# -undefined dynamic_lookup: https://stackoverflow.com/a/30934307
# -rpath @executable_path/ (or other paths to search): https://wincent.com/wiki/@executable_path,_@load_path_and_@rpath
# -install_name @loader_path/libArmoryCommon.0.dylib: http://osiris.laya.com/coding/dylib_linking.html
CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -fPIC -pipe"
LDFLAGS="${LDFLAGS} -stdlib=libc++ -lc++"
# There really ought to be some sort of Qt check here. M4 files don't work
# well with Armory. Revisit this later. Not required, just nice to have.
;;
#*linux*)
# BUILD_OS=linux
# use_pkgconfig=yes
# if test "x$build_gui" = "xyes"; then
# # Check existence of Qt packages.
# if ! pkg-config --exists 'QtCore >= 4.8 QtCore <= 5 QtGui >= 4.8 QtGui <= 5'; then
# AC_MSG_ERROR([missing QtCore library, make sure libqtcore4 and libqt4-dev are installed])
# fi
# fi
# ;;
esac
#if test x$use_pkgconfig = xyes; then
# m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR(PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.)])
# m4_ifdef([PKG_PROG_PKG_CONFIG], [
# PKG_PROG_PKG_CONFIG
# if test x"$PKG_CONFIG" = "x"; then
# AC_MSG_ERROR(pkg-config not found.)
# fi
# ])
#fi
# Check for protobuf (protoc in particular is required)
PKG_CHECK_MODULES_STATIC(PROTOBUF, protobuf >= 2.0.0)
PKG_CHECK_VAR([PROTOBUF_LIBDIR], [protobuf], [libdir])
AC_MSG_CHECKING([protobuf lib path])
AS_IF([test "x$PROTOBUF_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify protobuf lib path.])
])
AC_MSG_RESULT($PROTOBUF_LIBDIR)
AC_SUBST([PROTOBUF_LIBDIR])
CXXFLAGS="${CXXFLAGS} ${PROTOBUF_CFLAGS}"
dnl Check for protoc (Google Protocol Buffers).
AC_PATH_PROG([PROTOC], [protoc], [])
AS_IF([test x"$PROTOC" = x],
[AC_MSG_ERROR([cannot find protoc (the Protocol Buffers compiler)])])
if test x$use_pkgconfig$with_own_lws = xyesno; then
PKG_CHECK_MODULES_STATIC([WEBSOCKETS], [libwebsockets_static >= 3.0.1],,[AC_MSG_ERROR(libwebsockets_static >= 3.0.1 not found.)])
AC_MSG_CHECKING([libwebsockets lib path])
PKG_CHECK_VAR([WEBSOCKETS_LIBDIR], [libwebsockets_static], [libdir])
AS_IF([test "x$WEBSOCKETS_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify libwebsockets_static lib path.])
])
AC_MSG_RESULT($WEBSOCKETS_LIBDIR)
AC_SUBST([WEBSOCKETS_LIBDIR])
CXXFLAGS="${CXXFLAGS} ${WEBSOCKETS_CFLAGS}"
else
# Even if libraries don't directly use LWS, they may rely on libraries that do
# rely on LWS. This causes the "child" libraries to rely on LWS too! Be sure to
# use the rpath equivalent in LDFLAGS for all affected libraries, "children" and
# "parent".
AC_SUBST([WEBSOCKETS_LIBDIR], ["$with_own_lws/lib"])
CXXFLAGS="${CXXFLAGS} -I$with_own_lws/include"
fi
if test x$with_own_libbtc = xno; then
AC_MSG_FAILURE([No path to libbtc, check README section on libbtc])
else
AC_SUBST([LIBBTC_LIBDIR], ["$with_own_libbtc"])
CXXFLAGS="${CXXFLAGS} -I$with_own_libbtc/include"
fi
AC_MSG_CHECKING(for LWS_WITH_TLS)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "lws_config.h"
#ifndef LWS_WITH_TLS
# error macro not defined
#endif
]])],
[ LWS_WITH_TLS_FOUND="yes" ],
[ LWS_WITH_TLS_FOUND="no" ]
)
AC_LANG_POP([C++])
AC_MSG_RESULT($LWS_WITH_TLS_FOUND)
if test x$LWS_WITH_TLS_FOUND = xyes; then
PKG_CHECK_MODULES_STATIC([SSL], [libssl],, [AC_MSG_ERROR(libssl not found.)])
AC_MSG_CHECKING([libssl lib path])
PKG_CHECK_VAR([SSL_LIBDIR], [libssl], [libdir])
AS_IF([test "x$SSL_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify libssl lib path.])
])
AC_MSG_RESULT($SSL_LIBDIR)
AC_SUBST([SSL_LIBDIR])
CXXFLAGS="${CXXFLAGS} ${SSL_CFLAGS}"
PKG_CHECK_MODULES_STATIC([CRYPTO], [libcrypto],, [AC_MSG_ERROR(libcrypto not found.)])
AC_MSG_CHECKING([libcrypto lib path])
PKG_CHECK_VAR([CRYPTO_LIBDIR], [libcrypto], [libdir])
AS_IF([test "x$CRYPTO_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify libcrypto lib path.])
])
AC_MSG_RESULT($CRYPTO_LIBDIR)
AC_SUBST([CRYPTO_LIBDIR])
AC_MSG_CHECKING([ldl required])
PKG_CHECK_VAR([SSL_LIBS], [libssl], [libs])
AS_IF(echo "$SSL_LIBS" | grep '\-ldl' >/dev/null 2>&1, SSL_LDL_REQUIRED="yes", SSL_LDL_REQUIRED="no")
PKG_CHECK_VAR([CRYPTO_LIBS], [libcrypto], [libs])
AS_IF(echo "$CRYPTO_LIBS" | grep '\-ldl' >/dev/null 2>&1, CRYPTO_LDL_REQUIRED="yes", CRYPTO_LDL_REQUIRED="no")
LDL_REQUIRED="no"
AS_IF([test "x$SSL_LDL_REQUIRED$CRYPTO_LDL_REQUIRED" != "xnono"], [
LDL_REQUIRED="yes"
])
AC_MSG_RESULT($LDL_REQUIRED)
fi
AC_MSG_CHECKING(for LWS_WITH_LIBUV)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "lws_config.h"
#ifndef LWS_WITH_LIBUV
# error macro not defined
#endif
]])],
[ LWS_WITH_LIBUV_FOUND="yes" ],
[ LWS_WITH_LIBUV_FOUND="no" ]
)
AC_LANG_POP([C++])
AC_MSG_RESULT($LWS_WITH_LIBUV_FOUND)
if test x$LWS_WITH_LIBUV_FOUND = xyes; then
PKG_CHECK_MODULES_STATIC([LIBUV], [libuv],, [AC_MSG_ERROR(libuv not found.)])
AC_MSG_CHECKING([libuv lib path])
PKG_CHECK_VAR([LIBUV_LIBDIR], [libuv], [libdir])
AS_IF([test "x$LIBUV_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify libuv lib path.])
])
AC_MSG_RESULT($LIBUV_LIBDIR)
AC_SUBST([LIBUV_LIBDIR])
CXXFLAGS="${CXXFLAGS} ${LIBUV_CFLAGS}"
fi
AC_MSG_CHECKING(for LWS_WITH_LIBEVENT)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "lws_config.h"
#ifndef LWS_WITH_LIBEVENT
# error macro not defined
#endif
]])],
[ LWS_WITH_LIBEVENT_FOUND="yes" ],
[ LWS_WITH_LIBEVENT_FOUND="no" ]
)
AC_LANG_POP([C++])
AC_MSG_RESULT($LWS_WITH_LIBEVENT_FOUND)
if test x$LWS_WITH_LIBEVENT_FOUND = xyes; then
PKG_CHECK_MODULES_STATIC([LIBEVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)])
AC_MSG_CHECKING([libevent lib path])
PKG_CHECK_VAR([LIBEVENT_LIBDIR], [libevent], [libdir])
AS_IF([test "x$LIBEVENT_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify libevent lib path.])
])
AC_MSG_RESULT($LIBEVENT_LIBDIR)
AC_SUBST([LIBEVENT_LIBDIR])
CXXFLAGS="${CXXFLAGS} ${LIBEVENT_CFLAGS}"
fi
AC_MSG_CHECKING(for LWS_HAVE_LIBCAP)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "lws_config.h"
#ifndef LWS_HAVE_LIBCAP
# error macro not defined
#endif
]])],
[ LWS_HAVE_LIBCAP_FOUND="yes" ],
[ LWS_HAVE_LIBCAP_FOUND="no" ]
)
AC_LANG_POP([C++])
AC_MSG_RESULT($LWS_HAVE_LIBCAP_FOUND)
if test x$LWS_HAVE_LIBCAP_FOUND = xyes; then
PKG_CHECK_MODULES_STATIC([LIBCAP], [libcap],, [AC_MSG_ERROR(libcap not found.)])
AC_SUBST([LIBCAP_LIBS])
fi
AM_CONDITIONAL([BUILD_OPENSSL_SUPPORT], [test x$LWS_WITH_TLS_FOUND = xyes])
AM_CONDITIONAL([BUILD_LIBUV_SUPPORT], [test x$LWS_WITH_LIBUV_FOUND = xyes])
AM_CONDITIONAL([BUILD_LIBEVENT_SUPPORT], [test x$LWS_WITH_LIBEVENT_FOUND = xyes])
AM_CONDITIONAL([BUILD_LIBCAP_SUPPORT], [test x$LWS_HAVE_LIBCAP_FOUND = xyes])
AM_CONDITIONAL([BUILD_LDL_REQUIRED], [test x$LDL_REQUIRED = xyes])
dnl Clang detection is complicated since it comes up as GCC too.
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
not clang
#endif
]])],
[CLANG=yes], [CLANG=no])
AC_LANG_POP([C++])
AC_MSG_RESULT([is compiler clang: $CLANG])
AC_SUBST([CLANG])
# Declare CFLAGS "unprecious" so that it can be passed directly to subdirs.
AC_DEFUN([AX_UNPRECIOUS], [
m4_define([_AC_PRECIOUS_VARS], m4_bpatsubst(_AC_PRECIOUS_VARS, [$1
], []))
])
AX_UNPRECIOUS([CFLAGS])
export BUILD_OS
export CFLAGS
export CXXFLAGS
export LDFLAGS
AM_CONDITIONAL([HAVE_CLANG], [test x$CLANG = xyes])
AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
AC_CONFIG_FILES(Makefile
cppForSwig/Makefile
cppForSwig/chacha20poly1305/Makefile
cppForSwig/hkdf/Makefile)
AM_CONDITIONAL([BUILD_BENCH], [test x$want_benchmark = xyes])
AM_CONDITIONAL([BUILD_TESTS], [test "x$want_tests" = "xyes"])
AC_OUTPUT
echo " Armory Autotools flags"
echo " CC = $CC"
echo " CFLAGS = $CFLAGS"
echo " CPP = $CPP"
echo " CPPFLAGS = $CPPFLAGS"
echo " CXX = $CXX"
echo " CXXFLAGS = $CXXFLAGS"
echo " LDFLAGS = $LDFLAGS"
echo " LD = $LD"
echo " LIBS = $LIBS"
echo " ac_configure_args = $ac_configure_args"
echo " with tests = $want_tests"
echo " with benchmarks = $want_benchmark"
echo " debug symbols = $want_debug"
echo " with client = $build_client"
echo " custom lws path = $with_own_lws"
echo " custom libbtc = $with_own_libbtc"