configure.ac 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. dnl * Copyright 2012-2013 Luke Dashjr
  2. dnl * Copyright 2011-2013 Con Kolivas
  3. dnl * Copyright 2010-2011 Jeff Garzik
  4. dnl * Copyright 2012 Xiangfu
  5. dnl * Copyright 2011 Rusty Russell
  6. dnl * Copyright 2011 Mark Crichton
  7. dnl *
  8. dnl * This program is free software; you can redistribute it and/or modify it
  9. dnl * under the terms of the GNU General Public License as published by the Free
  10. dnl * Software Foundation; either version 3 of the License, or (at your option)
  11. dnl * any later version. See COPYING for more details.
  12. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  13. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  14. m4_define([v_maj], [3])
  15. m4_define([v_min], [3])
  16. m4_define([v_mic], [0])
  17. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  18. m4_define([v_ver], [v_maj.v_min.v_mic])
  19. m4_define([lt_rev], m4_eval(v_maj + v_min))
  20. m4_define([lt_cur], v_mic)
  21. m4_define([lt_age], v_min)
  22. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  23. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  24. AC_INIT([bfgminer], [v_ver], [luke-jr+bfgminer@utopios.org])
  25. AC_PREREQ([2.59c])
  26. AC_CANONICAL_SYSTEM
  27. AC_CONFIG_MACRO_DIR([m4])
  28. AC_CONFIG_SRCDIR([miner.c])
  29. AC_CONFIG_HEADERS([config.h])
  30. AM_INIT_AUTOMAKE([foreign])
  31. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  32. AC_USE_SYSTEM_EXTENSIONS
  33. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  34. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  35. m4_ifdef([v_rev], , [m4_define([v_rev], [0])])
  36. m4_ifdef([v_rel], , [m4_define([v_rel], [])])
  37. AC_DEFINE_UNQUOTED(CGMINER_MAJOR_VERSION, [v_maj], [Major version])
  38. AC_DEFINE_UNQUOTED(CGMINER_MINOR_VERSION, [v_min], [Minor version])
  39. AC_DEFINE_UNQUOTED(CGMINER_MINOR_SUBVERSION, [v_mic], [Micro version])
  40. version_info="lt_rev:lt_cur:lt_age"
  41. release_info="v_rel"
  42. AC_SUBST(version_info)
  43. AC_SUBST(release_info)
  44. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  45. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  46. VMAJ=v_maj
  47. AC_SUBST(VMAJ)
  48. AC_CANONICAL_BUILD
  49. AC_CANONICAL_HOST
  50. dnl Make sure anyone changing configure.ac/Makefile.am has a clue
  51. AM_MAINTAINER_MODE([enable])
  52. dnl Checks for programs
  53. AC_PROG_CC_C99
  54. gl_EARLY
  55. AC_PROG_GCC_TRADITIONAL
  56. AM_PROG_CC_C_O
  57. AC_PROG_RANLIB
  58. AC_PROG_CPP
  59. gl_INIT
  60. dnl Checks for header files.
  61. AC_HEADER_STDC
  62. AC_CHECK_HEADERS(syslog.h)
  63. AC_CHECK_HEADERS([sys/epoll.h])
  64. AC_CHECK_HEADERS([sys/prctl.h])
  65. AC_CHECK_HEADERS([sys/file.h])
  66. AC_CHECK_HEADERS([linux/spi/spidev.h])
  67. AC_CHECK_HEADERS([sys/file.h])
  68. # Setuid
  69. AC_CHECK_HEADERS([pwd.h])
  70. # Check for chroot support
  71. AC_CHECK_FUNCS([chroot])
  72. AC_FUNC_ALLOCA
  73. driverlist=
  74. algolist=SHA256d
  75. optlist=
  76. need_dynclock=no
  77. need_fpgautils=no
  78. need_lowlevel=no
  79. have_cygwin=false
  80. have_win32=false
  81. have_macho=false
  82. DLOPEN_FLAGS="-ldl"
  83. WS2_LIBS=""
  84. MM_LIBS=""
  85. MATH_LIBS="-lm"
  86. RT_LIBS=""
  87. case $target in
  88. amd64-* | x86_64-*)
  89. have_x86_32=false
  90. have_x86_64=true
  91. bitness="64"
  92. ;;
  93. i386-* | i486-* | i586-* | i686-* | x86-*)
  94. have_x86_32=true
  95. have_x86_64=false
  96. bitness="32"
  97. ;;
  98. *)
  99. have_x86_32=false
  100. have_x86_64=false
  101. ;;
  102. esac
  103. case $target in
  104. *-*-mingw*)
  105. have_win32=true
  106. DLOPEN_FLAGS=""
  107. WS2_LIBS="-lws2_32"
  108. MM_LIBS="-lwinmm"
  109. AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
  110. AC_DEFINE([FD_SETSIZE], [4096], [Maximum sockets before fd_set overflows])
  111. ;;
  112. *-*-cygwin*)
  113. have_cygwin=true
  114. ;;
  115. powerpc-*-darwin*)
  116. CFLAGS="$CFLAGS -faltivec"
  117. have_macho=true
  118. ;;
  119. *-*-darwin*)
  120. have_macho=true
  121. ;;
  122. esac
  123. m4_define([BFG_INCLUDE],
  124. if test "x$2" = "x"; then
  125. $1=''
  126. else
  127. $1="[#]include <$2>"
  128. fi
  129. )
  130. m4_define([BFG_PREPROC_IFELSE],
  131. BFG_INCLUDE([headerinclude], $2)
  132. AC_COMPILE_IFELSE([
  133. AC_LANG_PROGRAM([
  134. ${headerinclude}
  135. ], [
  136. #if !( $1 )
  137. #error "$1 false in preprocessor"
  138. #endif
  139. ])
  140. ],[$3],[$4])
  141. )
  142. AC_CHECK_DECL([HASH_ITER],[
  143. AC_CHECK_DECL([DL_FOREACH_SAFE],[
  144. true
  145. ],[
  146. AC_MSG_ERROR([Could not find DL_FOREACH_SAFE - install uthash-dev 1.9.2+])
  147. ],[
  148. #include <utlist.h>
  149. ])
  150. ],[
  151. AC_MSG_ERROR([Could not find HASH_ITER - please install uthash-dev 1.9.2+])
  152. ],[
  153. #include <uthash.h>
  154. ])
  155. driverlist="$driverlist cpu/cpumining"
  156. cpumining="no"
  157. AC_ARG_ENABLE([cpumining],
  158. [AC_HELP_STRING([--enable-cpumining],[Build with CPU mining support (default disabled)])],
  159. [cpumining=$enableval]
  160. )
  161. if test "x$cpumining" = xyes; then
  162. AC_DEFINE_UNQUOTED([WANT_CPUMINE], [1], [Enable CPUMINING])
  163. driverlist="$driverlist cpu:asm/has_yasm"
  164. driverlist="$driverlist cpu:sse2/have_sse2"
  165. fi
  166. AM_CONDITIONAL([HAS_CPUMINE], [test x$cpumining = xyes])
  167. driverlist="$driverlist opencl"
  168. opencl="yes"
  169. AC_ARG_ENABLE([opencl],
  170. [AC_HELP_STRING([--disable-opencl],[Build without support for OpenCL (default enabled)])],
  171. [opencl=$enableval]
  172. )
  173. if test "x$opencl" = xyes; then
  174. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL support is wanted])
  175. else
  176. DLOPEN_FLAGS=""
  177. fi
  178. AM_CONDITIONAL([HAVE_OPENCL], [test x$opencl = xyes])
  179. m4_define([BFG_PTHREAD_FLAG_CHECK],
  180. AC_MSG_CHECKING([for $1])
  181. for cflag in ' -pthread' ''; do
  182. for lib in ' -lpthread' ' -lwinpthread' ''; do
  183. CFLAGS="${save_CFLAGS}${cflag}"
  184. LIBS="${save_LIBS}${lib}"
  185. AC_LINK_IFELSE([
  186. AC_LANG_PROGRAM([
  187. #include <pthread.h>
  188. ], [
  189. void *f = $1;
  190. ])
  191. ], [
  192. found_pthread=true
  193. PTHREAD_FLAGS="${cflag}"
  194. PTHREAD_LIBS="${lib}"
  195. if test "x${cflag}${lib}" = "x"; then
  196. AC_MSG_RESULT([yes])
  197. else
  198. AC_MSG_RESULT([with${cflag}${lib}])
  199. fi
  200. $2
  201. break 2
  202. ])
  203. done
  204. done
  205. if test "x${found_pthread}" = "xfalse"; then
  206. AC_MSG_RESULT([no])
  207. fi
  208. )
  209. save_CFLAGS="${CFLAGS}"
  210. save_LIBS="${LIBS}"
  211. found_pthread=false
  212. BFG_PTHREAD_FLAG_CHECK([pthread_cancel],[
  213. AC_DEFINE([HAVE_PTHREAD_CANCEL], [1], [Define if you have a native pthread_cancel])
  214. ])
  215. if test "x${found_pthread}" = "xfalse"; then
  216. BFG_PTHREAD_FLAG_CHECK([pthread_create])
  217. if test "x${found_pthread}" = "xfalse"; then
  218. AC_MSG_ERROR([Could not find pthread library - please install libpthread])
  219. fi
  220. fi
  221. # check for nanosleep here, since it is provided by winpthread
  222. AC_CHECK_FUNCS([nanosleep])
  223. CFLAGS="${save_CFLAGS}"
  224. LIBS="${save_LIBS}"
  225. PKG_CHECK_MODULES([JANSSON],[jansson],[
  226. true
  227. ],[
  228. AC_MSG_CHECKING([for jansson in system-default locations])
  229. LIBS="$LIBS -ljansson"
  230. AC_TRY_LINK([
  231. #include <jansson.h>
  232. ],[
  233. json_object();
  234. ],[
  235. AC_MSG_RESULT([found])
  236. JANSSON_LIBS=-ljansson
  237. ],[
  238. AC_MSG_RESULT([not found])
  239. AC_MSG_ERROR([Could not find jansson library])
  240. ])
  241. LIBS="${save_LIBS}"
  242. ])
  243. AC_SUBST(JANSSON_CFLAGS)
  244. AC_SUBST(JANSSON_LIBS)
  245. if test "x$opencl" = xyes; then
  246. adl="yes"
  247. driverlist="$driverlist opencl:sensors/with_sensors"
  248. AC_ARG_WITH([sensors],
  249. [AC_HELP_STRING([--without-sensors],[Build with libsensors monitoring (default enabled)])],
  250. [true],[with_sensors=auto])
  251. if test "x$opencl" != xyes; then
  252. with_sensors=no
  253. fi
  254. if test "x$with_sensors" != xno; then
  255. AC_MSG_CHECKING([for libsensors])
  256. save_LIBS="${LIBS}"
  257. LIBS="$LIBS -lsensors"
  258. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  259. #include <stddef.h>
  260. #include <sensors/sensors.h>
  261. ],[
  262. const sensors_chip_name *cn;
  263. cn = sensors_get_detected_chips(NULL, NULL);
  264. ])],[
  265. with_sensors=yes
  266. sensors_LIBS="-lsensors"
  267. AC_DEFINE([HAVE_SENSORS], [1], [Defined if libsensors was found])
  268. AC_MSG_RESULT([yes])
  269. ],[
  270. with_sensors=no
  271. AC_MSG_RESULT([no])
  272. if ! $have_win32; then
  273. with_sensors_enableaction="install libsensors"
  274. fi
  275. ])
  276. LIBS="$save_LIBS"
  277. fi
  278. AC_SUBST(sensors_LIBS)
  279. driverlist="$driverlist opencl:adl/adl"
  280. AC_ARG_ENABLE([adl],
  281. [AC_HELP_STRING([--disable-adl],[Build without ADL monitoring (default enabled)])],
  282. [adl=$enableval]
  283. )
  284. if test x$adl = xyes
  285. then
  286. AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
  287. fi
  288. else
  289. adl="no"
  290. fi
  291. driverlist="$driverlist bitforce"
  292. AC_ARG_ENABLE([bitforce],
  293. [AC_HELP_STRING([--disable-bitforce],[Compile support for BitForce (default enabled)])],
  294. [bitforce=$enableval],
  295. [bitforce=yes]
  296. )
  297. if test "x$bitforce" = xyes; then
  298. AC_DEFINE([USE_BITFORCE], [1], [Defined to 1 if BitForce support is wanted])
  299. need_fpgautils=yes
  300. fi
  301. AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
  302. driverlist="$driverlist icarus cairnsmore/icarus erupter/icarus"
  303. AC_ARG_ENABLE([icarus],
  304. [AC_HELP_STRING([--disable-icarus],[Compile support for Icarus (default enabled)])],
  305. [icarus=$enableval],
  306. [icarus=yes]
  307. )
  308. if test "x$icarus" = xyes; then
  309. AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
  310. need_dynclock=yes
  311. need_fpgautils=yes
  312. fi
  313. AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
  314. driverlist="$driverlist avalon"
  315. avalon="no"
  316. AC_ARG_ENABLE([avalon],
  317. [AC_HELP_STRING([--disable-avalon],[Compile support for Avalon (default enabled)])],
  318. [avalon=$enableval],
  319. [avalon=yes]
  320. )
  321. if test "x$avalon" = xyes; then
  322. AC_DEFINE([USE_AVALON], [1], [Defined to 1 if Avalon support is wanted])
  323. need_fpgautils=yes
  324. fi
  325. AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes])
  326. httpsrv=auto
  327. AC_ARG_WITH([libmicrohttpd],
  328. [AC_HELP_STRING([--without-libmicrohttpd],[Compile support for libmicrohttpd getwork server (default enabled)])],
  329. [httpsrv=$withval]
  330. )
  331. if test "x$httpsrv" != "xno"; then
  332. PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.5],[
  333. AC_DEFINE([USE_LIBMICROHTTPD],[1],[Defined to 1 if libmicrohttpd support is wanted])
  334. httpsrv=yes
  335. ],[
  336. httpsrv=no
  337. httpsrv_enableaction="install libmicrohttpd 0.9.5+"
  338. need_bfg_driver_proxy_enableaction="install libmicrohttpd 0.9.5+"
  339. if test "x$httpsrv" = "xyes"; then
  340. AC_MSG_ERROR([Unable to find libmicrohttpd 0.9.5+])
  341. else
  342. AC_MSG_WARN([libmicrohttpd 0.9.5+ not found; getwork proxy will be unavailable])
  343. fi
  344. ])
  345. fi
  346. AM_CONDITIONAL([USE_LIBMICROHTTPD], [test x$httpsrv = xyes])
  347. libevent=auto
  348. AC_ARG_WITH([libevent],
  349. [AC_HELP_STRING([--without-libevent],[Compile support for libevent stratum server (default enabled)])],
  350. [libevent=$withval]
  351. )
  352. if test "x$libevent" != "xno"; then
  353. PKG_CHECK_MODULES([libevent],[libevent >= 2.0.3],[
  354. AC_DEFINE([USE_LIBEVENT],[1],[Defined to 1 if libevent support is wanted])
  355. libevent=yes
  356. ],[
  357. libevent=no
  358. libevent_enableaction="install libevent 2.0.3+"
  359. if test -n "$need_bfg_driver_proxy_enableaction"; then
  360. need_bfg_driver_proxy_enableaction="${need_bfg_driver_proxy_enableaction} (getwork) or libevent 2.0.3+ (stratum)"
  361. else
  362. need_bfg_driver_proxy_enableaction="install libevent 2.0.3+"
  363. fi
  364. if test "x$libevent" = "xyes"; then
  365. AC_MSG_ERROR([Unable to find libevent 2.0.3+])
  366. else
  367. AC_MSG_WARN([libevent 2.0.3+ not found; stratum proxy will be unavailable])
  368. fi
  369. ])
  370. fi
  371. AM_CONDITIONAL([USE_LIBEVENT], [test x$libevent = xyes])
  372. driverlist="$driverlist proxy/need_bfg_driver_proxy"
  373. if test x$libevent$httpsrv = xnono; then
  374. need_bfg_driver_proxy=no
  375. else
  376. need_bfg_driver_proxy=yes
  377. driverlist="$driverlist proxy:getwork/httpsrv proxy:stratum/libevent"
  378. fi
  379. AM_CONDITIONAL([NEED_BFG_DRIVER_PROXY], [test x$libevent$httpsrv != xnono])
  380. driverlist="$driverlist modminer"
  381. AC_ARG_ENABLE([modminer],
  382. [AC_HELP_STRING([--disable-modminer],[Compile support for ModMiner (default enabled)])],
  383. [modminer=$enableval],
  384. [modminer=yes]
  385. )
  386. if test "x$modminer" = xyes; then
  387. AC_DEFINE([USE_MODMINER], [1], [Defined to 1 if ModMiner support is wanted])
  388. need_dynclock=yes
  389. need_fpgautils=yes
  390. fi
  391. AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes])
  392. PKG_PROG_PKG_CONFIG()
  393. libusb=no
  394. libusb_include_path=""
  395. PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[
  396. libusb=yes
  397. ],[
  398. for usb_lib in usb-1.0 usb; do
  399. AC_CHECK_LIB($usb_lib, libusb_init, [
  400. libusb=yes
  401. break
  402. ])
  403. done
  404. if test "x$libusb" = xyes; then
  405. AC_CHECK_DECL([libusb_init],[
  406. true
  407. ],[
  408. AC_MSG_CHECKING([whether libusb_init is declared in subdirectory])
  409. libusb_include_path=`echo '#include <libusb-1.0/libusb.h>' | ${CPP} -M - 2>/dev/null | tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)libusb\.h[[:space:]].*$/\1/' -e t -e d`
  410. if test "x$libusb_include_path" != "x"; then
  411. LIBUSB_LIBS="-l$usb_lib"
  412. LIBUSB_CFLAGS="-I$libusb_include_path"
  413. AC_MSG_RESULT([yes])
  414. else
  415. libusb=no
  416. AC_MSG_RESULT([no])
  417. fi
  418. ],[#include <libusb.h>])
  419. fi
  420. ])
  421. driverlist="$driverlist x6500"
  422. AC_ARG_ENABLE([x6500],
  423. [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])],
  424. [x6500=$enableval],
  425. [x6500=auto]
  426. )
  427. if test "x$x6500$libusb" = xyesno; then
  428. AC_MSG_ERROR([Could not find libusb, required for X6500 support])
  429. elif test "x$x6500" = xauto; then
  430. x6500="$libusb"
  431. if test "x$libusb" = xno; then
  432. AC_MSG_WARN([Could not find libusb, required for X6500 support])
  433. x6500_enableaction="install libusb 1.0+"
  434. fi
  435. fi
  436. if test "x$x6500" = xyes; then
  437. AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted])
  438. need_dynclock=yes
  439. need_fpgautils=yes
  440. need_lowlevel=yes
  441. fi
  442. AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes])
  443. driverlist="$driverlist ztex"
  444. AC_ARG_ENABLE([ztex],
  445. [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])],
  446. [ztex=$enableval],
  447. [ztex=auto]
  448. )
  449. if test "x$ztex$libusb" = xyesno; then
  450. AC_MSG_ERROR([Could not find libusb, required for ZTEX support])
  451. elif test "x$ztex" = xauto; then
  452. ztex="$libusb"
  453. if test "x$libusb" = xno; then
  454. AC_MSG_WARN([Could not find libusb, required for ZTEX support])
  455. ztex_enableaction="install libusb 1.0+"
  456. fi
  457. fi
  458. if test "x$ztex" = xyes; then
  459. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted])
  460. need_dynclock=yes
  461. need_fpgautils=yes
  462. fi
  463. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  464. driverlist="$driverlist bitfury_gpio/bitfury"
  465. bitfury=yes
  466. AC_ARG_ENABLE([bitfury],
  467. [AC_HELP_STRING([--disable-bitfury],[Compile support for Bitfury (default enabled)])],
  468. [bitfury=$enableval]
  469. )
  470. if test "x$bitfury" = xyes; then
  471. AC_DEFINE([USE_BITFURY], [1], [Defined to 1 if Bitfury support is wanted])
  472. fi
  473. AM_CONDITIONAL([HAS_BITFURY], [test x$bitfury = xyes])
  474. driverlist="$driverlist bfsb"
  475. bfsb=no
  476. AC_ARG_ENABLE([bfsb],
  477. [AC_HELP_STRING([--enable-bfsb],[Compile support for BFSB (default disabled)])],
  478. [bfsb=$enableval]
  479. )
  480. if test "x$bfsb" = "xyes"; then
  481. if test "x$bitfury" = "xno"; then
  482. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BFSB])
  483. fi
  484. AC_DEFINE([USE_BFSB], [1], [Defined to 1 if BFSB support is wanted])
  485. fi
  486. AM_CONDITIONAL([HAS_BFSB], [test x$bfsb = xyes])
  487. driverlist="$driverlist bigpic"
  488. bigpic=auto
  489. AC_ARG_ENABLE([bigpic],
  490. [AC_HELP_STRING([--disable-bigpic],[Compile support for Big Picture Mining USB (default enabled)])],
  491. [bigpic=$enableval]
  492. )
  493. if test "x$bigpic" = "xno"; then
  494. true
  495. elif test "x$bitfury" = "xyes"; then
  496. bigpic=yes
  497. elif test "x$bigpic" = "xyes"; then
  498. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BigPic])
  499. else
  500. bigpic=no
  501. fi
  502. if test "x$bigpic" = "xyes"; then
  503. AC_DEFINE([USE_BIGPIC], [1], [Defined to 1 if Big Picture Mining USB support is wanted])
  504. need_fpgautils=yes
  505. fi
  506. AM_CONDITIONAL([HAS_BIGPIC], [test x$bigpic = xyes])
  507. driverlist="$driverlist littlefury"
  508. littlefury=auto
  509. AC_ARG_ENABLE([littlefury],
  510. [AC_HELP_STRING([--disable-littlefury],[Compile support for LittleFury (default enabled)])],
  511. [littlefury=$enableval]
  512. )
  513. if test "x$littlefury" = "xno"; then
  514. true
  515. elif test "x$bitfury" = "xyes"; then
  516. littlefury=yes
  517. elif test "x$littlefury" = "xyes"; then
  518. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled LittleFury])
  519. else
  520. littlefury=no
  521. fi
  522. if test "x$littlefury" = "xyes"; then
  523. AC_DEFINE([USE_LITTLEFURY], [1], [Defined to 1 if LittleFury support is wanted])
  524. need_fpgautils=yes
  525. fi
  526. AM_CONDITIONAL([HAS_LITTLEFURY], [test x$littlefury = xyes])
  527. driverlist="$driverlist nanofury"
  528. nanofury=auto
  529. AC_ARG_ENABLE([nanofury],
  530. [AC_HELP_STRING([--disable-nanofury],[Compile support for NanoFury (default enabled)])],
  531. [nanofury=$enableval]
  532. )
  533. if test "x$nanofury" = "xno"; then
  534. true
  535. elif test "x$bitfury" = "xyes"; then
  536. _found_hidapi=false
  537. for _hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
  538. PKG_CHECK_MODULES([hidapi],[$_hidapi_lib],[
  539. found_hidapi=true
  540. break
  541. ],[
  542. true
  543. ])
  544. done
  545. if test x$found_hidapi = xtrue; then
  546. nanofury=yes
  547. else
  548. if test x$nanofury = xauto; then
  549. nanofury=no
  550. nanofury_enableaction="install hidapi"
  551. else
  552. AC_MSG_ERROR([Could not find hidapi, required for NanoFury support])
  553. fi
  554. fi
  555. elif test "x$nanofury" = "xyes"; then
  556. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled NanoFury])
  557. need_fpgautils=yes
  558. else
  559. nanofury=no
  560. fi
  561. if test "x$nanofury" = "xyes"; then
  562. AC_DEFINE([USE_NANOFURY], [1], [Defined to 1 if NanoFury support is wanted])
  563. need_fpgautils=yes
  564. need_lowlevel=yes
  565. fi
  566. AM_CONDITIONAL([HAS_NANOFURY], [test x$nanofury = xyes])
  567. driverlist="$driverlist metabank"
  568. metabank=no
  569. AC_ARG_ENABLE([metabank],
  570. [AC_HELP_STRING([--enable-metabank],[Compile support for Metabank (default disabled)])],
  571. [metabank=$enableval]
  572. )
  573. if test "x$metabank" = "xyes"; then
  574. if test "x$bitfury" = "xno"; then
  575. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Metabank])
  576. fi
  577. AC_DEFINE([USE_METABANK], [1], [Defined to 1 if Metabank support is wanted])
  578. fi
  579. AM_CONDITIONAL([HAS_METABANK], [test x$metabank = xyes])
  580. if test "x$x6500$ztex" = "xnono"; then
  581. libusb=no
  582. LIBUSB_LIBS=''
  583. LIBUSB_CFLAGS=''
  584. fi
  585. if test "x$libusb" = xyes; then
  586. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  587. save_CFLAGS="$CFLAGS"
  588. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  589. AC_CHECK_DECLS([libusb_error_name],[true],[true],[#include <libusb.h>])
  590. CFLAGS="$save_CFLAGS"
  591. fi
  592. algolist="$algolist scrypt"
  593. scrypt="no"
  594. AC_ARG_ENABLE([scrypt],
  595. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  596. [scrypt=$enableval]
  597. )
  598. if test "x$scrypt" = xyes; then
  599. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  600. fi
  601. if test x$need_fpgautils = xyes; then
  602. AC_DEFINE([HAVE_FPGAUTILS], [1], [Defined to 1 if fpgautils is being used])
  603. if $have_win32; then
  604. echo '#include <iospeeds.h>' >iospeeds_local.h
  605. else
  606. AC_MSG_CHECKING([what baud rates your system supports])
  607. echo '#include <termios.h>' | ${CPP} -dM - 2>/dev/null | sed 's/.*[ ]B\([0-9][0-9]*\)[ ].*/IOSPEED(\1)/' | grep IOSPEED >iospeeds_local.h
  608. if grep -q IOSPEED iospeeds_local.h; then
  609. AC_MSG_RESULT([done])
  610. else
  611. AC_MSG_RESULT([failed, using standard POSIX])
  612. echo '#include <iospeeds_posix.h>' >iospeeds_local.h
  613. fi
  614. fi
  615. fi
  616. if test x$need_lowlevel = xyes; then
  617. AC_DEFINE([HAVE_BFG_LOWLEVEL], [1], [Defined to 1 if lowlevel drivers are being used])
  618. fi
  619. curses="auto"
  620. AC_ARG_WITH([curses],
  621. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  622. [curses=$withval]
  623. )
  624. if test "x$curses" = "xno"; then
  625. optlist="$optlist curses"
  626. else
  627. curses_enableaction="install a curses library"
  628. orig_libs="$LIBS"
  629. if test "x${curses}" = "xyes"; then
  630. preferl=''
  631. else
  632. preferl="${curses} ${curses}6 ${curses}5"
  633. fi
  634. for wideornot in w u ''; do
  635. for ncursesver in '' 6 5; do
  636. preferl="${preferl} ncurses${wideornot}${ncursesver}"
  637. done
  638. preferl="${preferl} pdcurses${wideornot}"
  639. done
  640. if test "x$cross_compiling" != "xyes"; then
  641. AC_MSG_CHECKING([for best native curses library])
  642. orig_cflags="$CFLAGS"
  643. for curses_lib in ${preferl}; do
  644. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  645. continue
  646. fi
  647. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  648. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  649. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  650. #include <curses.h>
  651. ]], [[
  652. WINDOW *w = NULL;
  653. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  654. ]])], [
  655. curses=yes
  656. optlist="$optlist ${curses_lib}/curses"
  657. AC_MSG_RESULT([$curses_lib])
  658. NCURSES_LIBS=`${curses_lib}-config --libs`
  659. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  660. break
  661. ], [
  662. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  663. ])
  664. done
  665. CFLAGS="$orig_cflags"
  666. if test "x$curses" != "xyes"; then
  667. AC_MSG_RESULT([none?])
  668. fi
  669. fi
  670. if test "x$curses" != "xyes"; then
  671. sym=addstr
  672. AC_SEARCH_LIBS(${sym}, ${preferl}, [
  673. curses=yes
  674. eval "curseslib=\"\${ac_cv_search_${sym}}\""
  675. barelib="${curseslib/-l/}"
  676. optlist="$optlist ${barelib}/curses"
  677. if test "x${curseslib}" != "xnone required"; then
  678. NCURSES_LIBS="${curseslib}"
  679. fi
  680. # Need to check for headers in subdirectories, to ensure we get wide stuff
  681. AC_MSG_CHECKING([for curses header subdirectory])
  682. barelib="${barelib/6/}"
  683. barelib="${barelib/5/}"
  684. cursesincl=`echo "#include <${barelib}/curses.h>" | ${CPP} -M - 2>/dev/null | tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)libusb\.h[[:space:]].*$/\1/' -e t -e d`
  685. if test "x$cursesincl" != "x"; then
  686. NCURSES_CPPFLAGS="-I${cursesincl}"
  687. AC_MSG_RESULT([$cursesincl])
  688. else
  689. AC_MSG_RESULT([none found])
  690. fi
  691. break
  692. ], [
  693. if test "x$curses" = "xyes"; then
  694. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  695. else
  696. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  697. curses=no
  698. optlist="$optlist curses"
  699. fi
  700. ])
  701. fi
  702. if test "x$curses" = "xyes"; then
  703. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  704. AC_MSG_CHECKING([whether curses library supports wide characters])
  705. LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS"
  706. AC_LINK_IFELSE([
  707. AC_LANG_PROGRAM([
  708. #define PDC_WIDE
  709. #include <curses.h>
  710. ],[
  711. addwstr(L"test");
  712. add_wch(WACS_VLINE);
  713. ])
  714. ],[
  715. AC_MSG_RESULT([yes])
  716. AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters])
  717. ],[
  718. AC_MSG_RESULT([no])
  719. ])
  720. fi
  721. LIBS="$orig_libs"
  722. fi
  723. maybe_ldconfig=
  724. AC_ARG_WITH([system-libblkmaker], [AC_HELP_STRING([--with-system-libblkmaker], [Use system libblkmaker rather than bundled one (default disabled)])],[true],[with_system_libblkmaker=no])
  725. if test "x$with_system_libblkmaker" = "xyes"; then
  726. PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
  727. true
  728. ],[
  729. AC_MSG_ERROR([Could not find system libblkmaker])
  730. ])
  731. else
  732. save_LDFLAGS="$LDFLAGS"
  733. LDFLAGS="$LDFLAGS -Wl,-zorigin"
  734. origin_LDFLAGS=
  735. AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
  736. AC_TRY_LINK([],[],[
  737. AC_MSG_RESULT([yes])
  738. origin_LDFLAGS=',-zorigin'
  739. ],[
  740. AC_MSG_RESULT([no])
  741. ])
  742. LDFLAGS="$save_LDFLAGS"
  743. libblkmaker_CFLAGS='-Ilibblkmaker'
  744. libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS"
  745. libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
  746. AC_CONFIG_SUBDIRS([libblkmaker])
  747. _ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g`
  748. possible_ldconfigs="${target}-ldconfig"
  749. if test "x$cross_compiling" != "xyes"; then
  750. possible_ldconfigs="${possible_ldconfigs} ldconfig"
  751. fi
  752. AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH])
  753. if test "x$LDCONFIG" != "x"; then
  754. maybe_ldconfig=" && $LDCONFIG"
  755. fi
  756. fi
  757. AC_SUBST(libblkmaker_CFLAGS)
  758. AC_SUBST(libblkmaker_LDFLAGS)
  759. AC_SUBST(libblkmaker_LIBS)
  760. AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
  761. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes])
  762. AM_CONDITIONAL([NEED_FPGAUTILS], [test x$need_fpgautils = xyes])
  763. AM_CONDITIONAL([NEED_BFG_LOWLEVEL], [test x$need_lowlevel = xyes])
  764. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  765. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  766. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  767. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  768. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  769. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  770. AM_CONDITIONAL([HAS_FPGA], [test x$bitforce$icarus$modminer$x6500$ztex != xnonononono])
  771. AM_CONDITIONAL([HAS_ASIC], [test x$avalon$bfsb$bigpic$icarus$httpsrv$metabank != xnononononono])
  772. dnl Find YASM
  773. has_yasm=false
  774. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  775. AC_PATH_PROG([YASM],[yasm],[false])
  776. if test "x$YASM" != "xfalse" ; then
  777. has_yasm_enableaction="install yasm 1.0.1+"
  778. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  779. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  780. yamajor=`echo $yasmver | cut -d. -f1`
  781. yaminor=`echo $yasmver | cut -d. -f2`
  782. yamini=`echo $yasmver | cut -d. -f3`
  783. if test "$yamajor" -ge "1" ; then
  784. if test "$yamajor" -eq "1" ; then
  785. if test "$yaminor" -ge "0" ; then
  786. if test "$yaminor" -eq "0"; then
  787. if test "$yamini" -ge "1"; then
  788. has_yasm=true
  789. fi
  790. else
  791. has_yasm=true
  792. fi
  793. fi
  794. fi
  795. else
  796. has_yasm=false
  797. fi
  798. if test "x$has_yasm" = "xtrue" ; then
  799. AC_MSG_RESULT([yes])
  800. else
  801. AC_MSG_RESULT([no])
  802. fi
  803. fi
  804. if test "x$has_yasm" = "xfalse" ; then
  805. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  806. else
  807. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  808. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  809. if test "x$have_x86_64" = xtrue; then
  810. YASM_FMT="win64"
  811. else
  812. YASM_FMT="coff"
  813. fi
  814. elif test "x$have_macho" = "xtrue"; then
  815. YASM_FMT="macho$bitness"
  816. else
  817. YASM_FMT="elf$bitness"
  818. fi
  819. fi
  820. fi
  821. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  822. have_sse2=no
  823. if test "x$cpumining$have_x86_32" = "xyestrue"; then
  824. AC_MSG_CHECKING([if SSE2 code compiles])
  825. save_CFLAGS="$CFLAGS"
  826. for flags in '' '-msse2'; do
  827. CFLAGS="$CFLAGS $flags"
  828. AC_TRY_LINK([
  829. #include <xmmintrin.h>
  830. ],[
  831. int *i = (int *)0xdeadbeef;
  832. __m128i a, b;
  833. a = _mm_set1_epi32(i[0]);
  834. b = _mm_set_epi32(i[0], i[1], i[2], i[3]);
  835. a = _mm_add_epi32(a, b);
  836. a = _mm_andnot_si128(a, b);
  837. a = _mm_or_si128(a, b);
  838. a = _mm_slli_epi32(a, i[4]);
  839. a = _mm_and_si128(a, b);
  840. a = _mm_xor_si128(a, b);
  841. ],[
  842. if test "x$flags" = "x"; then
  843. AC_MSG_RESULT([yes])
  844. else
  845. AC_MSG_RESULT([with $flags])
  846. fi
  847. SSE2_CFLAGS="$flags"
  848. have_sse2=yes
  849. break
  850. ],[
  851. true
  852. ])
  853. done
  854. CFLAGS="${save_CFLAGS}"
  855. if test "x$have_sse2" = "xyes"; then
  856. AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used])
  857. else
  858. AC_MSG_RESULT([no])
  859. fi
  860. fi
  861. AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"])
  862. if test "x$need_fpgautils" = "xyes"; then
  863. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  864. [libudev=$withval],
  865. [libudev=auto]
  866. )
  867. if test "x$libudev" != "xno"; then
  868. AC_CHECK_HEADER([libudev.h],[
  869. libudev=yes
  870. UDEV_LIBS=-ludev
  871. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  872. ], [
  873. if test "x$libudev" = "xyes"; then
  874. AC_MSG_ERROR([libudev not found])
  875. fi
  876. libudev=no
  877. ])
  878. fi
  879. fi
  880. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  881. AC_SUBST(LIBUSB_LIBS)
  882. AC_SUBST(LIBUSB_CFLAGS)
  883. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  884. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  885. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  886. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  887. fi
  888. AC_SUBST(LIBCURL_LIBS)
  889. AC_CHECK_FUNCS([setrlimit])
  890. dnl CCAN wants to know a lot of vars.
  891. # All the configuration checks. Regrettably, the __attribute__ checks will
  892. # give false positives on old GCCs, since they just cause warnings. But that's
  893. # fairly harmless.
  894. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  895. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  896. [Define if __attribute__((cold))]))
  897. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  898. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  899. [Define if __attribute__((const))]))
  900. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  901. [
  902. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  903. [Define if __attribute__((noreturn))])
  904. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  905. ], [
  906. AC_DEFINE_UNQUOTED([NORETURN], [])
  907. ]
  908. )
  909. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  910. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  911. [Define if __attribute__((format(__printf__)))]))
  912. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  913. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  914. [Define if __attribute__((unused))]))
  915. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  916. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  917. [Define if __attribute__((used))]))
  918. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  919. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  920. [Define if have __builtin_constant_p]))
  921. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  922. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  923. [Define if have __builtin_types_compatible_p]))
  924. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  925. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  926. [Define if __attribute__((warn_unused_result))]))
  927. AC_MSG_CHECKING([for roundl function])
  928. save_LIBS="${LIBS}"
  929. LIBS="$LIBS -lm"
  930. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  931. #include <math.h>
  932. ]], [[
  933. return (roundl(*(long double *)0xdeadbeef) == 1.0);
  934. ]])], [
  935. AC_MSG_RESULT([yes])
  936. ], [
  937. AC_MSG_RESULT([no])
  938. AC_DEFINE([NEED_ROUNDL], [1], [Defined to 1 if C99 roundl is missing])
  939. ])
  940. LIBS="${save_LIBS}"
  941. # byteswap functions
  942. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  943. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  944. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  945. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  946. BSWAP=''
  947. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  948. AC_MSG_CHECKING([for ${sym}* functions])
  949. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  950. BFG_INCLUDE([headerinclude], [${headerfile}])
  951. AC_LINK_IFELSE([
  952. AC_LANG_PROGRAM([
  953. ${headerinclude}
  954. ], [
  955. (void) ${sym}16(0);
  956. (void) ${sym}32(0);
  957. (void) ${sym}64(0);
  958. ])
  959. ], [
  960. BSWAP="${sym}"
  961. if test "x${headerfile}" = "x"; then
  962. AC_MSG_RESULT([yes])
  963. else
  964. AC_MSG_RESULT([found in ${headerfile}])
  965. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  966. fi
  967. break 2
  968. ])
  969. done
  970. AC_MSG_RESULT([no])
  971. done
  972. if test "x$BSWAP" = "x"; then
  973. true # Substitutes are provided in miner.h
  974. elif test "x$BSWAP" = "xbswap_"; then
  975. AC_MSG_CHECKING([if bswap_16 is already a macro])
  976. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  977. AC_MSG_RESULT([yes])
  978. BSWAP=""
  979. ],[
  980. AC_MSG_RESULT([no])
  981. ])
  982. fi
  983. if test "x$BSWAP" != "x"; then
  984. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  985. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  986. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  987. fi
  988. # endian definition macros
  989. AC_MSG_CHECKING([for platform endian])
  990. found_endian=no
  991. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  992. for pfx in '' '__'; do
  993. BFG_PREPROC_IFELSE([defined(${pfx}BYTE_ORDER) && defined(${pfx}BIG_ENDIAN) && defined(${pfx}LITTLE_ENDIAN) && (${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN || ${pfx}BYTE_ORDER == ${pfx}LITTLE_ENDIAN)], ${headerfile}, [
  994. if test "x$headerfile" = "x"; then
  995. headerfilec=''
  996. else
  997. headerfilec=" (${headerfile})"
  998. fi
  999. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  1000. AC_MSG_RESULT([big endian${headerfilec}])
  1001. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  1002. ], [
  1003. AC_MSG_RESULT([little endian${headerfilec}])
  1004. ])
  1005. found_endian=yes
  1006. break 2
  1007. ],[true])
  1008. done
  1009. done
  1010. if test "x$found_endian" = "xno"; then
  1011. if $have_win32 || $have_cygwin; then
  1012. AC_MSG_RESULT([assuming little endian (Windows)])
  1013. else
  1014. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  1015. AC_MSG_RESULT([unknown])
  1016. AC_MSG_ERROR([Unable to identify platform endian])
  1017. fi
  1018. fi
  1019. AC_MSG_CHECKING([if GNU format attribute compiles])
  1020. AC_TRY_COMPILE([
  1021. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  1022. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  1023. int myfunc(char *fmt, ...) {
  1024. return 42;
  1025. }
  1026. ], [
  1027. myfunc("abc%d", 42);
  1028. ], [
  1029. AC_MSG_RESULT([yes])
  1030. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  1031. ], [
  1032. AC_MSG_RESULT([no])
  1033. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  1034. ])
  1035. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC)])
  1036. AC_TRY_COMPILE([
  1037. #define _GNU_SOURCE
  1038. #include <time.h>
  1039. ],[
  1040. struct timespec ts;
  1041. clock_gettime(CLOCK_MONOTONIC, &ts);
  1042. ],[
  1043. AC_MSG_RESULT([yes])
  1044. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC) is defined])
  1045. save_LIBS="${LIBS}"
  1046. AC_SEARCH_LIBS([clock_gettime],[rt posix4],[
  1047. if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then
  1048. RT_LIBS="${ac_cv_search_clock_gettime}"
  1049. fi
  1050. ])
  1051. LIBS="${save_LIBS}"
  1052. AC_CHECK_FUNCS([clock_nanosleep])
  1053. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC_RAW)])
  1054. AC_TRY_COMPILE([
  1055. #define _GNU_SOURCE
  1056. #include <time.h>
  1057. ],[
  1058. struct timespec ts;
  1059. clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  1060. ],[
  1061. AC_MSG_RESULT([yes])
  1062. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC_RAW], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC_RAW) is defined])
  1063. ],[
  1064. AC_MSG_RESULT([no])
  1065. ])
  1066. ],[
  1067. AC_MSG_RESULT([no])
  1068. ])
  1069. if test "x$prefix" = xNONE; then
  1070. prefix=/usr/local
  1071. fi
  1072. AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono])
  1073. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel])
  1074. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel])
  1075. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel])
  1076. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel])
  1077. AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
  1078. AC_SUBST(PTHREAD_FLAGS)
  1079. AC_SUBST(DLOPEN_FLAGS)
  1080. AC_SUBST(PTHREAD_LIBS)
  1081. AC_SUBST(NCURSES_CPPFLAGS)
  1082. AC_SUBST(NCURSES_LIBS)
  1083. AC_SUBST(PDCURSES_LIBS)
  1084. AC_SUBST(WS2_LIBS)
  1085. AC_SUBST(MM_LIBS)
  1086. AC_SUBST(MATH_LIBS)
  1087. AC_SUBST(RT_LIBS)
  1088. AC_SUBST(UDEV_LIBS)
  1089. AC_SUBST(SSE2_CFLAGS)
  1090. AC_SUBST(YASM_FMT)
  1091. AC_CONFIG_FILES([
  1092. Makefile
  1093. x86_64/Makefile
  1094. x86_32/Makefile
  1095. ccan/Makefile
  1096. lib/Makefile
  1097. ])
  1098. AC_OUTPUT
  1099. echo
  1100. echo
  1101. echo
  1102. echo "------------------------------------------------------------------------"
  1103. echo "$PACKAGE $VERSION"
  1104. echo "------------------------------------------------------------------------"
  1105. echo
  1106. echo
  1107. echo "Configuration Options Summary:"
  1108. echo
  1109. m4_define([BFG_PRINT_LIST],[
  1110. eval _mylist="\$$2"
  1111. _yeslist=
  1112. _nolist=
  1113. _enableactions=
  1114. for _opt in $_mylist; do
  1115. IFS=/ read _opt _var <<EOF
  1116. $_opt
  1117. EOF
  1118. test -n "$_var" || _var="$_opt"
  1119. eval "_val=\"\$${_var}\""
  1120. if test "x$_val" = "xno" || test "x$_val" = "xfalse"; then
  1121. _nolist="$_nolist $_opt"
  1122. eval "_enableaction=\"\$${_var}_enableaction\""
  1123. if test -n "$_enableaction"; then
  1124. _enableactions="${_enableactions}~ To enable ${_opt}, ${_enableaction}"
  1125. fi
  1126. else
  1127. _yeslist="$_yeslist $_opt"
  1128. fi
  1129. done
  1130. _yeslist=`echo "$_yeslist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1131. _nolist=`echo "$_nolist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1132. echo " Enabled..$1..:$_yeslist"
  1133. echo " Disabled.$1..:$_nolist"
  1134. if test -n "$_enableactions"; then
  1135. echo "${_enableactions:1}" | tr '~' '\n'
  1136. fi
  1137. ])
  1138. BFG_PRINT_LIST([Drivers...],[driverlist])
  1139. BFG_PRINT_LIST([Algorithms],[algolist])
  1140. BFG_PRINT_LIST([Options...],[optlist])
  1141. echo
  1142. echo "Compilation............: make (or gmake)"
  1143. echo " CFLAGS...............: $CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libblkmaker_CFLAGS $hidapi_CFLAGS"
  1144. echo " LDFLAGS..............: $LDFLAGS $PTHREAD_FLAGS $libblkmaker_LDFLAGS $PTHREAD_LIBS $LIBS $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $UDEV_LIBS $LIBUSB_LIBS $RT_LIBS $sensors_LIBS $libblkmaker_LIBS"
  1145. echo
  1146. echo "Installation...........: make install$maybe_ldconfig #(as root if needed, with 'su' or 'sudo')"
  1147. echo " prefix...............: $prefix"
  1148. echo