configure.ac 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  1. dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
  2. AC_PREREQ([2.60])
  3. define(_CLIENT_VERSION_MAJOR, 0)
  4. define(_CLIENT_VERSION_MINOR, 17)
  5. define(_CLIENT_VERSION_REVISION, 1)
  6. define(_CLIENT_VERSION_BUILD, 0)
  7. define(_CLIENT_VERSION_IS_RELEASE, true)
  8. define(_COPYRIGHT_YEAR, 2019)
  9. define(_COPYRIGHT_HOLDERS,[The %s developers])
  10. define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Litecoin Core]])
  11. AC_INIT([Litecoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/litecoin-project/litecoin/issues],[litecoin],[https://litecoin.org/])
  12. AC_CONFIG_SRCDIR([src/validation.cpp])
  13. AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
  14. AC_CONFIG_AUX_DIR([build-aux])
  15. AC_CONFIG_MACRO_DIR([build-aux/m4])
  16. BITCOIN_DAEMON_NAME=litecoind
  17. BITCOIN_GUI_NAME=litecoin-qt
  18. BITCOIN_CLI_NAME=litecoin-cli
  19. BITCOIN_TX_NAME=litecoin-tx
  20. dnl Unless the user specified ARFLAGS, force it to be cr
  21. AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to <cr> if not set])
  22. if test "x${ARFLAGS+set}" != "xset"; then
  23. ARFLAGS="cr"
  24. fi
  25. AC_CANONICAL_HOST
  26. AH_TOP([#ifndef BITCOIN_CONFIG_H])
  27. AH_TOP([#define BITCOIN_CONFIG_H])
  28. AH_BOTTOM([#endif //BITCOIN_CONFIG_H])
  29. dnl faketime breaks configure and is only needed for make. Disable it here.
  30. unset FAKETIME
  31. dnl Automake init set-up and checks
  32. AM_INIT_AUTOMAKE([no-define subdir-objects foreign])
  33. dnl faketime messes with timestamps and causes configure to be re-run.
  34. dnl --disable-maintainer-mode can be used to bypass this.
  35. AM_MAINTAINER_MODE([enable])
  36. dnl make the compilation flags quiet unless V=1 is used
  37. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  38. dnl Compiler checks (here before libtool).
  39. if test "x${CXXFLAGS+set}" = "xset"; then
  40. CXXFLAGS_overridden=yes
  41. else
  42. CXXFLAGS_overridden=no
  43. fi
  44. AC_PROG_CXX
  45. dnl By default, libtool for mingw refuses to link static libs into a dll for
  46. dnl fear of mixing pic/non-pic objects, and import/export complications. Since
  47. dnl we have those under control, re-enable that functionality.
  48. case $host in
  49. *mingw*)
  50. lt_cv_deplibs_check_method="pass_all"
  51. ;;
  52. esac
  53. dnl Require C++11 compiler (no GNU extensions)
  54. AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault])
  55. dnl Check if -latomic is required for <std::atomic>
  56. CHECK_ATOMIC
  57. dnl Unless the user specified OBJCXX, force it to be the same as CXX. This ensures
  58. dnl that we get the same -std flags for both.
  59. m4_ifdef([AC_PROG_OBJCXX],[
  60. if test "x${OBJCXX+set}" = "x"; then
  61. OBJCXX="${CXX}"
  62. fi
  63. AC_PROG_OBJCXX
  64. ])
  65. dnl Libtool init checks.
  66. LT_INIT([pic-only])
  67. dnl Check/return PATH for base programs.
  68. AC_PATH_TOOL(AR, ar)
  69. AC_PATH_TOOL(RANLIB, ranlib)
  70. AC_PATH_TOOL(STRIP, strip)
  71. AC_PATH_TOOL(GCOV, gcov)
  72. AC_PATH_PROG(LCOV, lcov)
  73. dnl Python 3.x is supported from 3.4 on (see https://github.com/bitcoin/bitcoin/issues/7893)
  74. AC_PATH_PROGS([PYTHON], [python3.7 python3.6 python3.5 python3.4 python3 python])
  75. AC_PATH_PROG(GENHTML, genhtml)
  76. AC_PATH_PROG([GIT], [git])
  77. AC_PATH_PROG(CCACHE,ccache)
  78. AC_PATH_PROG(XGETTEXT,xgettext)
  79. AC_PATH_PROG(HEXDUMP,hexdump)
  80. AC_PATH_TOOL(READELF, readelf)
  81. AC_PATH_TOOL(CPPFILT, c++filt)
  82. AC_PATH_TOOL(OBJCOPY, objcopy)
  83. AC_PATH_PROG(DOXYGEN, doxygen)
  84. if test -z "$DOXYGEN"; then
  85. AC_MSG_WARN([Doxygen not found])
  86. fi
  87. AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
  88. AC_ARG_VAR(PYTHONPATH, Augments the default search path for python module files)
  89. # Enable wallet
  90. AC_ARG_ENABLE([wallet],
  91. [AS_HELP_STRING([--disable-wallet],
  92. [disable wallet (enabled by default)])],
  93. [enable_wallet=$enableval],
  94. [enable_wallet=yes])
  95. AC_ARG_WITH([miniupnpc],
  96. [AS_HELP_STRING([--with-miniupnpc],
  97. [enable UPNP (default is yes if libminiupnpc is found)])],
  98. [use_upnp=$withval],
  99. [use_upnp=auto])
  100. AC_ARG_ENABLE([upnp-default],
  101. [AS_HELP_STRING([--enable-upnp-default],
  102. [if UPNP is enabled, turn it on at startup (default is no)])],
  103. [use_upnp_default=$enableval],
  104. [use_upnp_default=no])
  105. AC_ARG_ENABLE(tests,
  106. AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]),
  107. [use_tests=$enableval],
  108. [use_tests=yes])
  109. AC_ARG_ENABLE(gui-tests,
  110. AS_HELP_STRING([--disable-gui-tests],[do not compile GUI tests (default is to compile if GUI and tests enabled)]),
  111. [use_gui_tests=$enableval],
  112. [use_gui_tests=$use_tests])
  113. AC_ARG_ENABLE(bench,
  114. AS_HELP_STRING([--disable-bench],[do not compile benchmarks (default is to compile)]),
  115. [use_bench=$enableval],
  116. [use_bench=yes])
  117. AC_ARG_ENABLE([extended-functional-tests],
  118. AS_HELP_STRING([--enable-extended-functional-tests],[enable expensive functional tests when using lcov (default no)]),
  119. [use_extended_functional_tests=$enableval],
  120. [use_extended_functional_tests=no])
  121. AC_ARG_WITH([qrencode],
  122. [AS_HELP_STRING([--with-qrencode],
  123. [enable QR code support (default is yes if qt is enabled and libqrencode is found)])],
  124. [use_qr=$withval],
  125. [use_qr=auto])
  126. AC_ARG_ENABLE([hardening],
  127. [AS_HELP_STRING([--disable-hardening],
  128. [do not attempt to harden the resulting executables (default is to harden when possible)])],
  129. [use_hardening=$enableval],
  130. [use_hardening=auto])
  131. AC_ARG_ENABLE([reduce-exports],
  132. [AS_HELP_STRING([--enable-reduce-exports],
  133. [attempt to reduce exported symbols in the resulting executables (default is no)])],
  134. [use_reduce_exports=$enableval],
  135. [use_reduce_exports=no])
  136. AC_ARG_ENABLE([ccache],
  137. [AS_HELP_STRING([--disable-ccache],
  138. [do not use ccache for building (default is to use if found)])],
  139. [use_ccache=$enableval],
  140. [use_ccache=auto])
  141. AC_ARG_ENABLE([lcov],
  142. [AS_HELP_STRING([--enable-lcov],
  143. [enable lcov testing (default is no)])],
  144. [use_lcov=$enableval],
  145. [use_lcov=no])
  146. AC_ARG_ENABLE([lcov-branch-coverage],
  147. [AS_HELP_STRING([--enable-lcov-branch-coverage],
  148. [enable lcov testing branch coverage (default is no)])],
  149. [use_lcov_branch=yes],
  150. [use_lcov_branch=no])
  151. AC_ARG_ENABLE([glibc-back-compat],
  152. [AS_HELP_STRING([--enable-glibc-back-compat],
  153. [enable backwards compatibility with glibc])],
  154. [use_glibc_compat=$enableval],
  155. [use_glibc_compat=no])
  156. AC_ARG_ENABLE([asm],
  157. [AS_HELP_STRING([--enable-asm],
  158. [Enable assembly routines (default is yes)])],
  159. [use_asm=$enableval],
  160. [use_asm=yes])
  161. if test "x$use_asm" = xyes; then
  162. AC_DEFINE(USE_ASM, 1, [Define this symbol to build in assembly routines])
  163. fi
  164. AC_ARG_WITH([system-univalue],
  165. [AS_HELP_STRING([--with-system-univalue],
  166. [Build with system UniValue (default is no)])],
  167. [system_univalue=$withval],
  168. [system_univalue=no]
  169. )
  170. AC_ARG_ENABLE([zmq],
  171. [AS_HELP_STRING([--disable-zmq],
  172. [disable ZMQ notifications])],
  173. [use_zmq=$enableval],
  174. [use_zmq=yes])
  175. AC_ARG_ENABLE([sse2],
  176. [AS_HELP_STRING([--enable-sse2],
  177. [enable SSE2 instructions in the scrypt library. (default is disabled)])],
  178. [use_sse2=$enableval],
  179. [use_sse2=no])
  180. AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
  181. AC_ARG_ENABLE(man,
  182. [AS_HELP_STRING([--disable-man],
  183. [do not install man pages (default is to install)])],,
  184. enable_man=yes)
  185. AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
  186. # Enable debug
  187. AC_ARG_ENABLE([debug],
  188. [AS_HELP_STRING([--enable-debug],
  189. [use debug compiler flags and macros (default is no)])],
  190. [enable_debug=$enableval],
  191. [enable_debug=no])
  192. # Enable different -fsanitize options
  193. AC_ARG_WITH([sanitizers],
  194. [AS_HELP_STRING([--with-sanitizers],
  195. [comma separated list of extra sanitizers to build with (default is none enabled)])],
  196. [use_sanitizers=$withval])
  197. # Enable gprof profiling
  198. AC_ARG_ENABLE([gprof],
  199. [AS_HELP_STRING([--enable-gprof],
  200. [use gprof profiling compiler flags (default is no)])],
  201. [enable_gprof=$enableval],
  202. [enable_gprof=no])
  203. # Turn warnings into errors
  204. AC_ARG_ENABLE([werror],
  205. [AS_HELP_STRING([--enable-werror],
  206. [Treat certain compiler warnings as errors (default is no)])],
  207. [enable_werror=$enableval],
  208. [enable_werror=no])
  209. AC_LANG_PUSH([C++])
  210. AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""])
  211. if test "x$enable_debug" = xyes; then
  212. # Clear default -g -O2 flags
  213. if test "x$CXXFLAGS_overridden" = xno; then
  214. CXXFLAGS=""
  215. fi
  216. # Prefer -Og, fall back to -O0 if that is unavailable.
  217. AX_CHECK_COMPILE_FLAG(
  218. [-Og],
  219. [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Og"]],
  220. [AX_CHECK_COMPILE_FLAG([-O0],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"]],,[[$CXXFLAG_WERROR]])],
  221. [[$CXXFLAG_WERROR]])
  222. # Prefer -g3, fall back to -g if that is unavailable.
  223. AX_CHECK_COMPILE_FLAG(
  224. [-g3],
  225. [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g3"]],
  226. [AX_CHECK_COMPILE_FLAG([-g],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g"]],,[[$CXXFLAG_WERROR]])],
  227. [[$CXXFLAG_WERROR]])
  228. AX_CHECK_PREPROC_FLAG([-DDEBUG],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG"]],,[[$CXXFLAG_WERROR]])
  229. AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"]],,[[$CXXFLAG_WERROR]])
  230. AX_CHECK_COMPILE_FLAG([-ftrapv],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -ftrapv"],,[[$CXXFLAG_WERROR]])
  231. fi
  232. if test x$use_sanitizers != x; then
  233. # First check if the compiler accepts flags. If an incompatible pair like
  234. # -fsanitize=address,thread is used here, this check will fail. This will also
  235. # fail if a bad argument is passed, e.g. -fsanitize=undfeined
  236. AX_CHECK_COMPILE_FLAG(
  237. [[-fsanitize=$use_sanitizers]],
  238. [[SANITIZER_CXXFLAGS=-fsanitize=$use_sanitizers]],
  239. [AC_MSG_ERROR([compiler did not accept requested flags])])
  240. # Some compilers (e.g. GCC) require additional libraries like libasan,
  241. # libtsan, libubsan, etc. Make sure linking still works with the sanitize
  242. # flag. This is a separate check so we can give a better error message when
  243. # the sanitize flags are supported by the compiler but the actual sanitizer
  244. # libs are missing.
  245. AX_CHECK_LINK_FLAG(
  246. [[-fsanitize=$use_sanitizers]],
  247. [[SANITIZER_LDFLAGS=-fsanitize=$use_sanitizers]],
  248. [AC_MSG_ERROR([linker did not accept requested flags, you are missing required libraries])])
  249. fi
  250. ERROR_CXXFLAGS=
  251. if test "x$enable_werror" = "xyes"; then
  252. if test "x$CXXFLAG_WERROR" = "x"; then
  253. AC_MSG_ERROR("enable-werror set but -Werror is not usable")
  254. fi
  255. AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]])
  256. AX_CHECK_COMPILE_FLAG([-Werror=thread-safety-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety-analysis"],,[[$CXXFLAG_WERROR]])
  257. fi
  258. if test "x$CXXFLAGS_overridden" = "xno"; then
  259. AX_CHECK_COMPILE_FLAG([-Wall],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]])
  260. AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
  261. AX_CHECK_COMPILE_FLAG([-Wformat],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
  262. AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
  263. AX_CHECK_COMPILE_FLAG([-Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
  264. AX_CHECK_COMPILE_FLAG([-Wthread-safety-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety-analysis"],,[[$CXXFLAG_WERROR]])
  265. AX_CHECK_COMPILE_FLAG([-Wrange-loop-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wrange-loop-analysis"],,[[$CXXFLAG_WERROR]])
  266. ## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
  267. ## unknown options if any other warning is produced. Test the -Wfoo case, and
  268. ## set the -Wno-foo case if it works.
  269. AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]])
  270. AX_CHECK_COMPILE_FLAG([-Wself-assign],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]])
  271. AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
  272. AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])
  273. AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]])
  274. fi
  275. # Check for optional instruction set support. Enabling these does _not_ imply that all code will
  276. # be compiled with them, rather that specific objects/libs may use them after checking for runtime
  277. # compatibility.
  278. AX_CHECK_COMPILE_FLAG([-msse4.2],[[SSE42_CXXFLAGS="-msse4.2"]],,[[$CXXFLAG_WERROR]])
  279. AX_CHECK_COMPILE_FLAG([-msse4.1],[[SSE41_CXXFLAGS="-msse4.1"]],,[[$CXXFLAG_WERROR]])
  280. AX_CHECK_COMPILE_FLAG([-mavx -mavx2],[[AVX2_CXXFLAGS="-mavx -mavx2"]],,[[$CXXFLAG_WERROR]])
  281. AX_CHECK_COMPILE_FLAG([-msse4 -msha],[[SHANI_CXXFLAGS="-msse4 -msha"]],,[[$CXXFLAG_WERROR]])
  282. TEMP_CXXFLAGS="$CXXFLAGS"
  283. CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS"
  284. AC_MSG_CHECKING(for assembler crc32 support)
  285. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  286. #include <stdint.h>
  287. #if defined(_MSC_VER)
  288. #include <intrin.h>
  289. #elif defined(__GNUC__) && defined(__SSE4_2__)
  290. #include <nmmintrin.h>
  291. #endif
  292. ]],[[
  293. uint64_t l = 0;
  294. l = _mm_crc32_u8(l, 0);
  295. l = _mm_crc32_u32(l, 0);
  296. l = _mm_crc32_u64(l, 0);
  297. return l;
  298. ]])],
  299. [ AC_MSG_RESULT(yes); enable_hwcrc32=yes],
  300. [ AC_MSG_RESULT(no)]
  301. )
  302. CXXFLAGS="$TEMP_CXXFLAGS"
  303. TEMP_CXXFLAGS="$CXXFLAGS"
  304. CXXFLAGS="$CXXFLAGS $SSE41_CXXFLAGS"
  305. AC_MSG_CHECKING(for SSE4.1 intrinsics)
  306. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  307. #include <stdint.h>
  308. #include <immintrin.h>
  309. ]],[[
  310. __m128i l = _mm_set1_epi32(0);
  311. return _mm_extract_epi32(l, 3);
  312. ]])],
  313. [ AC_MSG_RESULT(yes); enable_sse41=yes; AC_DEFINE(ENABLE_SSE41, 1, [Define this symbol to build code that uses SSE4.1 intrinsics]) ],
  314. [ AC_MSG_RESULT(no)]
  315. )
  316. CXXFLAGS="$TEMP_CXXFLAGS"
  317. TEMP_CXXFLAGS="$CXXFLAGS"
  318. CXXFLAGS="$CXXFLAGS $AVX2_CXXFLAGS"
  319. AC_MSG_CHECKING(for AVX2 intrinsics)
  320. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  321. #include <stdint.h>
  322. #include <immintrin.h>
  323. ]],[[
  324. __m256i l = _mm256_set1_epi32(0);
  325. return _mm256_extract_epi32(l, 7);
  326. ]])],
  327. [ AC_MSG_RESULT(yes); enable_avx2=yes; AC_DEFINE(ENABLE_AVX2, 1, [Define this symbol to build code that uses AVX2 intrinsics]) ],
  328. [ AC_MSG_RESULT(no)]
  329. )
  330. CXXFLAGS="$TEMP_CXXFLAGS"
  331. TEMP_CXXFLAGS="$CXXFLAGS"
  332. CXXFLAGS="$CXXFLAGS $SHANI_CXXFLAGS"
  333. AC_MSG_CHECKING(for SHA-NI intrinsics)
  334. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  335. #include <stdint.h>
  336. #include <immintrin.h>
  337. ]],[[
  338. __m128i i = _mm_set1_epi32(0);
  339. __m128i j = _mm_set1_epi32(1);
  340. __m128i k = _mm_set1_epi32(2);
  341. return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, i, k), 0);
  342. ]])],
  343. [ AC_MSG_RESULT(yes); enable_shani=yes; AC_DEFINE(ENABLE_SHANI, 1, [Define this symbol to build code that uses SHA-NI intrinsics]) ],
  344. [ AC_MSG_RESULT(no)]
  345. )
  346. CXXFLAGS="$TEMP_CXXFLAGS"
  347. CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
  348. AC_ARG_WITH([utils],
  349. [AS_HELP_STRING([--with-utils],
  350. [build litecoin-cli bitcoin-tx (default=yes)])],
  351. [build_bitcoin_utils=$withval],
  352. [build_bitcoin_utils=yes])
  353. AC_ARG_WITH([libs],
  354. [AS_HELP_STRING([--with-libs],
  355. [build libraries (default=yes)])],
  356. [build_bitcoin_libs=$withval],
  357. [build_bitcoin_libs=yes])
  358. AC_ARG_WITH([daemon],
  359. [AS_HELP_STRING([--with-daemon],
  360. [build litecoind daemon (default=yes)])],
  361. [build_bitcoind=$withval],
  362. [build_bitcoind=yes])
  363. use_pkgconfig=yes
  364. case $host in
  365. *mingw*)
  366. #pkgconfig does more harm than good with MinGW
  367. use_pkgconfig=no
  368. TARGET_OS=windows
  369. AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(libmingwthrd missing))
  370. AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(libkernel32 missing))
  371. AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(libuser32 missing))
  372. AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(libgdi32 missing))
  373. AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(libcomdlg32 missing))
  374. AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(libwinspool missing))
  375. AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(libwinmm missing))
  376. AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(libshell32 missing))
  377. AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(libcomctl32 missing))
  378. AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(libole32 missing))
  379. AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(liboleaut32 missing))
  380. AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(libuuid missing))
  381. AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(librpcrt4 missing))
  382. AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(libadvapi32 missing))
  383. AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(libws2_32 missing))
  384. AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(libmswsock missing))
  385. AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(libshlwapi missing))
  386. AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(libiphlpapi missing))
  387. AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(libcrypt32 missing))
  388. # -static is interpreted by libtool, where it has a different meaning.
  389. # In libtool-speak, it's -all-static.
  390. AX_CHECK_LINK_FLAG([[-static]],[LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"])
  391. AC_PATH_PROG([MAKENSIS], [makensis], none)
  392. if test x$MAKENSIS = xnone; then
  393. AC_MSG_WARN("makensis not found. Cannot create installer.")
  394. fi
  395. AC_PATH_TOOL(WINDRES, windres, none)
  396. if test x$WINDRES = xnone; then
  397. AC_MSG_ERROR("windres not found")
  398. fi
  399. CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
  400. LEVELDB_TARGET_FLAGS="-DOS_WINDOWS"
  401. if test "x$CXXFLAGS_overridden" = "xno"; then
  402. CXXFLAGS="$CXXFLAGS -w"
  403. fi
  404. case $host in
  405. i?86-*) WINDOWS_BITS=32 ;;
  406. x86_64-*) WINDOWS_BITS=64 ;;
  407. *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;;
  408. esac
  409. AC_SUBST(WINDOWS_BITS)
  410. dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against.
  411. dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override
  412. dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are
  413. dnl also overridden to prevent their insertion later.
  414. dnl This should only affect dll's.
  415. archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
  416. postdeps_CXX=
  417. ;;
  418. *darwin*)
  419. TARGET_OS=darwin
  420. LEVELDB_TARGET_FLAGS="-DOS_MACOSX"
  421. if test x$cross_compiling != xyes; then
  422. BUILD_OS=darwin
  423. AC_CHECK_PROG([PORT],port, port)
  424. if test x$PORT = xport; then
  425. dnl add default macports paths
  426. CPPFLAGS="$CPPFLAGS -isystem /opt/local/include"
  427. LIBS="$LIBS -L/opt/local/lib"
  428. if test -d /opt/local/include/db48; then
  429. CPPFLAGS="$CPPFLAGS -I/opt/local/include/db48"
  430. LIBS="$LIBS -L/opt/local/lib/db48"
  431. fi
  432. fi
  433. AC_PATH_PROGS([RSVG_CONVERT], [rsvg-convert rsvg],rsvg-convert)
  434. AC_CHECK_PROG([BREW],brew, brew)
  435. if test x$BREW = xbrew; then
  436. dnl These Homebrew packages may be keg-only, meaning that they won't be found
  437. dnl in expected paths because they may conflict with system files. Ask
  438. dnl Homebrew where each one is located, then adjust paths accordingly.
  439. dnl It's safe to add these paths even if the functionality is disabled by
  440. dnl the user (--without-wallet or --without-gui for example).
  441. openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
  442. bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null`
  443. qt5_prefix=`$BREW --prefix qt5 2>/dev/null`
  444. if test x$openssl_prefix != x; then
  445. PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
  446. export PKG_CONFIG_PATH
  447. fi
  448. if test x$bdb_prefix != x; then
  449. CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include"
  450. LIBS="$LIBS -L$bdb_prefix/lib"
  451. fi
  452. if test x$qt5_prefix != x; then
  453. PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
  454. export PKG_CONFIG_PATH
  455. fi
  456. fi
  457. else
  458. case $build_os in
  459. *darwin*)
  460. BUILD_OS=darwin
  461. ;;
  462. *)
  463. AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool)
  464. AC_PATH_TOOL([OTOOL], [otool], otool)
  465. AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage)
  466. AC_PATH_PROGS([RSVG_CONVERT], [rsvg-convert rsvg],rsvg-convert)
  467. AC_PATH_PROGS([IMAGEMAGICK_CONVERT], [convert],convert)
  468. AC_PATH_PROGS([TIFFCP], [tiffcp],tiffcp)
  469. dnl libtool will try to strip the static lib, which is a problem for
  470. dnl cross-builds because strip attempts to call a hard-coded ld,
  471. dnl which may not exist in the path. Stripping the .a is not
  472. dnl necessary, so just disable it.
  473. old_striplib=
  474. ;;
  475. esac
  476. fi
  477. AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"])
  478. CPPFLAGS="$CPPFLAGS -DMAC_OSX"
  479. OBJCXXFLAGS="$CXXFLAGS"
  480. ;;
  481. *android*)
  482. dnl make sure android stays above linux for hosts like *linux-android*
  483. LEVELDB_TARGET_FLAGS="-DOS_ANDROID"
  484. ;;
  485. *linux*)
  486. TARGET_OS=linux
  487. LEVELDB_TARGET_FLAGS="-DOS_LINUX"
  488. ;;
  489. *kfreebsd*)
  490. LEVELDB_TARGET_FLAGS="-DOS_KFREEBSD"
  491. ;;
  492. *freebsd*)
  493. LEVELDB_TARGET_FLAGS="-DOS_FREEBSD"
  494. ;;
  495. *openbsd*)
  496. LEVELDB_TARGET_FLAGS="-DOS_OPENBSD"
  497. ;;
  498. *netbsd*)
  499. LEVELDB_TARGET_FLAGS="-DOS_NETBSD"
  500. ;;
  501. *dragonfly*)
  502. LEVELDB_TARGET_FLAGS="-DOS_DRAGONFLYBSD"
  503. ;;
  504. *solaris*)
  505. LEVELDB_TARGET_FLAGS="-DOS_SOLARIS"
  506. ;;
  507. *hpux*)
  508. LEVELDB_TARGET_FLAGS="-DOS_HPUX"
  509. ;;
  510. *)
  511. AC_MSG_ERROR(Cannot build leveldb for $host. Please file a bug report.)
  512. ;;
  513. esac
  514. if test x$use_pkgconfig = xyes; then
  515. 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.)])
  516. m4_ifdef([PKG_PROG_PKG_CONFIG], [
  517. PKG_PROG_PKG_CONFIG
  518. if test x"$PKG_CONFIG" = "x"; then
  519. AC_MSG_ERROR(pkg-config not found.)
  520. fi
  521. ])
  522. fi
  523. if test x$use_extended_functional_tests != xno; then
  524. AC_SUBST(EXTENDED_FUNCTIONAL_TESTS, --extended)
  525. fi
  526. if test x$use_lcov = xyes; then
  527. if test x$LCOV = x; then
  528. AC_MSG_ERROR("lcov testing requested but lcov not found")
  529. fi
  530. if test x$GCOV = x; then
  531. AC_MSG_ERROR("lcov testing requested but gcov not found")
  532. fi
  533. if test x$PYTHON = x; then
  534. AC_MSG_ERROR("lcov testing requested but python not found")
  535. fi
  536. if test x$GENHTML = x; then
  537. AC_MSG_ERROR("lcov testing requested but genhtml not found")
  538. fi
  539. LCOV="$LCOV --gcov-tool=$GCOV"
  540. AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"],
  541. [AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")])
  542. AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
  543. [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
  544. AC_DEFINE(USE_COVERAGE, 1, [Define this symbol if coverage is enabled])
  545. CXXFLAGS="$CXXFLAGS -Og"
  546. fi
  547. if test x$use_lcov_branch != xno; then
  548. AC_SUBST(LCOV_OPTS, "$LCOV_OPTS --rc lcov_branch_coverage=1")
  549. fi
  550. dnl Check for endianness
  551. AC_C_BIGENDIAN
  552. dnl Check for pthread compile/link requirements
  553. AX_PTHREAD
  554. # The following macro will add the necessary defines to bitcoin-config.h, but
  555. # they also need to be passed down to any subprojects. Pull the results out of
  556. # the cache and add them to CPPFLAGS.
  557. AC_SYS_LARGEFILE
  558. # detect POSIX or GNU variant of strerror_r
  559. AC_FUNC_STRERROR_R
  560. if test x$ac_cv_sys_file_offset_bits != x &&
  561. test x$ac_cv_sys_file_offset_bits != xno &&
  562. test x$ac_cv_sys_file_offset_bits != xunknown; then
  563. CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
  564. fi
  565. if test x$ac_cv_sys_large_files != x &&
  566. test x$ac_cv_sys_large_files != xno &&
  567. test x$ac_cv_sys_large_files != xunknown; then
  568. CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
  569. fi
  570. AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"])
  571. AX_GCC_FUNC_ATTRIBUTE([visibility])
  572. AX_GCC_FUNC_ATTRIBUTE([dllexport])
  573. AX_GCC_FUNC_ATTRIBUTE([dllimport])
  574. if test x$use_glibc_compat != xno; then
  575. #glibc absorbed clock_gettime in 2.17. librt (its previous location) is safe to link
  576. #in anyway for back-compat.
  577. AC_CHECK_LIB([rt],[clock_gettime],, AC_MSG_ERROR(librt missing))
  578. #__fdelt_chk's params and return type have changed from long unsigned int to long int.
  579. # See which one is present here.
  580. AC_MSG_CHECKING(__fdelt_chk type)
  581. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE
  582. #undef _FORTIFY_SOURCE
  583. #endif
  584. #define _FORTIFY_SOURCE 2
  585. #include <sys/select.h>
  586. extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])],
  587. [ fdelt_type="long unsigned int"],
  588. [ fdelt_type="long int"])
  589. AC_MSG_RESULT($fdelt_type)
  590. AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk])
  591. AX_CHECK_LINK_FLAG([[-Wl,--wrap=__divmoddi4]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"])
  592. AX_CHECK_LINK_FLAG([[-Wl,--wrap=log2f]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"])
  593. else
  594. AC_SEARCH_LIBS([clock_gettime],[rt])
  595. fi
  596. if test "x$enable_gprof" = xyes; then
  597. dnl -pg is incompatible with -pie. Since hardening and profiling together doesn't make sense,
  598. dnl we simply make them mutually exclusive here. Additionally, hardened toolchains may force
  599. dnl -pie by default, in which case it needs to be turned off with -no-pie.
  600. if test x$use_hardening = xyes; then
  601. AC_MSG_ERROR(gprof profiling is not compatible with hardening. Reconfigure with --disable-hardening or --disable-gprof)
  602. fi
  603. use_hardening=no
  604. AX_CHECK_COMPILE_FLAG([-pg],[GPROF_CXXFLAGS="-pg"],
  605. [AC_MSG_ERROR(gprof profiling requested but not available)], [[$CXXFLAG_WERROR]])
  606. AX_CHECK_LINK_FLAG([[-no-pie]], [GPROF_LDFLAGS="-no-pie"])
  607. AX_CHECK_LINK_FLAG([[-pg]],[GPROF_LDFLAGS="$GPROF_LDFLAGS -pg"],
  608. [AC_MSG_ERROR(gprof profiling requested but not available)], [[$GPROF_LDFLAGS]])
  609. fi
  610. if test x$TARGET_OS != xwindows; then
  611. # All windows code is PIC, forcing it on just adds useless compile warnings
  612. AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
  613. fi
  614. if test x$use_hardening != xno; then
  615. use_hardening=yes
  616. AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
  617. AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
  618. AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
  619. AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
  620. HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
  621. ])
  622. HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
  623. ])
  624. AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
  625. AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])
  626. AX_CHECK_LINK_FLAG([[-Wl,--high-entropy-va]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"])
  627. AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"])
  628. AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"])
  629. AX_CHECK_LINK_FLAG([[-fPIE -pie]], [PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],, [[$CXXFLAG_WERROR]])
  630. case $host in
  631. *mingw*)
  632. AC_CHECK_LIB([ssp], [main],, AC_MSG_ERROR(libssp missing))
  633. ;;
  634. esac
  635. fi
  636. dnl this flag screws up non-darwin gcc even when the check fails. special-case it.
  637. if test x$TARGET_OS = xdarwin; then
  638. AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
  639. fi
  640. AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
  641. AC_CHECK_DECLS([strnlen])
  642. # Check for daemon(3), unrelated to --with-daemon (although used by it)
  643. AC_CHECK_DECLS([daemon])
  644. AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,,
  645. [#if HAVE_ENDIAN_H
  646. #include <endian.h>
  647. #elif HAVE_SYS_ENDIAN_H
  648. #include <sys/endian.h>
  649. #endif])
  650. AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64],,,
  651. [#if HAVE_BYTESWAP_H
  652. #include <byteswap.h>
  653. #endif])
  654. AC_CHECK_DECLS([__builtin_clz, __builtin_clzl, __builtin_clzll])
  655. dnl Check for malloc_info (for memory statistics information in getmemoryinfo)
  656. AC_MSG_CHECKING(for getmemoryinfo)
  657. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
  658. [[ int f = malloc_info(0, NULL); ]])],
  659. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MALLOC_INFO, 1,[Define this symbol if you have malloc_info]) ],
  660. [ AC_MSG_RESULT(no)]
  661. )
  662. dnl Check for mallopt(M_ARENA_MAX) (to set glibc arenas)
  663. AC_MSG_CHECKING(for mallopt M_ARENA_MAX)
  664. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
  665. [[ mallopt(M_ARENA_MAX, 1); ]])],
  666. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MALLOPT_ARENA_MAX, 1,[Define this symbol if you have mallopt with M_ARENA_MAX]) ],
  667. [ AC_MSG_RESULT(no)]
  668. )
  669. AC_MSG_CHECKING([for visibility attribute])
  670. AC_LINK_IFELSE([AC_LANG_SOURCE([
  671. int foo_def( void ) __attribute__((visibility("default")));
  672. int main(){}
  673. ])],
  674. [
  675. AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.])
  676. AC_MSG_RESULT(yes)
  677. ],
  678. [
  679. AC_MSG_RESULT(no)
  680. if test x$use_reduce_exports = xyes; then
  681. AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduce-exports.])
  682. fi
  683. ]
  684. )
  685. TEMP_LDFLAGS="$LDFLAGS"
  686. LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS"
  687. AC_MSG_CHECKING([for thread_local support])
  688. AC_LINK_IFELSE([AC_LANG_SOURCE([
  689. #include <thread>
  690. static thread_local int foo = 0;
  691. static void run_thread() { foo++;}
  692. int main(){
  693. for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();}
  694. return foo;
  695. }
  696. ])],
  697. [
  698. AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define if thread_local is supported.])
  699. AC_MSG_RESULT(yes)
  700. ],
  701. [
  702. AC_MSG_RESULT(no)
  703. ]
  704. )
  705. LDFLAGS="$TEMP_LDFLAGS"
  706. # Check for different ways of gathering OS randomness
  707. AC_MSG_CHECKING(for Linux getrandom syscall)
  708. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
  709. #include <sys/syscall.h>
  710. #include <linux/random.h>]],
  711. [[ syscall(SYS_getrandom, nullptr, 32, 0); ]])],
  712. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_GETRANDOM, 1,[Define this symbol if the Linux getrandom system call is available]) ],
  713. [ AC_MSG_RESULT(no)]
  714. )
  715. AC_MSG_CHECKING(for getentropy)
  716. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]],
  717. [[ getentropy(nullptr, 32) ]])],
  718. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_GETENTROPY, 1,[Define this symbol if the BSD getentropy system call is available]) ],
  719. [ AC_MSG_RESULT(no)]
  720. )
  721. AC_MSG_CHECKING(for getentropy via random.h)
  722. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
  723. #include <sys/random.h>]],
  724. [[ getentropy(nullptr, 32) ]])],
  725. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_GETENTROPY_RAND, 1,[Define this symbol if the BSD getentropy system call is available with sys/random.h]) ],
  726. [ AC_MSG_RESULT(no)]
  727. )
  728. AC_MSG_CHECKING(for sysctl KERN_ARND)
  729. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  730. #include <sys/sysctl.h>]],
  731. [[ static const int name[2] = {CTL_KERN, KERN_ARND};
  732. sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])],
  733. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL_ARND, 1,[Define this symbol if the BSD sysctl(KERN_ARND) is available]) ],
  734. [ AC_MSG_RESULT(no)]
  735. )
  736. AC_MSG_CHECKING(for if type char equals int8_t)
  737. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>
  738. #include <type_traits>]],
  739. [[ static_assert(std::is_same<int8_t, char>::value, ""); ]])],
  740. [ AC_MSG_RESULT(yes); AC_DEFINE(CHAR_EQUALS_INT8, 1,[Define this symbol if type char equals int8_t]) ],
  741. [ AC_MSG_RESULT(no)]
  742. )
  743. # Check for reduced exports
  744. if test x$use_reduce_exports = xyes; then
  745. AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
  746. [AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])])
  747. fi
  748. LEVELDB_CPPFLAGS=
  749. LIBLEVELDB=
  750. LIBMEMENV=
  751. AM_CONDITIONAL([EMBEDDED_LEVELDB],[true])
  752. AC_SUBST(LEVELDB_CPPFLAGS)
  753. AC_SUBST(LIBLEVELDB)
  754. AC_SUBST(LIBMEMENV)
  755. if test x$enable_wallet != xno; then
  756. dnl Check for libdb_cxx only if wallet enabled
  757. BITCOIN_FIND_BDB48
  758. fi
  759. dnl Check for libminiupnpc (optional)
  760. if test x$use_upnp != xno; then
  761. AC_CHECK_HEADERS(
  762. [miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h miniupnpc/upnperrors.h],
  763. [AC_CHECK_LIB([miniupnpc], [upnpDiscover], [MINIUPNPC_LIBS=-lminiupnpc], [have_miniupnpc=no])],
  764. [have_miniupnpc=no]
  765. )
  766. fi
  767. BITCOIN_QT_INIT
  768. dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
  769. BITCOIN_QT_CONFIGURE([$use_pkgconfig])
  770. if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench = xnonononono; then
  771. use_boost=no
  772. else
  773. use_boost=yes
  774. fi
  775. if test x$use_boost = xyes; then
  776. dnl Minimum required Boost version
  777. define(MINIMUM_REQUIRED_BOOST, 1.47.0)
  778. dnl Check for boost libs
  779. AX_BOOST_BASE([MINIMUM_REQUIRED_BOOST])
  780. if test x$want_boost = xno; then
  781. AC_MSG_ERROR([[only libbitcoinconsensus can be built without boost]])
  782. fi
  783. AX_BOOST_SYSTEM
  784. AX_BOOST_FILESYSTEM
  785. AX_BOOST_THREAD
  786. AX_BOOST_CHRONO
  787. dnl Boost 1.56 through 1.62 allow using std::atomic instead of its own atomic
  788. dnl counter implementations. In 1.63 and later the std::atomic approach is default.
  789. m4_pattern_allow(DBOOST_AC_USE_STD_ATOMIC) dnl otherwise it's treated like a macro
  790. BOOST_CPPFLAGS="-DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC $BOOST_CPPFLAGS"
  791. if test x$use_reduce_exports = xyes; then
  792. AC_MSG_CHECKING([for working boost reduced exports])
  793. TEMP_CPPFLAGS="$CPPFLAGS"
  794. CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
  795. AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
  796. @%:@include <boost/version.hpp>
  797. ]], [[
  798. #if BOOST_VERSION >= 104900
  799. // Everything is okay
  800. #else
  801. # error Boost version is too old
  802. #endif
  803. ]])],[
  804. AC_MSG_RESULT(yes)
  805. ],[
  806. AC_MSG_ERROR([boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduce-exports.])
  807. ])
  808. CPPFLAGS="$TEMP_CPPFLAGS"
  809. fi
  810. fi
  811. if test x$use_reduce_exports = xyes; then
  812. CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
  813. AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"])
  814. fi
  815. if test x$use_tests = xyes; then
  816. if test x$HEXDUMP = x; then
  817. AC_MSG_ERROR(hexdump is required for tests)
  818. fi
  819. if test x$use_boost = xyes; then
  820. AX_BOOST_UNIT_TEST_FRAMEWORK
  821. dnl Determine if -DBOOST_TEST_DYN_LINK is needed
  822. AC_MSG_CHECKING([for dynamic linked boost test])
  823. TEMP_LIBS="$LIBS"
  824. LIBS="$LIBS $BOOST_LDFLAGS $BOOST_UNIT_TEST_FRAMEWORK_LIB"
  825. TEMP_CPPFLAGS="$CPPFLAGS"
  826. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  827. AC_LINK_IFELSE([AC_LANG_SOURCE([
  828. #define BOOST_TEST_DYN_LINK
  829. #define BOOST_TEST_MAIN
  830. #include <boost/test/unit_test.hpp>
  831. ])],
  832. [AC_MSG_RESULT(yes)]
  833. [TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"],
  834. [AC_MSG_RESULT(no)])
  835. LIBS="$TEMP_LIBS"
  836. CPPFLAGS="$TEMP_CPPFLAGS"
  837. fi
  838. fi
  839. if test x$use_boost = xyes; then
  840. BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
  841. dnl If boost (prior to 1.57) was built without c++11, it emulated scoped enums
  842. dnl using c++98 constructs. Unfortunately, this implementation detail leaked into
  843. dnl the abi. This was fixed in 1.57.
  844. dnl When building against that installed version using c++11, the headers pick up
  845. dnl on the native c++11 scoped enum support and enable it, however it will fail to
  846. dnl link. This can be worked around by disabling c++11 scoped enums if linking will
  847. dnl fail.
  848. dnl BOOST_NO_SCOPED_ENUMS was changed to BOOST_NO_CXX11_SCOPED_ENUMS in 1.51.
  849. TEMP_LIBS="$LIBS"
  850. LIBS="$BOOST_LIBS $LIBS"
  851. TEMP_CPPFLAGS="$CPPFLAGS"
  852. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  853. AC_MSG_CHECKING([for mismatched boost c++11 scoped enums])
  854. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  855. #include <boost/config.hpp>
  856. #include <boost/version.hpp>
  857. #if !defined(BOOST_NO_SCOPED_ENUMS) && !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && BOOST_VERSION < 105700
  858. #define BOOST_NO_SCOPED_ENUMS
  859. #define BOOST_NO_CXX11_SCOPED_ENUMS
  860. #define CHECK
  861. #endif
  862. #include <boost/filesystem.hpp>
  863. ]],[[
  864. #if defined(CHECK)
  865. boost::filesystem::copy_file("foo", "bar");
  866. #else
  867. choke;
  868. #endif
  869. ]])],
  870. [AC_MSG_RESULT(mismatched); BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS"], [AC_MSG_RESULT(ok)])
  871. LIBS="$TEMP_LIBS"
  872. CPPFLAGS="$TEMP_CPPFLAGS"
  873. dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
  874. dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
  875. dnl a working version is available, else fall back to sleep. sleep was removed
  876. dnl after 1.56.
  877. dnl If neither is available, abort.
  878. TEMP_LIBS="$LIBS"
  879. LIBS="$BOOST_LIBS $LIBS"
  880. TEMP_CPPFLAGS="$CPPFLAGS"
  881. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  882. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  883. #include <boost/thread/thread.hpp>
  884. #include <boost/version.hpp>
  885. ]],[[
  886. #if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
  887. boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
  888. #else
  889. choke me
  890. #endif
  891. ]])],
  892. [boost_sleep=yes;
  893. AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
  894. [boost_sleep=no])
  895. LIBS="$TEMP_LIBS"
  896. CPPFLAGS="$TEMP_CPPFLAGS"
  897. if test x$boost_sleep != xyes; then
  898. TEMP_LIBS="$LIBS"
  899. LIBS="$BOOST_LIBS $LIBS"
  900. TEMP_CPPFLAGS="$CPPFLAGS"
  901. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  902. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  903. #include <boost/version.hpp>
  904. #include <boost/thread.hpp>
  905. #include <boost/date_time/posix_time/posix_time_types.hpp>
  906. ]],[[
  907. #if BOOST_VERSION <= 105600
  908. boost::this_thread::sleep(boost::posix_time::milliseconds(0));
  909. #else
  910. choke me
  911. #endif
  912. ]])],
  913. [boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
  914. [boost_sleep=no])
  915. LIBS="$TEMP_LIBS"
  916. CPPFLAGS="$TEMP_CPPFLAGS"
  917. fi
  918. if test x$boost_sleep != xyes; then
  919. AC_MSG_ERROR(No working boost sleep implementation found.)
  920. fi
  921. fi
  922. if test x$use_pkgconfig = xyes; then
  923. : dnl
  924. m4_ifdef(
  925. [PKG_CHECK_MODULES],
  926. [
  927. PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
  928. PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
  929. BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
  930. if test x$use_qr != xno; then
  931. BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
  932. fi
  933. if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then
  934. PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)])
  935. if test x$TARGET_OS != xwindows; then
  936. PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads],, [AC_MSG_ERROR(libevent_pthreads not found.)])
  937. fi
  938. fi
  939. if test "x$use_zmq" = "xyes"; then
  940. PKG_CHECK_MODULES([ZMQ],[libzmq >= 4],
  941. [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])],
  942. [AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])
  943. AC_MSG_WARN([libzmq version 4.x or greater not found, disabling])
  944. use_zmq=no])
  945. else
  946. AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])
  947. fi
  948. ]
  949. )
  950. else
  951. AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing))
  952. AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing))
  953. AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
  954. AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing))
  955. if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then
  956. AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),)
  957. AC_CHECK_LIB([event],[main],EVENT_LIBS=-levent,AC_MSG_ERROR(libevent missing))
  958. if test x$TARGET_OS != xwindows; then
  959. AC_CHECK_LIB([event_pthreads],[main],EVENT_PTHREADS_LIBS=-levent_pthreads,AC_MSG_ERROR(libevent_pthreads missing))
  960. fi
  961. fi
  962. if test "x$use_zmq" = "xyes"; then
  963. AC_CHECK_HEADER([zmq.h],
  964. [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])],
  965. [AC_MSG_WARN([zmq.h not found, disabling zmq support])
  966. use_zmq=no
  967. AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])])
  968. AC_CHECK_LIB([zmq],[zmq_ctx_shutdown],ZMQ_LIBS=-lzmq,
  969. [AC_MSG_WARN([libzmq >= 4.0 not found, disabling zmq support])
  970. use_zmq=no
  971. AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])])
  972. else
  973. AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])
  974. fi
  975. if test "x$use_zmq" = "xyes"; then
  976. dnl Assume libzmq was built for static linking
  977. case $host in
  978. *mingw*)
  979. ZMQ_CFLAGS="$ZMQ_CFLAGS -DZMQ_STATIC"
  980. ;;
  981. esac
  982. fi
  983. BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
  984. if test x$use_qr != xno; then
  985. BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
  986. BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
  987. fi
  988. fi
  989. save_CXXFLAGS="${CXXFLAGS}"
  990. CXXFLAGS="${CXXFLAGS} ${CRYPTO_CFLAGS} ${SSL_CFLAGS}"
  991. AC_CHECK_DECLS([EVP_MD_CTX_new],,,[AC_INCLUDES_DEFAULT
  992. #include <openssl/x509_vfy.h>
  993. ])
  994. CXXFLAGS="${save_CXXFLAGS}"
  995. dnl univalue check
  996. need_bundled_univalue=yes
  997. if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench = xnonononono; then
  998. need_bundled_univalue=no
  999. else
  1000. if test x$system_univalue != xno ; then
  1001. found_univalue=no
  1002. if test x$use_pkgconfig = xyes; then
  1003. : #NOP
  1004. m4_ifdef(
  1005. [PKG_CHECK_MODULES],
  1006. [
  1007. PKG_CHECK_MODULES([UNIVALUE],[libunivalue >= 1.0.4],[found_univalue=yes],[true])
  1008. ]
  1009. )
  1010. else
  1011. AC_CHECK_HEADER([univalue.h],[
  1012. AC_CHECK_LIB([univalue], [main],[
  1013. UNIVALUE_LIBS=-lunivalue
  1014. found_univalue=yes
  1015. ],[true])
  1016. ],[true])
  1017. fi
  1018. if test x$found_univalue = xyes ; then
  1019. system_univalue=yes
  1020. need_bundled_univalue=no
  1021. elif test x$system_univalue = xyes ; then
  1022. AC_MSG_ERROR([univalue not found])
  1023. else
  1024. system_univalue=no
  1025. fi
  1026. fi
  1027. if test x$need_bundled_univalue = xyes ; then
  1028. UNIVALUE_CFLAGS='-I$(srcdir)/univalue/include'
  1029. UNIVALUE_LIBS='univalue/libunivalue.la'
  1030. fi
  1031. fi
  1032. AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes])
  1033. AC_SUBST(UNIVALUE_CFLAGS)
  1034. AC_SUBST(UNIVALUE_LIBS)
  1035. BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
  1036. AC_MSG_CHECKING([whether to build litecoind])
  1037. AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
  1038. AC_MSG_RESULT($build_bitcoind)
  1039. AC_MSG_CHECKING([whether to build utils (litecoin-cli litecoin-tx)])
  1040. AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
  1041. AC_MSG_RESULT($build_bitcoin_utils)
  1042. AC_MSG_CHECKING([whether to build libraries])
  1043. AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes])
  1044. if test x$build_bitcoin_libs = xyes; then
  1045. AC_DEFINE(HAVE_CONSENSUS_LIB, 1, [Define this symbol if the consensus lib has been built])
  1046. AC_CONFIG_FILES([libbitcoinconsensus.pc:libbitcoinconsensus.pc.in])
  1047. fi
  1048. AC_MSG_RESULT($build_bitcoin_libs)
  1049. AC_LANG_POP
  1050. if test "x$use_ccache" != "xno"; then
  1051. AC_MSG_CHECKING(if ccache should be used)
  1052. if test x$CCACHE = x; then
  1053. if test "x$use_ccache" = "xyes"; then
  1054. AC_MSG_ERROR([ccache not found.]);
  1055. else
  1056. use_ccache=no
  1057. fi
  1058. else
  1059. use_ccache=yes
  1060. CC="$ac_cv_path_CCACHE $CC"
  1061. CXX="$ac_cv_path_CCACHE $CXX"
  1062. fi
  1063. AC_MSG_RESULT($use_ccache)
  1064. fi
  1065. if test "x$use_ccache" = "xyes"; then
  1066. AX_CHECK_PREPROC_FLAG([-Qunused-arguments],[CPPFLAGS="-Qunused-arguments $CPPFLAGS"])
  1067. fi
  1068. dnl enable wallet
  1069. AC_MSG_CHECKING([if wallet should be enabled])
  1070. if test x$enable_wallet != xno; then
  1071. AC_MSG_RESULT(yes)
  1072. AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions])
  1073. else
  1074. AC_MSG_RESULT(no)
  1075. fi
  1076. dnl enable upnp support
  1077. AC_MSG_CHECKING([whether to build with support for UPnP])
  1078. if test x$have_miniupnpc = xno; then
  1079. if test x$use_upnp = xyes; then
  1080. AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
  1081. fi
  1082. AC_MSG_RESULT(no)
  1083. else
  1084. if test x$use_upnp != xno; then
  1085. AC_MSG_RESULT(yes)
  1086. AC_MSG_CHECKING([whether to build with UPnP enabled by default])
  1087. use_upnp=yes
  1088. upnp_setting=0
  1089. if test x$use_upnp_default != xno; then
  1090. use_upnp_default=yes
  1091. upnp_setting=1
  1092. fi
  1093. AC_MSG_RESULT($use_upnp_default)
  1094. AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state])
  1095. if test x$TARGET_OS = xwindows; then
  1096. MINIUPNPC_CPPFLAGS="-DSTATICLIB -DMINIUPNP_STATICLIB"
  1097. fi
  1098. else
  1099. AC_MSG_RESULT(no)
  1100. fi
  1101. fi
  1102. dnl these are only used when qt is enabled
  1103. BUILD_TEST_QT=""
  1104. if test x$bitcoin_enable_qt != xno; then
  1105. dnl enable dbus support
  1106. AC_MSG_CHECKING([whether to build GUI with support for D-Bus])
  1107. if test x$bitcoin_enable_qt_dbus != xno; then
  1108. AC_DEFINE([USE_DBUS],[1],[Define if dbus support should be compiled in])
  1109. fi
  1110. AC_MSG_RESULT($bitcoin_enable_qt_dbus)
  1111. dnl enable qr support
  1112. AC_MSG_CHECKING([whether to build GUI with support for QR codes])
  1113. if test x$have_qrencode = xno; then
  1114. if test x$use_qr = xyes; then
  1115. AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode")
  1116. fi
  1117. AC_MSG_RESULT(no)
  1118. else
  1119. if test x$use_qr != xno; then
  1120. AC_MSG_RESULT(yes)
  1121. AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in])
  1122. use_qr=yes
  1123. else
  1124. AC_MSG_RESULT(no)
  1125. fi
  1126. fi
  1127. if test x$XGETTEXT = x; then
  1128. AC_MSG_WARN("xgettext is required to update qt translations")
  1129. fi
  1130. AC_MSG_CHECKING([whether to build test_litecoin-qt])
  1131. if test x$use_gui_tests$bitcoin_enable_qt_test = xyesyes; then
  1132. AC_MSG_RESULT([yes])
  1133. BUILD_TEST_QT="yes"
  1134. else
  1135. AC_MSG_RESULT([no])
  1136. fi
  1137. fi
  1138. AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
  1139. AC_MSG_CHECKING([whether to build test_litecoin])
  1140. if test x$use_tests = xyes; then
  1141. AC_MSG_RESULT([yes])
  1142. BUILD_TEST="yes"
  1143. else
  1144. AC_MSG_RESULT([no])
  1145. BUILD_TEST=""
  1146. fi
  1147. AC_MSG_CHECKING([whether to enable sse2 instructions])
  1148. if test x$use_sse2 != xno; then
  1149. AC_MSG_RESULT(yes)
  1150. AC_DEFINE([USE_SSE2],[1],[Define if SSE2 support should be compiled in])
  1151. use_sse2=yes
  1152. CPPFLAGS="$CPPFLAGS -DUSE_SSE2=1"
  1153. else
  1154. AC_MSG_RESULT(no)
  1155. fi
  1156. AC_MSG_CHECKING([whether to reduce exports])
  1157. if test x$use_reduce_exports = xyes; then
  1158. AC_MSG_RESULT([yes])
  1159. else
  1160. AC_MSG_RESULT([no])
  1161. fi
  1162. if test x$build_bitcoin_utils$build_bitcoin_libs$build_bitcoind$bitcoin_enable_qt$use_bench$use_tests = xnononononono; then
  1163. AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-bench or --enable-tests])
  1164. fi
  1165. AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
  1166. AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
  1167. AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
  1168. AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
  1169. AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
  1170. AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
  1171. AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
  1172. AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
  1173. AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
  1174. AM_CONDITIONAL([USE_SSE2], [test x$use_sse2 = xyes])
  1175. AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
  1176. AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
  1177. AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
  1178. AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes])
  1179. AM_CONDITIONAL([ENABLE_SSE41],[test x$enable_sse41 = xyes])
  1180. AM_CONDITIONAL([ENABLE_AVX2],[test x$enable_avx2 = xyes])
  1181. AM_CONDITIONAL([ENABLE_SHANI],[test x$enable_shani = xyes])
  1182. AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes])
  1183. AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
  1184. AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
  1185. AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision])
  1186. AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build])
  1187. AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release])
  1188. AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Copyright year])
  1189. AC_DEFINE(COPYRIGHT_HOLDERS, "_COPYRIGHT_HOLDERS", [Copyright holder(s) before %s replacement])
  1190. AC_DEFINE(COPYRIGHT_HOLDERS_SUBSTITUTION, "_COPYRIGHT_HOLDERS_SUBSTITUTION", [Replacement for %s in copyright holders string])
  1191. define(_COPYRIGHT_HOLDERS_FINAL, [patsubst(_COPYRIGHT_HOLDERS, [%s], [_COPYRIGHT_HOLDERS_SUBSTITUTION])])
  1192. AC_DEFINE(COPYRIGHT_HOLDERS_FINAL, "_COPYRIGHT_HOLDERS_FINAL", [Copyright holder(s)])
  1193. AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR)
  1194. AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR)
  1195. AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION)
  1196. AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD)
  1197. AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
  1198. AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
  1199. AC_SUBST(COPYRIGHT_HOLDERS, "_COPYRIGHT_HOLDERS")
  1200. AC_SUBST(COPYRIGHT_HOLDERS_SUBSTITUTION, "_COPYRIGHT_HOLDERS_SUBSTITUTION")
  1201. AC_SUBST(COPYRIGHT_HOLDERS_FINAL, "_COPYRIGHT_HOLDERS_FINAL")
  1202. AC_SUBST(BITCOIN_DAEMON_NAME)
  1203. AC_SUBST(BITCOIN_GUI_NAME)
  1204. AC_SUBST(BITCOIN_CLI_NAME)
  1205. AC_SUBST(BITCOIN_TX_NAME)
  1206. AC_SUBST(RELDFLAGS)
  1207. AC_SUBST(DEBUG_CPPFLAGS)
  1208. AC_SUBST(WARN_CXXFLAGS)
  1209. AC_SUBST(NOWARN_CXXFLAGS)
  1210. AC_SUBST(DEBUG_CXXFLAGS)
  1211. AC_SUBST(COMPAT_LDFLAGS)
  1212. AC_SUBST(ERROR_CXXFLAGS)
  1213. AC_SUBST(GPROF_CXXFLAGS)
  1214. AC_SUBST(GPROF_LDFLAGS)
  1215. AC_SUBST(HARDENED_CXXFLAGS)
  1216. AC_SUBST(HARDENED_CPPFLAGS)
  1217. AC_SUBST(HARDENED_LDFLAGS)
  1218. AC_SUBST(PIC_FLAGS)
  1219. AC_SUBST(PIE_FLAGS)
  1220. AC_SUBST(SANITIZER_CXXFLAGS)
  1221. AC_SUBST(SANITIZER_LDFLAGS)
  1222. AC_SUBST(SSE42_CXXFLAGS)
  1223. AC_SUBST(SSE41_CXXFLAGS)
  1224. AC_SUBST(AVX2_CXXFLAGS)
  1225. AC_SUBST(SHANI_CXXFLAGS)
  1226. AC_SUBST(LIBTOOL_APP_LDFLAGS)
  1227. AC_SUBST(USE_UPNP)
  1228. AC_SUBST(USE_QRCODE)
  1229. AC_SUBST(USE_SSE2)
  1230. AC_SUBST(BOOST_LIBS)
  1231. AC_SUBST(TESTDEFS)
  1232. AC_SUBST(LEVELDB_TARGET_FLAGS)
  1233. AC_SUBST(MINIUPNPC_CPPFLAGS)
  1234. AC_SUBST(MINIUPNPC_LIBS)
  1235. AC_SUBST(CRYPTO_LIBS)
  1236. AC_SUBST(SSL_LIBS)
  1237. AC_SUBST(EVENT_LIBS)
  1238. AC_SUBST(EVENT_PTHREADS_LIBS)
  1239. AC_SUBST(ZMQ_LIBS)
  1240. AC_SUBST(PROTOBUF_LIBS)
  1241. AC_SUBST(QR_LIBS)
  1242. AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
  1243. AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
  1244. AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
  1245. AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])
  1246. AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py])
  1247. AC_CONFIG_LINKS([test/util/bitcoin-util-test.py:test/util/bitcoin-util-test.py])
  1248. AC_CONFIG_LINKS([test/util/rpcauth-test.py:test/util/rpcauth-test.py])
  1249. dnl boost's m4 checks do something really nasty: they export these vars. As a
  1250. dnl result, they leak into secp256k1's configure and crazy things happen.
  1251. dnl Until this is fixed upstream and we've synced, we'll just un-export them.
  1252. CPPFLAGS_TEMP="$CPPFLAGS"
  1253. unset CPPFLAGS
  1254. CPPFLAGS="$CPPFLAGS_TEMP"
  1255. LDFLAGS_TEMP="$LDFLAGS"
  1256. unset LDFLAGS
  1257. LDFLAGS="$LDFLAGS_TEMP"
  1258. LIBS_TEMP="$LIBS"
  1259. unset LIBS
  1260. LIBS="$LIBS_TEMP"
  1261. PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"
  1262. unset PKG_CONFIG_PATH
  1263. PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
  1264. PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR"
  1265. unset PKG_CONFIG_LIBDIR
  1266. PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP"
  1267. if test x$need_bundled_univalue = xyes; then
  1268. AC_CONFIG_SUBDIRS([src/univalue])
  1269. fi
  1270. ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery --disable-jni"
  1271. AC_CONFIG_SUBDIRS([src/secp256k1])
  1272. AC_OUTPUT
  1273. dnl Taken from https://wiki.debian.org/RpathIssue
  1274. case $host in
  1275. *-*-linux-gnu)
  1276. AC_MSG_RESULT([Fixing libtool for -rpath problems.])
  1277. sed < libtool > libtool-2 \
  1278. 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/'
  1279. mv libtool-2 libtool
  1280. chmod 755 libtool
  1281. ;;
  1282. esac
  1283. dnl Replace the BUILDDIR path with the correct Windows path if compiling on Native Windows
  1284. case ${OS} in
  1285. *Windows*)
  1286. sed 's/BUILDDIR="\/\([[a-z]]\)/BUILDDIR="\1:/' test/config.ini > test/config-2.ini
  1287. mv test/config-2.ini test/config.ini
  1288. ;;
  1289. esac
  1290. echo
  1291. echo "Options used to compile and link:"
  1292. echo " with wallet = $enable_wallet"
  1293. echo " with gui / qt = $bitcoin_enable_qt"
  1294. if test x$bitcoin_enable_qt != xno; then
  1295. echo " with qr = $use_qr"
  1296. fi
  1297. echo " with zmq = $use_zmq"
  1298. echo " with test = $use_tests"
  1299. echo " with bench = $use_bench"
  1300. echo " with upnp = $use_upnp"
  1301. echo " use asm = $use_asm"
  1302. echo " sanitizers = $use_sanitizers"
  1303. echo " scrypt sse2 = $use_sse2"
  1304. echo " debug enabled = $enable_debug"
  1305. echo " gprof enabled = $enable_gprof"
  1306. echo " werror = $enable_werror"
  1307. echo
  1308. echo " target os = $TARGET_OS"
  1309. echo " build os = $BUILD_OS"
  1310. echo
  1311. echo " CC = $CC"
  1312. echo " CFLAGS = $CFLAGS"
  1313. echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS"
  1314. echo " CXX = $CXX"
  1315. echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
  1316. echo " LDFLAGS = $PTHREAD_CFLAGS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
  1317. echo " ARFLAGS = $ARFLAGS"
  1318. echo