configure.ac 40 KB

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