configure.ac 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940
  1. dnl * Copyright 2011-2014 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 * Copyright 2013-2014 Nate Woolls
  8. dnl *
  9. dnl * This program is free software; you can redistribute it and/or modify it
  10. dnl * under the terms of the GNU General Public License as published by the Free
  11. dnl * Software Foundation; either version 3 of the License, or (at your option)
  12. dnl * any later version. See COPYING for more details.
  13. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  14. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  15. m4_define([v_maj], [4])
  16. m4_define([v_min], [9])
  17. m4_define([v_mic], [0])
  18. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  19. m4_define([v_ver], [v_maj.v_min.v_mic])
  20. m4_define([lt_rev], m4_eval(v_maj + v_min))
  21. m4_define([lt_cur], v_mic)
  22. m4_define([lt_age], v_min)
  23. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  24. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  25. AC_INIT([bfgminer], [v_ver], [luke-jr+bfgminer@utopios.org])
  26. AC_PREREQ([2.59c])
  27. AC_CANONICAL_SYSTEM
  28. AC_CONFIG_MACRO_DIR([m4])
  29. AC_CONFIG_SRCDIR([miner.c])
  30. AC_CONFIG_HEADERS([config.h])
  31. AH_BOTTOM([
  32. #ifdef WIN32
  33. #include "winhacks.h"
  34. #endif
  35. ])
  36. AM_INIT_AUTOMAKE([foreign subdir-objects])
  37. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  38. AC_USE_SYSTEM_EXTENSIONS
  39. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  40. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  41. m4_ifdef([v_rev], , [m4_define([v_rev], [0])])
  42. m4_ifdef([v_rel], , [m4_define([v_rel], [])])
  43. AC_DEFINE_UNQUOTED(CGMINER_MAJOR_VERSION, [v_maj], [Major version])
  44. AC_DEFINE_UNQUOTED(CGMINER_MINOR_VERSION, [v_min], [Minor version])
  45. AC_DEFINE_UNQUOTED(CGMINER_MINOR_SUBVERSION, [v_mic], [Micro version])
  46. version_info="lt_rev:lt_cur:lt_age"
  47. release_info="v_rel"
  48. AC_SUBST(version_info)
  49. AC_SUBST(release_info)
  50. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  51. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  52. VMAJ=v_maj
  53. AC_SUBST(VMAJ)
  54. AC_CANONICAL_BUILD
  55. AC_CANONICAL_HOST
  56. dnl Make sure anyone changing configure.ac/Makefile.am has a clue
  57. AM_MAINTAINER_MODE([enable])
  58. dnl Checks for programs
  59. AC_PROG_CC_C99
  60. gl_EARLY
  61. AC_PROG_GCC_TRADITIONAL
  62. AM_PROG_CC_C_O
  63. AC_PROG_RANLIB
  64. AC_PROG_CPP
  65. gl_INIT
  66. AC_SYS_LARGEFILE
  67. dnl Checks for header files.
  68. AC_HEADER_STDC
  69. AC_CHECK_HEADERS(syslog.h)
  70. AC_CHECK_HEADERS([sys/epoll.h])
  71. AC_CHECK_HEADERS([sys/mman.h])
  72. AC_CHECK_HEADERS([sys/prctl.h])
  73. AC_CHECK_HEADERS([sys/file.h])
  74. AC_CHECK_HEADERS([sys/termios.h])
  75. AC_CHECK_HEADERS([linux/spi/spidev.h])
  76. AC_CHECK_MEMBER([struct i2c_msg.buf],[
  77. true
  78. ],[
  79. dnl Note the member is different here to avoid caching screwing things up
  80. AC_CHECK_MEMBER([struct i2c_msg.len],[
  81. AC_DEFINE([NEED_LINUX_I2C_H],[1],[Defined if linux/i2c.h is needed to supplement linux/i2c-dev.h])
  82. ],[
  83. true
  84. ],[
  85. AC_INCLUDES_DEFAULT
  86. #include <linux/i2c.h>
  87. #include <linux/i2c-dev.h>
  88. ])
  89. ],[
  90. AC_INCLUDES_DEFAULT
  91. #include <linux/i2c-dev.h>
  92. ])
  93. # Setuid
  94. AC_CHECK_HEADERS([pwd.h])
  95. # Check for chroot support
  96. AC_CHECK_FUNCS([chroot])
  97. AC_CHECK_FUNCS([sleep])
  98. AC_FUNC_ALLOCA
  99. lowllist=
  100. driverlist=
  101. algolist=SHA256d
  102. optlist=
  103. has_fpga=no
  104. has_asic=no
  105. need_binloader=no
  106. need_dynclock=no
  107. need_gc3355=no
  108. need_linux_i2c_dev=no
  109. need_lowl_vcom=no
  110. need_lowlevel=no
  111. need_lowl_ftdi=no
  112. need_lowl_hid=no
  113. need_lowl_mswin=no
  114. need_lowl_pci=no
  115. need_lowl_spi=no
  116. need_lowl_usb=no
  117. need_knc_asic=no
  118. need_work2d=no
  119. have_cygwin=false
  120. have_win32=false
  121. have_macho=false
  122. use_udevrules=true
  123. have_udevrules=false
  124. AUTOSCAN_CPPFLAGS=""
  125. AUTOSCAN_LIBS=""
  126. DLOPEN_FLAGS="-ldl"
  127. WS2_LIBS=""
  128. MM_LIBS=""
  129. MATH_LIBS="-lm"
  130. RT_LIBS=""
  131. case $target in
  132. amd64-* | x86_64-*)
  133. have_x86_32=false
  134. have_x86_64=true
  135. bitness="64"
  136. ;;
  137. i386-* | i486-* | i586-* | i686-* | x86-*)
  138. have_x86_32=true
  139. have_x86_64=false
  140. bitness="32"
  141. ;;
  142. *)
  143. have_x86_32=false
  144. have_x86_64=false
  145. ;;
  146. esac
  147. case $target in
  148. *-*-mingw*)
  149. have_win32=true
  150. use_udevrules=false
  151. DLOPEN_FLAGS=""
  152. WS2_LIBS="-lws2_32"
  153. MM_LIBS="-lwinmm"
  154. AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
  155. AC_DEFINE([FD_SETSIZE], [4096], [Maximum sockets before fd_set overflows])
  156. ;;
  157. *-*-cygwin*)
  158. have_cygwin=true
  159. use_udevrules=false
  160. ;;
  161. powerpc-*-darwin*)
  162. CFLAGS="$CFLAGS -faltivec"
  163. have_macho=true
  164. use_udevrules=false
  165. ;;
  166. *-*-darwin*)
  167. LDFLAGS="$LDFLAGS -framework IOKit -framework CoreFoundation"
  168. have_macho=true
  169. use_udevrules=false
  170. ;;
  171. esac
  172. m4_define([BFG_INCLUDE],
  173. if test "x$2" = "x"; then
  174. $1=''
  175. else
  176. $1="[#]include <$2>"
  177. fi
  178. )
  179. m4_define([BFG_PREPROC_IFELSE],
  180. BFG_INCLUDE([headerinclude], $2)
  181. AC_COMPILE_IFELSE([
  182. AC_LANG_PROGRAM([
  183. ${headerinclude}
  184. ], [
  185. #if !( $1 )
  186. #error "$1 false in preprocessor"
  187. #endif
  188. ])
  189. ],[$3],[$4])
  190. )
  191. AC_CHECK_DECL([HASH_ITER],[
  192. AC_CHECK_DECL([DL_CONCAT],[
  193. true
  194. ],[
  195. AC_MSG_ERROR([Could not find DL_FOREACH_SAFE - install uthash-dev 1.9.4+])
  196. ],[
  197. #include <utlist.h>
  198. ])
  199. ],[
  200. AC_MSG_ERROR([Could not find HASH_ITER - please install uthash-dev 1.9.4+])
  201. ],[
  202. #include <uthash.h>
  203. ])
  204. ddyes=yes
  205. ddauto=auto
  206. ddno=no
  207. AC_ARG_ENABLE([other-drivers],
  208. [AC_HELP_STRING([--disable-other-drivers],[Build without drivers by default unless explicitly enabled])],
  209. [
  210. if test x$enableval = xyes; then
  211. ddno=yes
  212. else
  213. ddyes=no
  214. ddauto=no
  215. fi
  216. ]
  217. )
  218. broad_udevrules=false
  219. AC_ARG_ENABLE([broad-udevrules],
  220. [AC_HELP_STRING([--enable-broad-udevrules],[Include udev rules for ambiguous devices which may not be miners])],
  221. [
  222. if test "x$enableval" = "xyes"; then
  223. broad_udevrules=true
  224. fi
  225. ]
  226. )
  227. use_udevrules_group=true
  228. udevrules_group="video"
  229. AC_ARG_WITH([udevrules-group],
  230. [AC_HELP_STRING([--with-udevrules-group=groupname],[Configure mining devices to be owned by a specific group (default `video')])],
  231. [
  232. if test "x$withval" = "xno"; then
  233. use_udevrules_group=false
  234. else
  235. udevrules_group="$withval"
  236. fi
  237. ]
  238. )
  239. AM_CONDITIONAL([USE_UDEVRULES_GROUP], [$use_udevrules_group])
  240. AC_SUBST([UDEVRULES_GROUP], [$udevrules_group])
  241. algolist="$algolist scrypt"
  242. AC_ARG_ENABLE([scrypt],
  243. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  244. [scrypt=$enableval],
  245. [scrypt=no])
  246. if test "x$scrypt" = xyes; then
  247. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  248. fi
  249. lowl_pci=no
  250. if test "x$ac_cv_header_sys_mman_h" = "xyes"; then
  251. AC_ARG_WITH([uio],
  252. [AC_HELP_STRING([--without-uio],[Compile support for PCI devices via Linux UIO interface (default enabled)])],
  253. [uio=$withval],
  254. [uio=yes])
  255. AC_ARG_WITH([vfio],
  256. [AC_HELP_STRING([--without-vfio],[Compile support for PCI devices via Linux VFIO interface (default enabled)])],
  257. [vfio=$withval],
  258. [vfio=auto])
  259. if test "x$vfio" != "xno"; then
  260. AC_CHECK_HEADER([linux/vfio.h],[
  261. vfio=yes
  262. ],[
  263. if test "x$vfio" = "xyes"; then
  264. AC_MSG_ERROR([Unable to find linux/vfio.h])
  265. elif test "x$uio" = "xyes"; then
  266. AC_MSG_WARN([linux/vfio.h not found; PCI device support will require UIO (and root access)])
  267. else
  268. AC_MSG_WARN([linux/vfio.h not found; PCI device support will not be available])
  269. fi
  270. vfio=no
  271. ])
  272. fi
  273. if test "x$vfio$uio" != xnono; then
  274. lowl_pci=yes
  275. fi
  276. fi
  277. driverlist="$driverlist cpu/cpumining"
  278. AC_ARG_ENABLE([cpumining],
  279. [AC_HELP_STRING([--enable-cpumining],[Build with CPU mining support (default disabled)])],
  280. [cpumining=$enableval],
  281. [cpumining=$ddno]
  282. )
  283. if test "x$cpumining" = xyes; then
  284. AC_DEFINE_UNQUOTED([WANT_CPUMINE], [1], [Enable CPUMINING])
  285. driverlist="$driverlist cpu:asm/has_yasm"
  286. driverlist="$driverlist cpu:sse2/have_sse2"
  287. fi
  288. AM_CONDITIONAL([HAS_CPUMINE], [test x$cpumining = xyes])
  289. driverlist="$driverlist opencl"
  290. AC_ARG_ENABLE([opencl],
  291. [AC_HELP_STRING([--enable-opencl],[Compile support for OpenCL (default disabled)])],
  292. [opencl=$enableval],
  293. [opencl=$ddno]
  294. )
  295. if test "x$opencl" = xyes; then
  296. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL support is wanted])
  297. fi
  298. AM_CONDITIONAL([HAVE_OPENCL], [test x$opencl = xyes])
  299. m4_define([BFG_PTHREAD_FLAG_CHECK],
  300. AC_MSG_CHECKING([for $1])
  301. for cflag in ' -pthread' ''; do
  302. for lib in ' -lpthread' ' -lwinpthread' ''; do
  303. CFLAGS="${save_CFLAGS}${cflag}"
  304. LIBS="${save_LIBS}${lib}"
  305. AC_LINK_IFELSE([
  306. AC_LANG_PROGRAM([
  307. #include <pthread.h>
  308. ], [
  309. void *f = $1;
  310. ])
  311. ], [
  312. found_pthread=true
  313. PTHREAD_FLAGS="${cflag}"
  314. PTHREAD_LIBS="${lib}"
  315. if test "x${cflag}${lib}" = "x"; then
  316. AC_MSG_RESULT([yes])
  317. else
  318. AC_MSG_RESULT([with${cflag}${lib}])
  319. fi
  320. $2
  321. break 2
  322. ])
  323. done
  324. done
  325. if test "x${found_pthread}" = "xfalse"; then
  326. AC_MSG_RESULT([no])
  327. fi
  328. )
  329. save_CFLAGS="${CFLAGS}"
  330. save_LIBS="${LIBS}"
  331. found_pthread=false
  332. BFG_PTHREAD_FLAG_CHECK([pthread_cancel],[
  333. AC_DEFINE([HAVE_PTHREAD_CANCEL], [1], [Define if you have a native pthread_cancel])
  334. ])
  335. if test "x${found_pthread}" = "xfalse"; then
  336. BFG_PTHREAD_FLAG_CHECK([pthread_create])
  337. if test "x${found_pthread}" = "xfalse"; then
  338. AC_MSG_ERROR([Could not find pthread library - please install libpthread])
  339. fi
  340. fi
  341. # check for nanosleep here, since it is provided by winpthread
  342. AC_CHECK_FUNCS([nanosleep])
  343. CFLAGS="${save_CFLAGS}"
  344. LIBS="${save_LIBS}"
  345. PKG_CHECK_MODULES([JANSSON],[jansson],[
  346. true
  347. ],[
  348. AC_MSG_CHECKING([for jansson in system-default locations])
  349. LIBS="$LIBS -ljansson"
  350. AC_TRY_LINK([
  351. #include <jansson.h>
  352. ],[
  353. json_object();
  354. ],[
  355. AC_MSG_RESULT([found])
  356. JANSSON_LIBS=-ljansson
  357. ],[
  358. AC_MSG_RESULT([not found])
  359. AC_MSG_ERROR([Could not find jansson library])
  360. ])
  361. LIBS="${save_LIBS}"
  362. ])
  363. AC_SUBST(JANSSON_CFLAGS)
  364. AC_SUBST(JANSSON_LIBS)
  365. if test "x$opencl" = xyes; then
  366. adl="yes"
  367. driverlist="$driverlist opencl:sensors/with_sensors"
  368. AC_ARG_WITH([sensors],
  369. [AC_HELP_STRING([--without-sensors],[Build with libsensors monitoring (default enabled)])],
  370. [true],[with_sensors=auto])
  371. if test "x$opencl" != xyes; then
  372. with_sensors=no
  373. fi
  374. if test "x$with_sensors" != xno; then
  375. AC_MSG_CHECKING([for libsensors])
  376. save_LIBS="${LIBS}"
  377. LIBS="$LIBS -lsensors"
  378. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  379. #include <stddef.h>
  380. #include <sensors/sensors.h>
  381. ],[
  382. const sensors_chip_name *cn;
  383. cn = sensors_get_detected_chips(NULL, NULL);
  384. ])],[
  385. with_sensors=yes
  386. sensors_LIBS="-lsensors"
  387. AC_DEFINE([HAVE_SENSORS], [1], [Defined if libsensors was found])
  388. AC_MSG_RESULT([yes])
  389. ],[
  390. with_sensors=no
  391. AC_MSG_RESULT([no])
  392. if ! $have_win32; then
  393. with_sensors_enableaction="install libsensors"
  394. fi
  395. ])
  396. LIBS="$save_LIBS"
  397. fi
  398. AC_SUBST(sensors_LIBS)
  399. driverlist="$driverlist opencl:adl/adl"
  400. AC_ARG_ENABLE([adl],
  401. [AC_HELP_STRING([--disable-adl],[Build without ADL monitoring (default enabled)])],
  402. [adl=$enableval]
  403. )
  404. if test x$adl = xyes
  405. then
  406. AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
  407. fi
  408. else
  409. adl="no"
  410. fi
  411. driverlist="$driverlist bitforce"
  412. AC_ARG_ENABLE([bitforce],
  413. [AC_HELP_STRING([--disable-bitforce],[Compile support for BitForce (default enabled)])],
  414. [bitforce=$enableval],
  415. [bitforce=$ddyes]
  416. )
  417. if test "x$bitforce" = xyes; then
  418. AC_DEFINE([USE_BITFORCE], [1], [Defined to 1 if BitForce support is wanted])
  419. driverlist="$driverlist bitforce:pci/need_lowl_pci"
  420. if test "x$lowl_pci" = "xyes"; then
  421. need_lowl_pci=yes
  422. fi
  423. need_lowl_vcom=yes
  424. driverlist="$driverlist bitforce:mswin/need_lowl_mswin"
  425. if test x$have_win32 = xtrue; then
  426. need_lowl_mswin=yes
  427. fi
  428. has_fpga=yes
  429. has_asic=yes
  430. have_udevrules=true
  431. fi
  432. AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
  433. driverlist="$driverlist icarus cairnsmore/icarus erupter/icarus antminer/icarus"
  434. AC_ARG_ENABLE([icarus],
  435. [AC_HELP_STRING([--disable-icarus],[Compile support for Icarus (default enabled)])],
  436. [icarus=$enableval],
  437. [icarus=$ddyes]
  438. )
  439. if test "x$icarus" = xyes; then
  440. AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
  441. need_dynclock=yes
  442. need_lowl_vcom=yes
  443. has_fpga=yes
  444. has_asic=yes
  445. have_udevrules=true
  446. fi
  447. AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
  448. driverlist="$driverlist dualminer"
  449. AC_ARG_ENABLE([dualminer],
  450. [AC_HELP_STRING([--disable-dualminer],[Compile support for DualMiner (default enabled)])],
  451. [dualminer=$enableval],
  452. [dualminer=$ddauto]
  453. )
  454. if test "x$dualminer" = "xno"; then
  455. true
  456. elif test "x$icarus" = "xyes"; then
  457. dualminer=yes
  458. elif test "x$dualminer" = "xyes"; then
  459. AC_MSG_ERROR([You explicitly disabled Icarus and explicitly enabled DualMiner])
  460. else
  461. dualminer=no
  462. fi
  463. if test "x$dualminer" = "xyes"; then
  464. AC_DEFINE([USE_DUALMINER], [1], [Defined to 1 if DualMiner support is wanted])
  465. need_gc3355=yes
  466. $broad_udevrules && have_udevrules=true
  467. fi
  468. AM_CONDITIONAL([USE_DUALMINER], [test x$dualminer = xyes])
  469. driverlist="$driverlist zeusminer"
  470. AC_ARG_ENABLE([zeusminer],
  471. [AC_HELP_STRING([--disable-zeusminer],[Compile support for ZeusMiner (default enabled with scrypt)])],
  472. [zeusminer=$enableval],
  473. [zeusminer=$ddauto])
  474. if test "x$zeusminer" = "xno"; then
  475. true
  476. elif test "x$icarus$scrypt" = "xyesyes"; then
  477. zeusminer=yes
  478. elif test "x$zeusminer" = "xauto"; then
  479. zeusminer=no
  480. elif test "x$scrypt" = "xno"; then
  481. AC_MSG_ERROR([You explicitly enabled ZeusMiner, but did not enable scrypt])
  482. elif test "x$icarus" = "xno"; then
  483. AC_MSG_ERROR([You explicitly disabled Icarus and explicitly enabled ZeusMiner])
  484. fi
  485. if test "x$zeusminer" = "xyes"; then
  486. AC_DEFINE([USE_ZEUSMINER], [1], [Defined to 1 if ZeusMiner support is wanted])
  487. need_lowl_vcom=yes
  488. has_asic=yes
  489. $broad_udevrules && have_udevrules=true
  490. fi
  491. AM_CONDITIONAL([USE_ZEUSMINER], [test x$zeusminer = xyes])
  492. driverlist="$driverlist gridseed"
  493. AC_ARG_ENABLE([gridseed],
  494. [AC_HELP_STRING([--disable-gridseed],[Compile support for GridSeed (default enabled with scrypt)])],
  495. [gridseed=$enableval],
  496. [gridseed=$ddauto])
  497. if test "x$gridseed" = "xno"; then
  498. true
  499. elif test "x$scrypt" = "xyes"; then
  500. gridseed=yes
  501. elif test "x$gridseed" = "xauto"; then
  502. gridseed=no
  503. else
  504. AC_MSG_ERROR([You explicitly enabled GridSeed, but did not enable scrypt (SHA2 not supported)])
  505. fi
  506. if test "x$gridseed" = "xyes"; then
  507. AC_DEFINE([USE_GRIDSEED], [1], [Defined to 1 if GridSeed support is wanted])
  508. need_gc3355=yes
  509. need_lowl_vcom=yes
  510. has_asic=yes
  511. $broad_udevrules && have_udevrules=true
  512. fi
  513. AM_CONDITIONAL([USE_GRIDSEED], [test x$gridseed = xyes])
  514. driverlist="$driverlist avalon"
  515. avalon="no"
  516. AC_ARG_ENABLE([avalon],
  517. [AC_HELP_STRING([--disable-avalon],[Compile support for Avalon (default enabled)])],
  518. [avalon=$enableval],
  519. [avalon=$ddyes]
  520. )
  521. if test "x$avalon" = xyes; then
  522. AC_DEFINE([USE_AVALON], [1], [Defined to 1 if Avalon support is wanted])
  523. need_lowl_vcom=yes
  524. has_asic=yes
  525. $broad_udevrules && have_udevrules=true
  526. fi
  527. AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes])
  528. driverlist="$driverlist avalonmm"
  529. AC_ARG_ENABLE([avalonmm],
  530. [AC_HELP_STRING([--disable-avalonmm],[Compile support for Avalon2/3 (default enabled)])],
  531. [avalonmm=$enableval],
  532. [avalonmm=$ddyes]
  533. )
  534. if test "x$avalonmm" = xyes; then
  535. AC_DEFINE([USE_AVALONMM], [1], [Defined to 1 if Avalon2/3 support is wanted])
  536. need_lowl_vcom=yes
  537. need_work2d=yes
  538. has_asic=yes
  539. $broad_udevrules && have_udevrules=true
  540. fi
  541. AM_CONDITIONAL([USE_AVALONMM], [test x$avalonmm = xyes])
  542. driverlist="$driverlist knc"
  543. AC_ARG_ENABLE([knc],
  544. [AC_HELP_STRING([--enable-knc],[Compile support for KnC (default disabled)])],
  545. [knc=$enableval],
  546. [knc=$ddno]
  547. )
  548. if test "x$knc" = xyes; then
  549. need_linux_i2c_dev=yes
  550. AC_DEFINE([USE_KNC], [1], [Defined to 1 if KnC support is wanted])
  551. need_lowl_spi=yes
  552. fi
  553. AM_CONDITIONAL([USE_KNC], [test x$knc = xyes])
  554. driverlist="$driverlist kncasic"
  555. AC_ARG_ENABLE([kncasic],
  556. [AC_HELP_STRING([--enable-kncasic],[Compile support for KnC gen 2 (default disabled)])],
  557. [kncasic=$enableval],
  558. [kncasic=$ddno]
  559. )
  560. if test "x$kncasic" != xno && test "x$kncasic" != xauto; then
  561. kncasic_controller=$kncasic
  562. if test "x$kncasic" = xyes; then
  563. kncasic_controller=BBB
  564. fi
  565. kncasic=yes
  566. need_knc_asic=yes
  567. need_linux_i2c_dev=yes
  568. AC_DEFINE([USE_KNCASIC], [1], [Defined to 1 if KnC gen 2 support is wanted])
  569. AC_DEFINE_UNQUOTED([CONTROLLER_BOARD_$kncasic_controller],[1])
  570. fi
  571. AM_CONDITIONAL([USE_KNCASIC], [test x$kncasic = xyes])
  572. AC_ARG_WITH([libmicrohttpd],
  573. [AC_HELP_STRING([--without-libmicrohttpd],[Compile support for libmicrohttpd getwork server (default enabled)])],
  574. [httpsrv=$withval],
  575. [httpsrv=$ddauto]
  576. )
  577. if test "x$httpsrv" != "xno"; then
  578. PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.5],[
  579. AC_DEFINE([USE_LIBMICROHTTPD],[1],[Defined to 1 if libmicrohttpd support is wanted])
  580. httpsrv=yes
  581. ],[
  582. httpsrv=no
  583. httpsrv_enableaction="install libmicrohttpd 0.9.5+"
  584. need_bfg_driver_proxy_enableaction="install libmicrohttpd 0.9.5+"
  585. if test "x$httpsrv" = "xyes"; then
  586. AC_MSG_ERROR([Unable to find libmicrohttpd 0.9.5+])
  587. else
  588. AC_MSG_WARN([libmicrohttpd 0.9.5+ not found; getwork proxy will be unavailable])
  589. fi
  590. ])
  591. fi
  592. AM_CONDITIONAL([USE_LIBMICROHTTPD], [test x$httpsrv = xyes])
  593. AC_ARG_WITH([libevent],
  594. [AC_HELP_STRING([--without-libevent],[Compile support for libevent stratum server (default enabled)])],
  595. [libevent=$withval],
  596. [libevent=$ddauto]
  597. )
  598. if test "x$libevent" != "xno"; then
  599. PKG_CHECK_MODULES([libevent],[libevent >= 2.0.3],[
  600. AC_DEFINE([USE_LIBEVENT],[1],[Defined to 1 if libevent support is wanted])
  601. libevent=yes
  602. ],[
  603. libevent=no
  604. libevent_enableaction="install libevent 2.0.3+"
  605. if test -n "$need_bfg_driver_proxy_enableaction"; then
  606. need_bfg_driver_proxy_enableaction="${need_bfg_driver_proxy_enableaction} (getwork) or libevent 2.0.3+ (stratum)"
  607. else
  608. need_bfg_driver_proxy_enableaction="install libevent 2.0.3+"
  609. fi
  610. if test "x$libevent" = "xyes"; then
  611. AC_MSG_ERROR([Unable to find libevent 2.0.3+])
  612. else
  613. AC_MSG_WARN([libevent 2.0.3+ not found; stratum proxy will be unavailable])
  614. fi
  615. ])
  616. if test "x$libevent" = "xyes"; then
  617. need_work2d=yes
  618. fi
  619. fi
  620. AM_CONDITIONAL([USE_LIBEVENT], [test x$libevent = xyes])
  621. driverlist="$driverlist proxy/need_bfg_driver_proxy"
  622. if test x$libevent$httpsrv = xnono; then
  623. need_bfg_driver_proxy=no
  624. else
  625. need_bfg_driver_proxy=yes
  626. driverlist="$driverlist proxy:getwork/httpsrv proxy:stratum/libevent"
  627. fi
  628. AM_CONDITIONAL([NEED_BFG_DRIVER_PROXY], [test x$libevent$httpsrv != xnono])
  629. driverlist="$driverlist modminer"
  630. AC_ARG_ENABLE([modminer],
  631. [AC_HELP_STRING([--disable-modminer],[Compile support for ModMiner (default enabled)])],
  632. [modminer=$enableval],
  633. [modminer=$ddyes]
  634. )
  635. if test "x$modminer" = xyes; then
  636. AC_DEFINE([USE_MODMINER], [1], [Defined to 1 if ModMiner support is wanted])
  637. need_dynclock=yes
  638. need_lowl_vcom=yes
  639. need_binloader=yes
  640. has_fpga=yes
  641. have_udevrules=true
  642. fi
  643. AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes])
  644. PKG_PROG_PKG_CONFIG()
  645. libusb=no
  646. libusb_include_path=""
  647. AC_ARG_WITH([libusb],
  648. [AC_HELP_STRING([--without-libusb],[Compile using libusb (default enabled)])],
  649. [want_libusb=$withval],
  650. [want_libusb=auto]
  651. )
  652. if test "x$want_libusb" != "xno"; then
  653. PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[
  654. libusb=yes
  655. ],[
  656. for usb_lib in usb-1.0 usb; do
  657. AC_CHECK_LIB($usb_lib, libusb_init, [
  658. libusb=yes
  659. break
  660. ])
  661. done
  662. if test "x$libusb" = xyes; then
  663. AC_CHECK_DECL([libusb_init],[
  664. LIBUSB_LIBS="-l$usb_lib"
  665. ],[
  666. AC_MSG_CHECKING([whether libusb_init is declared in subdirectory])
  667. 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'`
  668. if test "x$libusb_include_path" != "x"; then
  669. LIBUSB_LIBS="-l$usb_lib"
  670. LIBUSB_CFLAGS="-I$libusb_include_path"
  671. AC_MSG_RESULT([yes])
  672. else
  673. libusb=no
  674. AC_MSG_RESULT([no])
  675. fi
  676. ],[#include <libusb.h>])
  677. fi
  678. ])
  679. fi
  680. driverlist="$driverlist cointerra"
  681. AC_ARG_ENABLE([cointerra],
  682. [AC_HELP_STRING([--disable-cointerra],[Compile support for CoinTerra (default if libusb)])],
  683. [cointerra=$enableval],
  684. [cointerra=$ddauto]
  685. )
  686. if test "x$cointerra$want_libusb" = xyesno; then
  687. AC_MSG_ERROR([You disabled libusb, required for CoinTerra support])
  688. elif test "x$cointerra$libusb" = xyesno; then
  689. AC_MSG_ERROR([Could not find libusb, required for CoinTerra support])
  690. elif test "x$cointerra" = xauto; then
  691. cointerra="$libusb"
  692. if test "x$libusb" = xno; then
  693. AC_MSG_WARN([Could not find libusb, required for CoinTerra support])
  694. cointerra_enableaction="install libusb 1.0+"
  695. fi
  696. fi
  697. if test "x$cointerra" = xyes; then
  698. AC_DEFINE([USE_COINTERRA], [1], [Defined to 1 if CoinTerra support is wanted])
  699. need_lowl_usb=yes
  700. has_asic=yes
  701. have_udevrules=true
  702. fi
  703. AM_CONDITIONAL([USE_COINTERRA], [test x$cointerra = xyes])
  704. driverlist="$driverlist klondike hashbusteravalon/klondike"
  705. AC_ARG_ENABLE([klondike],
  706. [AC_HELP_STRING([--disable-klondike],[Compile support for Klondike (default enabled)])],
  707. [klondike=$enableval],
  708. [klondike=$ddauto]
  709. )
  710. if test "x$klondike$want_libusb" = xyesno; then
  711. AC_MSG_ERROR([You disabled libusb, required for Klondike support])
  712. elif test "x$klondike$libusb" = xyesno; then
  713. AC_MSG_ERROR([Could not find libusb, required for Klondike support])
  714. elif test "x$klondike" = xauto; then
  715. klondike="$libusb"
  716. if test "x$libusb" = xno; then
  717. AC_MSG_WARN([Could not find libusb, required for Klondike support])
  718. klondike_enableaction="install libusb 1.0+"
  719. fi
  720. fi
  721. if test "x$klondike" = xyes; then
  722. AC_DEFINE([USE_KLONDIKE], [1], [Defined to 1 if Klondike support is wanted])
  723. need_lowl_usb=yes
  724. has_asic=yes
  725. have_udevrules=true
  726. fi
  727. AM_CONDITIONAL([HAS_KLONDIKE], [test x$klondike = xyes])
  728. driverlist="$driverlist titan"
  729. AC_ARG_ENABLE([titan],
  730. [AC_HELP_STRING([--enable-titan],[Compile support for KnC Titan (default disabled)])],
  731. [titan=$enableval],
  732. [titan=$ddno]
  733. )
  734. if test "x$titan" != xno && test "x$titan" != xauto; then
  735. if test "x$titan" = xyes; then
  736. if test "x$kncasic" = "xyes"; then
  737. titan_controller="$kncasic_controller"
  738. else
  739. titan_controller=RPI
  740. fi
  741. else
  742. titan_controller=$titan
  743. titan=yes
  744. if test "x$kncasic" = "xyes"; then
  745. if test "x$kncasic_controller" != "$titan_controller"; then
  746. AC_MSG_ERROR([Can only build kncasic and titan drivers together for the same controller (kncasic=$kncasic_controller vs titan=$titan_controller)])
  747. fi
  748. fi
  749. fi
  750. if test "x$scrypt" = "xno"; then
  751. AC_MSG_ERROR([You explicitly enabled KnC Titan, but did not enable scrypt])
  752. fi
  753. need_knc_asic=yes
  754. need_linux_i2c_dev=yes
  755. AC_DEFINE([USE_TITAN], [1], [Defined to 1 if KnC Titan support is wanted])
  756. AC_DEFINE_UNQUOTED([CONTROLLER_BOARD_$titan_controller],[1])
  757. AH_TEMPLATE([CONTROLLER_BOARD_BACKPLANE])
  758. AH_TEMPLATE([CONTROLLER_BOARD_BBB])
  759. AH_TEMPLATE([CONTROLLER_BOARD_RPI])
  760. fi
  761. AM_CONDITIONAL([USE_TITAN], [test x$titan = xyes])
  762. driverlist="$driverlist x6500"
  763. AC_ARG_ENABLE([x6500],
  764. [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])],
  765. [x6500=$enableval],
  766. [x6500=$ddauto]
  767. )
  768. if test "x$x6500$want_libusb" = xyesno; then
  769. AC_MSG_ERROR([You disabled libusb, required for X6500 support])
  770. elif test "x$x6500$libusb" = xyesno; then
  771. AC_MSG_ERROR([Could not find libusb, required for X6500 support])
  772. elif test "x$x6500" = xauto; then
  773. x6500="$libusb"
  774. if test "x$libusb" = xno; then
  775. AC_MSG_WARN([Could not find libusb, required for X6500 support])
  776. x6500_enableaction="install libusb 1.0+"
  777. fi
  778. fi
  779. if test "x$x6500" = xyes; then
  780. AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted])
  781. need_dynclock=yes
  782. need_lowl_ftdi=yes
  783. need_binloader=yes
  784. has_fpga=yes
  785. have_udevrules=true
  786. fi
  787. AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes])
  788. driverlist="$driverlist ztex"
  789. AC_ARG_ENABLE([ztex],
  790. [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])],
  791. [ztex=$enableval],
  792. [ztex=$ddauto]
  793. )
  794. if test "x$ztex$want_libusb" = xyesno; then
  795. AC_MSG_ERROR([You disabled libusb, required for ZTEX support])
  796. elif test "x$ztex$libusb" = xyesno; then
  797. AC_MSG_ERROR([Could not find libusb, required for ZTEX support])
  798. elif test "x$ztex" = xauto; then
  799. ztex="$libusb"
  800. if test "x$libusb" = xno; then
  801. AC_MSG_WARN([Could not find libusb, required for ZTEX support])
  802. ztex_enableaction="install libusb 1.0+"
  803. fi
  804. fi
  805. if test "x$ztex" = xyes; then
  806. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted])
  807. need_dynclock=yes
  808. need_lowl_usb=yes
  809. need_binloader=yes
  810. has_fpga=yes
  811. have_udevrules=true
  812. fi
  813. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  814. driverlist="$driverlist bifury"
  815. AC_ARG_ENABLE([bifury],
  816. [AC_HELP_STRING([--disable-bifury],[Compile support for Bi*Fury (default enabled)])],
  817. [bifury=$enableval],
  818. [bifury=$ddyes]
  819. )
  820. if test "x$bifury" = "xyes"; then
  821. AC_DEFINE([USE_BIFURY], [1], [Defined to 1 if Bi*Fury support is wanted])
  822. need_lowl_vcom=yes
  823. has_asic=yes
  824. have_udevrules=true
  825. fi
  826. AM_CONDITIONAL([USE_BIFURY], [test x$bifury = xyes])
  827. driverlist="$driverlist bitfury_gpio/bitfury"
  828. AC_ARG_ENABLE([bitfury],
  829. [AC_HELP_STRING([--disable-bitfury],[Compile support for Bitfury (default enabled)])],
  830. [bitfury=$enableval],
  831. [bitfury=$ddyes]
  832. )
  833. if test "x$bitfury" = xyes; then
  834. AC_DEFINE([USE_BITFURY], [1], [Defined to 1 if Bitfury support is wanted])
  835. need_lowl_spi=yes
  836. fi
  837. AM_CONDITIONAL([HAS_BITFURY], [test x$bitfury = xyes])
  838. driverlist="$driverlist bfsb"
  839. AC_ARG_ENABLE([bfsb],
  840. [AC_HELP_STRING([--enable-bfsb],[Compile support for BFSB (default disabled)])],
  841. [bfsb=$enableval],
  842. [bfsb=$ddno]
  843. )
  844. if test "x$bfsb" = "xyes"; then
  845. if test "x$bitfury" = "xno"; then
  846. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BFSB])
  847. fi
  848. AC_DEFINE([USE_BFSB], [1], [Defined to 1 if BFSB support is wanted])
  849. fi
  850. AM_CONDITIONAL([HAS_BFSB], [test x$bfsb = xyes])
  851. driverlist="$driverlist bigpic"
  852. AC_ARG_ENABLE([bigpic],
  853. [AC_HELP_STRING([--disable-bigpic],[Compile support for Big Picture Mining USB (default enabled)])],
  854. [bigpic=$enableval],
  855. [bigpic=$ddauto]
  856. )
  857. if test "x$bigpic" = "xno"; then
  858. true
  859. elif test "x$bitfury" = "xyes"; then
  860. bigpic=yes
  861. elif test "x$bigpic" = "xyes"; then
  862. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BigPic])
  863. else
  864. bigpic=no
  865. fi
  866. if test "x$bigpic" = "xyes"; then
  867. AC_DEFINE([USE_BIGPIC], [1], [Defined to 1 if Big Picture Mining USB support is wanted])
  868. need_lowl_vcom=yes
  869. has_asic=yes
  870. have_udevrules=true
  871. fi
  872. AM_CONDITIONAL([HAS_BIGPIC], [test x$bigpic = xyes])
  873. driverlist="$driverlist bfx"
  874. AC_ARG_ENABLE([bfx],
  875. [AC_HELP_STRING([--disable-bfx],[Compile support for BFx2 (default if libusb)])],
  876. [bfx=$enableval],
  877. [bfx=$ddauto]
  878. )
  879. if test "x$bfx" = "xno"; then
  880. true
  881. elif test "x$bitfury$libusb" = "xyesyes"; then
  882. bfx=yes
  883. elif test "x$bfx" = "xyes"; then
  884. if test "x$want_libusb" = "xno"; then
  885. AC_MSG_ERROR([You disabled libusb, required for BFx2 support])
  886. elif test "x$libusb" = "xno"; then
  887. AC_MSG_ERROR([Could not find libusb, required for BFx2 support])
  888. else
  889. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BFx2])
  890. fi
  891. elif test "x$bfx" = "xauto"; then
  892. bfx="$libusb"
  893. if test "x$libusb" = xno; then
  894. AC_MSG_WARN([Could not find libusb, required for BFx2 support])
  895. bfx_enableaction="install libusb 1.0+"
  896. fi
  897. fi
  898. if test "x$bfx" = xyes; then
  899. AC_DEFINE([USE_BFX], [1], [Defined to 1 if BFx2 support is wanted])
  900. need_lowl_ftdi=yes
  901. has_asic=yes
  902. $broad_udevrules && have_udevrules=true
  903. fi
  904. AM_CONDITIONAL([USE_BFX], [test x$bfx = xyes])
  905. driverlist="$driverlist drillbit"
  906. AC_ARG_ENABLE([drillbit],
  907. [AC_HELP_STRING([--disable-drillbit],[Compile support for DrillBit (default enabled)])],
  908. [drillbit=$enableval],
  909. [drillbit=$ddauto]
  910. )
  911. if test "x$drillbit" = "xno"; then
  912. true
  913. elif test "x$bitfury" = "xyes"; then
  914. drillbit=yes
  915. elif test "x$drillbit" = "xyes"; then
  916. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled DrillBit])
  917. else
  918. drillbit=no
  919. fi
  920. if test "x$drillbit" = "xyes"; then
  921. AC_DEFINE([USE_DRILLBIT], [1], [Defined to 1 if DrillBit support is wanted])
  922. need_lowl_vcom=yes
  923. has_asic=yes
  924. have_udevrules=true
  925. fi
  926. AM_CONDITIONAL([USE_DRILLBIT], [test x$drillbit = xyes])
  927. driverlist="$driverlist twinfury"
  928. AC_ARG_ENABLE([twinfury],
  929. [AC_HELP_STRING([--disable-twinfury],[Compile support for Twinfury USB miner (default enabled)])],
  930. [twinfury=$enableval],
  931. [twinfury=$ddauto]
  932. )
  933. if test "x$twinfury" = "xno"; then
  934. true
  935. elif test "x$bitfury" = "xyes"; then
  936. twinfury=yes
  937. elif test "x$twinfury" = "xyes"; then
  938. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Twinfury])
  939. else
  940. twinfury=no
  941. fi
  942. if test "x$twinfury" = "xyes"; then
  943. AC_DEFINE([USE_TWINFURY], [1], [Defined to 1 if Twinfury USB miner support is wanted])
  944. need_lowl_vcom=yes
  945. has_asic=yes
  946. have_udevrules=true
  947. fi
  948. AM_CONDITIONAL([HAS_TWINFURY], [test x$twinfury = xyes])
  949. driverlist="$driverlist littlefury"
  950. AC_ARG_ENABLE([littlefury],
  951. [AC_HELP_STRING([--disable-littlefury],[Compile support for LittleFury (default enabled)])],
  952. [littlefury=$enableval],
  953. [littlefury=$ddauto]
  954. )
  955. if test "x$littlefury" = "xno"; then
  956. true
  957. elif test "x$bitfury" = "xyes"; then
  958. littlefury=yes
  959. elif test "x$littlefury" = "xyes"; then
  960. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled LittleFury])
  961. else
  962. littlefury=no
  963. fi
  964. if test "x$littlefury" = "xyes"; then
  965. AC_DEFINE([USE_LITTLEFURY], [1], [Defined to 1 if LittleFury support is wanted])
  966. need_lowl_vcom=yes
  967. has_asic=yes
  968. have_udevrules=true
  969. fi
  970. AM_CONDITIONAL([HAS_LITTLEFURY], [test x$littlefury = xyes])
  971. found_hidapi=false
  972. for _hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
  973. PKG_CHECK_MODULES([hidapi],[$_hidapi_lib],[
  974. found_hidapi=true
  975. break
  976. ],[
  977. true
  978. ])
  979. done
  980. driverlist="$driverlist nanofury"
  981. AC_ARG_ENABLE([nanofury],
  982. [AC_HELP_STRING([--disable-nanofury],[Compile support for NanoFury (default enabled)])],
  983. [nanofury=$enableval],
  984. [nanofury=$ddauto]
  985. )
  986. if test "x$nanofury" = "xno"; then
  987. true
  988. elif test "x$bitfury" = "xyes"; then
  989. if test x$found_hidapi = xtrue; then
  990. nanofury=yes
  991. else
  992. if test x$nanofury = xauto; then
  993. nanofury=no
  994. nanofury_enableaction="install hidapi"
  995. else
  996. AC_MSG_ERROR([Could not find hidapi, required for NanoFury support])
  997. fi
  998. fi
  999. elif test "x$nanofury" = "xyes"; then
  1000. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled NanoFury])
  1001. else
  1002. nanofury=no
  1003. fi
  1004. if test "x$nanofury" = "xyes"; then
  1005. AC_DEFINE([USE_NANOFURY], [1], [Defined to 1 if NanoFury support is wanted])
  1006. need_lowl_hid=yes
  1007. has_asic=yes
  1008. have_udevrules=true
  1009. fi
  1010. AM_CONDITIONAL([HAS_NANOFURY], [test x$nanofury = xyes])
  1011. driverlist="$driverlist hashbuster"
  1012. AC_ARG_ENABLE([hashbuster],
  1013. [AC_HELP_STRING([--disable-hashbuster],[Compile support for HashBuster Nano (default enabled)])],
  1014. [hashbuster=$enableval],
  1015. [hashbuster=$ddauto],
  1016. )
  1017. if test "x$hashbuster" = "xno"; then
  1018. true
  1019. elif test "x$bitfury" = "xyes"; then
  1020. if test x$found_hidapi = xtrue; then
  1021. hashbuster=yes
  1022. else
  1023. if test x$hashbuster = xauto; then
  1024. hashbuster=no
  1025. hashbuster_enableaction="install hidapi"
  1026. else
  1027. AC_MSG_ERROR([Could not find hidapi, required for HashBuster Nano support])
  1028. fi
  1029. fi
  1030. elif test "x$hashbuster" = "xyes"; then
  1031. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled HashBuster Nano])
  1032. else
  1033. hashbuster=no
  1034. fi
  1035. if test "x$hashbuster" = "xyes"; then
  1036. AC_DEFINE([USE_HASHBUSTER], [1], [Defined to 1 if HashBuster Nano support is wanted])
  1037. need_lowl_hid=yes
  1038. has_asic=yes
  1039. have_udevrules=true
  1040. fi
  1041. AM_CONDITIONAL([USE_HASHBUSTER], [test x$hashbuster = xyes])
  1042. driverlist="$driverlist hashbusterusb"
  1043. AC_ARG_ENABLE([hashbusterusb],
  1044. [AC_HELP_STRING([--disable-hashbusterusb],[Compile support for HashBuster Micro (default if libusb)])],
  1045. [hashbusterusb=$enableval],
  1046. [hashbusterusb=$ddauto]
  1047. )
  1048. if test "x$hashbusterusb$want_libusb" = xyesno; then
  1049. AC_MSG_ERROR([You disabled libusb, required for HashBuster Micro support])
  1050. elif test "x$hashbusterusb$libusb" = xyesno; then
  1051. AC_MSG_ERROR([Could not find libusb, required for HashBuster Micro support])
  1052. elif test "x$hashbusterusb" = xauto; then
  1053. hashbusterusb="$libusb"
  1054. if test "x$libusb" = xno; then
  1055. AC_MSG_WARN([Could not find libusb, required for HashBuster Micro support])
  1056. hashbusterusb_enableaction="install libusb 1.0+"
  1057. fi
  1058. fi
  1059. if test "x$hashbusterusb" = xyes; then
  1060. AC_DEFINE([USE_HASHBUSTERUSB], [1], [Defined to 1 if HashBuster Micro support is wanted])
  1061. need_lowl_usb=yes
  1062. has_asic=yes
  1063. have_udevrules=true
  1064. fi
  1065. AM_CONDITIONAL([USE_HASHBUSTERUSB], [test x$hashbusterusb = xyes])
  1066. driverlist="$driverlist hashfast"
  1067. AC_ARG_ENABLE([hashfast],
  1068. [AC_HELP_STRING([--disable-hashfast],[Compile support for HashFast (default enabled)])],
  1069. [hashfast=$enableval],
  1070. [hashfast=$ddyes]
  1071. )
  1072. if test "x$hashfast" = xyes; then
  1073. AC_DEFINE([USE_HASHFAST], [1], [Defined to 1 if HashFast support is wanted])
  1074. need_lowl_vcom=yes
  1075. has_asic=yes
  1076. have_udevrules=true
  1077. fi
  1078. AM_CONDITIONAL([USE_HASHFAST], [test x$hashfast = xyes])
  1079. driverlist="$driverlist jingtian"
  1080. AC_ARG_ENABLE([jingtian],
  1081. [AC_HELP_STRING([--enable-jingtian],[Compile support for JingTian (default disabled)])],
  1082. [jingtian=$enableval],
  1083. [jingtian=$ddno]
  1084. )
  1085. if test "x$jingtian" = "xyes"; then
  1086. AC_DEFINE([USE_JINGTIAN], [1], [Defined to 1 if JingTian support is wanted])
  1087. need_lowl_spi=yes
  1088. has_asic=yes
  1089. fi
  1090. AM_CONDITIONAL([USE_JINGTIAN], [test x$jingtian = xyes])
  1091. driverlist="$driverlist metabank"
  1092. AC_ARG_ENABLE([metabank],
  1093. [AC_HELP_STRING([--enable-metabank],[Compile support for Metabank (default disabled)])],
  1094. [metabank=$enableval],
  1095. [metabank=$ddno]
  1096. )
  1097. if test "x$metabank" = "xyes"; then
  1098. if test "x$bitfury" = "xno"; then
  1099. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Metabank])
  1100. fi
  1101. AC_DEFINE([USE_METABANK], [1], [Defined to 1 if Metabank support is wanted])
  1102. fi
  1103. AM_CONDITIONAL([HAS_METABANK], [test x$metabank = xyes])
  1104. driverlist="$driverlist minergate"
  1105. AC_ARG_ENABLE([minergate],
  1106. [AC_HELP_STRING([--enable-minergate],[Compile support for Spondoolies minergate interface (default disabled)])],
  1107. [minergate=$enableval],
  1108. [minergate=$ddno]
  1109. )
  1110. if test "x$minergate" = "xyes"; then
  1111. AC_DEFINE([USE_MINERGATE], [1], [Defined to 1 if Spondoolies minergate interface support is wanted])
  1112. need_lowlevel=yes
  1113. has_asic=yes
  1114. fi
  1115. AM_CONDITIONAL([USE_MINERGATE], [test x$minergate = xyes])
  1116. driverlist="$driverlist rockminer"
  1117. AC_ARG_ENABLE([rockminer],
  1118. [AC_HELP_STRING([--disable-rockminer],[Compile support for RockMiner (default enabled)])],
  1119. [rockminer=$enableval],
  1120. [rockminer=$ddyes]
  1121. )
  1122. if test "x$rockminer" = xyes; then
  1123. AC_DEFINE([USE_ROCKMINER], [1], [Defined to 1 if RockMiner support is wanted])
  1124. need_lowl_vcom=yes
  1125. has_asic=yes
  1126. have_udevrules=true
  1127. fi
  1128. AM_CONDITIONAL([USE_ROCKMINER], [test x$rockminer = xyes])
  1129. if test "x$need_lowl_vcom" != "xno"; then
  1130. # Lowlevel VCOM doesn't need libusb, but it can take advantage of it to reattach drivers
  1131. if test "x$libusb" != xno; then
  1132. need_lowl_usb=yes
  1133. elif test "x$libusb$want_libusb" = xnoyes; then
  1134. AC_MSG_ERROR([Could not find libusb, which you specifically requested])
  1135. fi
  1136. fi
  1137. lowllist="$lowllist ftdi/need_lowl_ftdi"
  1138. if test x$need_lowl_ftdi = xyes; then
  1139. AC_DEFINE([NEED_BFG_LOWL_FTDI], [1], [Defined to 1 if lowlevel ftdi drivers are being used])
  1140. need_lowl_usb=yes
  1141. fi
  1142. lowllist="$lowllist spi/need_lowl_spi"
  1143. if test x$need_lowl_spi = xyes; then
  1144. AC_DEFINE([NEED_BFG_LOWL_SPI], [1], [Defined to 1 if lowlevel SPI drivers are being used])
  1145. fi
  1146. if test "x$need_lowl_usb" = "xno"; then
  1147. libusb=no
  1148. LIBUSB_LIBS=''
  1149. LIBUSB_CFLAGS=''
  1150. fi
  1151. if test "x$libusb" = xyes; then
  1152. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  1153. save_CFLAGS="$CFLAGS"
  1154. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  1155. AC_CHECK_DECLS([libusb_error_name],[true],[true],[#include <libusb.h>])
  1156. CFLAGS="$save_CFLAGS"
  1157. fi
  1158. if test x$need_lowl_vcom = xyes; then
  1159. AC_DEFINE([NEED_BFG_LOWL_VCOM], [1], [Defined to 1 if lowlevel VCOM drivers are being used])
  1160. need_lowlevel=yes
  1161. if $have_win32; then
  1162. echo '#include <iospeeds.h>' >iospeeds_local.h
  1163. found_ddkusb=false
  1164. AC_CHECK_HEADER([usbiodef.h],[
  1165. found_ddkusb=true
  1166. ],[
  1167. AC_CHECK_HEADER([ddk/usbiodef.h],[
  1168. found_ddkusb=true
  1169. 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'`
  1170. ],[
  1171. true
  1172. ],[
  1173. #include <windows.h>
  1174. #include <ddk/usbioctl.h>
  1175. AC_INCLUDES_DEFAULT
  1176. ])
  1177. ],[
  1178. #include <windows.h>
  1179. #include <usbioctl.h>
  1180. AC_INCLUDES_DEFAULT
  1181. ])
  1182. if $found_ddkusb; then
  1183. AUTOSCAN_LIBS="-lsetupapi"
  1184. AC_DEFINE([HAVE_WIN_DDKUSB],[1],[Defined to 1 if Windows DDK USB headers are being used])
  1185. fi
  1186. else
  1187. AC_MSG_CHECKING([what baud rates your system supports])
  1188. echo '#include <termios.h>' | ${CPP} -dM - 2>/dev/null | sed 's/.*[ ]B\([0-9][0-9]*\)[ ].*/IOSPEED(\1)/' | grep IOSPEED >iospeeds_local.h
  1189. if grep -q IOSPEED iospeeds_local.h; then
  1190. AC_MSG_RESULT([done])
  1191. else
  1192. AC_MSG_RESULT([failed, using standard POSIX])
  1193. echo '#include <iospeeds_posix.h>' >iospeeds_local.h
  1194. fi
  1195. fi
  1196. fi
  1197. if test "x$opencl$need_lowl_hid" = xnono; then
  1198. DLOPEN_FLAGS=""
  1199. fi
  1200. lowllist="$lowllist hid/need_lowl_hid"
  1201. if test x$need_lowl_hid = xyes; then
  1202. AC_DEFINE([NEED_BFG_LOWL_HID], [1], [Defined to 1 if lowlevel hid drivers are being used])
  1203. need_lowlevel=yes
  1204. fi
  1205. lowllist="$lowllist mswin/need_lowl_mswin"
  1206. if test x$need_lowl_mswin = xyes; then
  1207. AC_DEFINE([NEED_BFG_LOWL_MSWIN], [1], [Defined to 1 if lowlevel mswin drivers are being used])
  1208. need_lowlevel=yes
  1209. fi
  1210. lowllist="$lowllist pci/need_lowl_pci"
  1211. if test x$need_lowl_pci = xyes; then
  1212. AC_DEFINE([NEED_BFG_LOWL_PCI], [1], [Defined to 1 if lowlevel PCI drivers are being used])
  1213. need_lowlevel=yes
  1214. lowllist="$lowllist pci:uio/uio"
  1215. if test x$uio = xyes; then
  1216. AC_DEFINE([USE_UIO], [1], [Defined to 1 if lowlevel PCI drivers should support UIO])
  1217. fi
  1218. lowllist="$lowllist pci:vfio/vfio"
  1219. if test x$vfio = xyes; then
  1220. AC_DEFINE([USE_VFIO], [1], [Defined to 1 if lowlevel PCI drivers should support VFIO])
  1221. fi
  1222. fi
  1223. AM_CONDITIONAL([USE_VFIO], [test x$need_lowl_pci$vfio = xyesyes])
  1224. lowllist="$lowllist usb/need_lowl_usb"
  1225. if test x$need_lowl_usb = xyes; then
  1226. need_lowlevel=yes
  1227. fi
  1228. lowllist="$lowllist vcom/need_lowl_vcom"
  1229. if test x$need_lowl_vcom = xyes; then
  1230. need_lowlevel=yes
  1231. fi
  1232. if test x$need_lowlevel = xyes; then
  1233. AC_DEFINE([HAVE_BFG_LOWLEVEL], [1], [Defined to 1 if lowlevel drivers are being used])
  1234. fi
  1235. if test x$need_linux_i2c_dev = xyes; then
  1236. AC_CHECK_HEADERS([linux/i2c-dev-user.h])
  1237. AC_CHECK_DECL([i2c_smbus_read_word_data],[true],[
  1238. AC_MSG_ERROR([linux/i2c-dev.h header from i2c-tools/libi2c-dev (NOT linux headers) is required for KnCMiner drivers])
  1239. ],[
  1240. #include <stddef.h>
  1241. #ifdef HAVE_LINUX_I2C_DEV_USER_H
  1242. #include <linux/i2c-dev-user.h>
  1243. #else
  1244. #ifdef NEED_LINUX_I2C_H
  1245. #include <linux/i2c.h>
  1246. #endif
  1247. #include <linux/i2c-dev.h>
  1248. #endif
  1249. ])
  1250. fi
  1251. curses="auto"
  1252. AC_ARG_WITH([curses],
  1253. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  1254. [curses=$withval]
  1255. )
  1256. if test "x$curses" = "xno"; then
  1257. optlist="$optlist curses"
  1258. else
  1259. curses_enableaction="install a curses library"
  1260. orig_libs="$LIBS"
  1261. if test "x${curses}" = "xyes"; then
  1262. preferl=''
  1263. else
  1264. preferl="${curses} ${curses}6 ${curses}5"
  1265. fi
  1266. for wideornot in w u ''; do
  1267. for ncursesver in '' 6 5; do
  1268. preferl="${preferl} ncurses${wideornot}${ncursesver}"
  1269. done
  1270. preferl="${preferl} pdcurses${wideornot}"
  1271. done
  1272. if test "x$cross_compiling" != "xyes"; then
  1273. AC_MSG_CHECKING([for best native curses library])
  1274. orig_cflags="$CFLAGS"
  1275. for curses_lib in ${preferl}; do
  1276. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  1277. continue
  1278. fi
  1279. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  1280. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  1281. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1282. #include <curses.h>
  1283. ]], [[
  1284. WINDOW *w = NULL;
  1285. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  1286. ]])], [
  1287. curses=yes
  1288. optlist="$optlist ${curses_lib}/curses"
  1289. AC_MSG_RESULT([$curses_lib])
  1290. NCURSES_LIBS=`${curses_lib}-config --libs`
  1291. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  1292. break
  1293. ], [
  1294. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  1295. ])
  1296. done
  1297. CFLAGS="$orig_cflags"
  1298. if test "x$curses" != "xyes"; then
  1299. AC_MSG_RESULT([none?])
  1300. fi
  1301. fi
  1302. if test "x$curses" != "xyes"; then
  1303. sym=addstr
  1304. AC_SEARCH_LIBS(${sym}, ${preferl}, [
  1305. curses=yes
  1306. eval "curseslib=\"\${ac_cv_search_${sym}}\""
  1307. barelib="${curseslib/-l/}"
  1308. optlist="$optlist ${barelib}/curses"
  1309. if test "x${curseslib}" != "xnone required"; then
  1310. NCURSES_LIBS="${curseslib}"
  1311. fi
  1312. # Need to check for headers in subdirectories, to ensure we get wide stuff
  1313. AC_MSG_CHECKING([for curses header subdirectory])
  1314. barelib="${barelib/6/}"
  1315. barelib="${barelib/5/}"
  1316. 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'`
  1317. if test "x$cursesincl" != "x"; then
  1318. NCURSES_CPPFLAGS="-I${cursesincl}"
  1319. AC_MSG_RESULT([$cursesincl])
  1320. else
  1321. AC_MSG_RESULT([none found])
  1322. fi
  1323. break
  1324. ], [
  1325. if test "x$curses" = "xyes"; then
  1326. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  1327. else
  1328. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  1329. curses=no
  1330. optlist="$optlist curses"
  1331. fi
  1332. ])
  1333. fi
  1334. if test "x$curses" = "xyes"; then
  1335. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  1336. AC_MSG_CHECKING([whether curses library supports wide characters])
  1337. LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS"
  1338. AC_LINK_IFELSE([
  1339. AC_LANG_PROGRAM([
  1340. #define PDC_WIDE
  1341. #include <curses.h>
  1342. ],[
  1343. addwstr(L"test");
  1344. add_wch(WACS_VLINE);
  1345. ])
  1346. ],[
  1347. AC_MSG_RESULT([yes])
  1348. AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters])
  1349. ],[
  1350. AC_MSG_RESULT([no])
  1351. ])
  1352. fi
  1353. LIBS="$orig_libs"
  1354. fi
  1355. BFG_BUNDLED_LIB([libbase58],[libbase58],[auto],[libbase58],[base58],[],[--disable-tool --disable-static --enable-shared])
  1356. BFG_BUNDLED_LIB([libblkmaker],[libblkmaker_jansson-0.1],[no],[libblkmaker],[blkmaker_jansson-0.1 blkmaker-0.1],[libbase58])
  1357. $have_udevrules || use_udevrules=false
  1358. if $use_udevrules; then
  1359. AC_ARG_WITH([udevrulesdir],
  1360. AS_HELP_STRING([--with-udevrulesdir=DIR], [Install udev rules into this directory]),
  1361. [], [
  1362. if test -d /lib/udev/rules.d; then
  1363. with_udevrulesdir=/lib/udev/rules.d
  1364. else
  1365. with_udevrulesdir=no
  1366. fi
  1367. ]
  1368. )
  1369. if test "x$with_udevrulesdir" = "xno"; then
  1370. use_udevrules=false
  1371. fi
  1372. if $use_udevrules; then
  1373. AC_SUBST([udevrulesdir], [$with_udevrulesdir])
  1374. fi
  1375. fi
  1376. AM_CONDITIONAL([NEED_BFG_BINLOADER], [test x$need_binloader = xyes])
  1377. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes])
  1378. AM_CONDITIONAL([USE_GC3355], [test x$need_gc3355 = xyes])
  1379. AM_CONDITIONAL([NEED_BFG_LOWL_VCOM], [test x$need_lowl_vcom = xyes])
  1380. AM_CONDITIONAL([NEED_BFG_LOWL_FTDI], [test x$need_lowl_ftdi = xyes])
  1381. AM_CONDITIONAL([NEED_BFG_LOWL_HID], [test x$need_lowl_hid = xyes])
  1382. AM_CONDITIONAL([NEED_BFG_LOWL_MSWIN], [test x$need_lowl_mswin = xyes])
  1383. AM_CONDITIONAL([NEED_BFG_LOWL_PCI], [test x$need_lowl_pci = xyes])
  1384. AM_CONDITIONAL([NEED_BFG_LOWL_SPI], [test x$need_lowl_spi = xyes])
  1385. AM_CONDITIONAL([NEED_BFG_LOWLEVEL], [test x$need_lowlevel = xyes])
  1386. AM_CONDITIONAL([NEED_BFG_WORK2D], [test x$need_work2d = xyes])
  1387. AM_CONDITIONAL([NEED_KNC_ASIC], [test x$need_knc_asic = xyes])
  1388. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  1389. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  1390. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  1391. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  1392. AM_CONDITIONAL([HAVE_LIBUSB], [test x$libusb = xyes])
  1393. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  1394. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  1395. AM_CONDITIONAL([HAVE_WIN_DDKUSB], [test x$found_ddkusb = xtrue])
  1396. AM_CONDITIONAL([HAS_FPGA], [test x$has_fpga != xno])
  1397. AM_CONDITIONAL([HAS_ASIC], [test x$has_asic != xno])
  1398. AM_CONDITIONAL([USE_UDEVRULES], [$use_udevrules])
  1399. AM_CONDITIONAL([BROAD_UDEVRULES], [$broad_udevrules])
  1400. dnl Find YASM
  1401. has_yasm=false
  1402. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  1403. AC_PATH_PROG([YASM],[yasm],[false])
  1404. if test "x$YASM" != "xfalse" ; then
  1405. has_yasm_enableaction="install yasm 1.0.1+"
  1406. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  1407. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  1408. yamajor=`echo $yasmver | cut -d. -f1`
  1409. yaminor=`echo $yasmver | cut -d. -f2`
  1410. yamini=`echo $yasmver | cut -d. -f3`
  1411. if test "$yamajor" -ge "1" ; then
  1412. if test "$yamajor" -eq "1" ; then
  1413. if test "$yaminor" -ge "0" ; then
  1414. if test "$yaminor" -eq "0"; then
  1415. if test "$yamini" -ge "1"; then
  1416. has_yasm=true
  1417. fi
  1418. else
  1419. has_yasm=true
  1420. fi
  1421. fi
  1422. fi
  1423. else
  1424. has_yasm=false
  1425. fi
  1426. if test "x$has_yasm" = "xtrue" ; then
  1427. AC_MSG_RESULT([yes])
  1428. else
  1429. AC_MSG_RESULT([no])
  1430. fi
  1431. fi
  1432. if test "x$has_yasm" = "xfalse" ; then
  1433. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  1434. else
  1435. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  1436. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  1437. if test "x$have_x86_64" = xtrue; then
  1438. YASM_FMT="win64"
  1439. else
  1440. YASM_FMT="coff"
  1441. fi
  1442. elif test "x$have_macho" = "xtrue"; then
  1443. YASM_FMT="macho$bitness"
  1444. else
  1445. YASM_FMT="elf$bitness"
  1446. fi
  1447. fi
  1448. fi
  1449. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  1450. have_sse2=no
  1451. if test "x$cpumining$have_x86_32" = "xyestrue"; then
  1452. AC_MSG_CHECKING([if SSE2 code compiles])
  1453. save_CFLAGS="$CFLAGS"
  1454. for flags in '' '-msse2'; do
  1455. CFLAGS="$CFLAGS $flags"
  1456. AC_TRY_LINK([
  1457. #include <xmmintrin.h>
  1458. ],[
  1459. int *i = (int *)0xdeadbeef;
  1460. __m128i a, b;
  1461. a = _mm_set1_epi32(i[0]);
  1462. b = _mm_set_epi32(i[0], i[1], i[2], i[3]);
  1463. a = _mm_add_epi32(a, b);
  1464. a = _mm_andnot_si128(a, b);
  1465. a = _mm_or_si128(a, b);
  1466. a = _mm_slli_epi32(a, i[4]);
  1467. a = _mm_and_si128(a, b);
  1468. a = _mm_xor_si128(a, b);
  1469. ],[
  1470. if test "x$flags" = "x"; then
  1471. AC_MSG_RESULT([yes])
  1472. else
  1473. AC_MSG_RESULT([with $flags])
  1474. fi
  1475. SSE2_CFLAGS="$flags"
  1476. have_sse2=yes
  1477. break
  1478. ],[
  1479. true
  1480. ])
  1481. done
  1482. CFLAGS="${save_CFLAGS}"
  1483. if test "x$have_sse2" = "xyes"; then
  1484. AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used])
  1485. else
  1486. AC_MSG_RESULT([no])
  1487. fi
  1488. fi
  1489. AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"])
  1490. if test "x$need_lowl_vcom" = "xyes"; then
  1491. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  1492. [libudev=$withval],
  1493. [libudev=auto]
  1494. )
  1495. if test "x$libudev" != "xno"; then
  1496. AC_CHECK_HEADER([libudev.h],[
  1497. libudev=yes
  1498. UDEV_LIBS=-ludev
  1499. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  1500. ], [
  1501. if test "x$libudev" = "xyes"; then
  1502. AC_MSG_ERROR([libudev not found])
  1503. fi
  1504. libudev=no
  1505. ])
  1506. fi
  1507. fi
  1508. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  1509. AC_SUBST(LIBUSB_LIBS)
  1510. AC_SUBST(LIBUSB_CFLAGS)
  1511. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  1512. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  1513. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  1514. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  1515. fi
  1516. AC_SUBST(LIBCURL_LIBS)
  1517. AC_CHECK_FUNCS([setrlimit])
  1518. dnl CCAN wants to know a lot of vars.
  1519. # All the configuration checks. Regrettably, the __attribute__ checks will
  1520. # give false positives on old GCCs, since they just cause warnings. But that's
  1521. # fairly harmless.
  1522. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  1523. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  1524. [Define if __attribute__((cold))]))
  1525. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  1526. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  1527. [Define if __attribute__((const))]))
  1528. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  1529. [
  1530. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  1531. [Define if __attribute__((noreturn))])
  1532. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  1533. ], [
  1534. AC_DEFINE_UNQUOTED([NORETURN], [])
  1535. ]
  1536. )
  1537. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  1538. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  1539. [Define if __attribute__((format(__printf__)))]))
  1540. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  1541. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  1542. [Define if __attribute__((unused))]))
  1543. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  1544. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  1545. [Define if __attribute__((used))]))
  1546. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  1547. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  1548. [Define if have __builtin_constant_p]))
  1549. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  1550. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  1551. [Define if have __builtin_types_compatible_p]))
  1552. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  1553. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  1554. [Define if __attribute__((warn_unused_result))]))
  1555. # byteswap functions
  1556. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  1557. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  1558. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  1559. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  1560. BSWAP=''
  1561. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  1562. AC_MSG_CHECKING([for ${sym}* functions])
  1563. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  1564. BFG_INCLUDE([headerinclude], [${headerfile}])
  1565. AC_LINK_IFELSE([
  1566. AC_LANG_PROGRAM([
  1567. ${headerinclude}
  1568. ], [
  1569. (void) ${sym}16(0);
  1570. (void) ${sym}32(0);
  1571. (void) ${sym}64(0);
  1572. ])
  1573. ], [
  1574. BSWAP="${sym}"
  1575. if test "x${headerfile}" = "x"; then
  1576. AC_MSG_RESULT([yes])
  1577. else
  1578. AC_MSG_RESULT([found in ${headerfile}])
  1579. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  1580. fi
  1581. break 2
  1582. ])
  1583. done
  1584. AC_MSG_RESULT([no])
  1585. done
  1586. if test "x$BSWAP" = "x"; then
  1587. true # Substitutes are provided in miner.h
  1588. elif test "x$BSWAP" = "xbswap_"; then
  1589. AC_MSG_CHECKING([if bswap_16 is already a macro])
  1590. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  1591. AC_MSG_RESULT([yes])
  1592. BSWAP=""
  1593. ],[
  1594. AC_MSG_RESULT([no])
  1595. ])
  1596. fi
  1597. if test "x$BSWAP" != "x"; then
  1598. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  1599. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  1600. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  1601. fi
  1602. # endian definition macros
  1603. AC_MSG_CHECKING([for platform endian])
  1604. found_endian=no
  1605. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  1606. for pfx in '' '__'; do
  1607. 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}, [
  1608. if test "x$headerfile" = "x"; then
  1609. headerfilec=''
  1610. else
  1611. headerfilec=" (${headerfile})"
  1612. fi
  1613. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  1614. AC_MSG_RESULT([big endian${headerfilec}])
  1615. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  1616. ], [
  1617. AC_MSG_RESULT([little endian${headerfilec}])
  1618. ])
  1619. found_endian=yes
  1620. break 2
  1621. ],[true])
  1622. done
  1623. done
  1624. if test "x$found_endian" = "xno"; then
  1625. if $have_win32 || $have_cygwin; then
  1626. AC_MSG_RESULT([assuming little endian (Windows)])
  1627. else
  1628. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  1629. AC_MSG_RESULT([unknown])
  1630. AC_MSG_ERROR([Unable to identify platform endian])
  1631. fi
  1632. fi
  1633. AC_MSG_CHECKING([if good static asserts compile])
  1634. AC_TRY_LINK([
  1635. #include <stddef.h>
  1636. ], [
  1637. _Static_assert(1, ":)");
  1638. ], [
  1639. AC_MSG_RESULT([yes])
  1640. ], [
  1641. AC_MSG_RESULT([no])
  1642. AC_DEFINE_UNQUOTED([_Static_assert(...)], [], [Turns _Static_assert into noop for compilers that don't support it])
  1643. ])
  1644. AC_MSG_CHECKING([if GNU format attribute compiles])
  1645. AC_TRY_COMPILE([
  1646. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  1647. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  1648. int myfunc(char *fmt, ...) {
  1649. return 42;
  1650. }
  1651. ], [
  1652. myfunc("abc%d", 42);
  1653. ], [
  1654. AC_MSG_RESULT([yes])
  1655. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  1656. ], [
  1657. AC_MSG_RESULT([no])
  1658. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  1659. ])
  1660. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC)])
  1661. AC_TRY_COMPILE([
  1662. #define _GNU_SOURCE
  1663. #include <time.h>
  1664. ],[
  1665. struct timespec ts;
  1666. clock_gettime(CLOCK_MONOTONIC, &ts);
  1667. ],[
  1668. AC_MSG_RESULT([yes])
  1669. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC) is defined])
  1670. save_LIBS="${LIBS}"
  1671. AC_SEARCH_LIBS([clock_gettime],[rt posix4],[
  1672. if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then
  1673. RT_LIBS="${ac_cv_search_clock_gettime}"
  1674. fi
  1675. ])
  1676. LIBS="${save_LIBS}"
  1677. AC_CHECK_FUNCS([clock_nanosleep])
  1678. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC_RAW)])
  1679. AC_TRY_COMPILE([
  1680. #define _GNU_SOURCE
  1681. #include <time.h>
  1682. ],[
  1683. struct timespec ts;
  1684. clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  1685. ],[
  1686. AC_MSG_RESULT([yes])
  1687. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC_RAW], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC_RAW) is defined])
  1688. ],[
  1689. AC_MSG_RESULT([no])
  1690. ])
  1691. ],[
  1692. AC_MSG_RESULT([no])
  1693. ])
  1694. save_LIBS="$LIBS"
  1695. LIBS="$LIBS $MATH_LIBS"
  1696. AC_CHECK_FUNCS([log2])
  1697. LIBS="$save_LIBS"
  1698. if test "x$prefix" = xNONE; then
  1699. prefix=/usr/local
  1700. fi
  1701. AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono])
  1702. m4_define([BFG_PRINT_LIST],[
  1703. eval _mylist="\$$2"
  1704. _yeslist=
  1705. _nolist=
  1706. _enableactions=
  1707. for _opt in $_mylist; do
  1708. IFS=/ read _opt _var <<EOF
  1709. $_opt
  1710. EOF
  1711. test -n "$_var" || _var="$_opt"
  1712. eval "_val=\"\$${_var}\""
  1713. if test "x$_val" = "xno" || test "x$_val" = "xfalse"; then
  1714. _nolist="$_nolist $_opt"
  1715. eval "_enableaction=\"\$${_var}_enableaction\""
  1716. if test -n "$_enableaction"; then
  1717. _enableactions="${_enableactions}~ To enable ${_opt}, ${_enableaction}"
  1718. fi
  1719. else
  1720. _yeslist="$_yeslist $_opt"
  1721. fi
  1722. done
  1723. _yeslist=`echo "$_yeslist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1724. _nolist=`echo "$_nolist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1725. AC_DEFINE_UNQUOTED(AS_TR_CPP([BFG_$2]),["$_yeslist"],[List of drivers being built])
  1726. $2_print=" Enabled..$1..:${_yeslist}~ Disabled.$1..:${_nolist}${_enableactions}"
  1727. ])
  1728. BFG_PRINT_LIST([Lowlevel..],[lowllist])
  1729. BFG_PRINT_LIST([Drivers...],[driverlist])
  1730. BFG_PRINT_LIST([Algorithms],[algolist])
  1731. BFG_PRINT_LIST([Options...],[optlist])
  1732. AC_SUBST(AUTOSCAN_CPPFLAGS)
  1733. AC_SUBST(AUTOSCAN_LIBS)
  1734. AC_SUBST(PTHREAD_FLAGS)
  1735. AC_SUBST(DLOPEN_FLAGS)
  1736. AC_SUBST(PTHREAD_LIBS)
  1737. AC_SUBST(NCURSES_CPPFLAGS)
  1738. AC_SUBST(NCURSES_LIBS)
  1739. AC_SUBST(PDCURSES_LIBS)
  1740. AC_SUBST(WS2_LIBS)
  1741. AC_SUBST(MM_LIBS)
  1742. AC_SUBST(MATH_LIBS)
  1743. AC_SUBST(RT_LIBS)
  1744. AC_SUBST(UDEV_LIBS)
  1745. AC_SUBST(SSE2_CFLAGS)
  1746. AC_SUBST(YASM_FMT)
  1747. AC_CONFIG_FILES([
  1748. Makefile
  1749. x86_64/Makefile
  1750. x86_32/Makefile
  1751. ccan.bfg/Makefile
  1752. lib/Makefile
  1753. ])
  1754. if $use_udevrules; then
  1755. AC_CONFIG_FILES([70-bfgminer.rules])
  1756. fi
  1757. AC_OUTPUT
  1758. BFG_CUSTOM_SUBDIRS_OUTPUT
  1759. wordfilter ()
  1760. {
  1761. echo "$1" | sed 's/ \+/ /g;s/^ *//;s/ *$//'
  1762. }
  1763. echo
  1764. echo "------------------------------------------------------------------------"
  1765. echo "$PACKAGE $VERSION configuration options summary"
  1766. echo "------------------------------------------------------------------------"
  1767. echo
  1768. echo " CFLAGS...............: "`wordfilter "$CPPFLAGS $AUTOSCAN_CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libbase58_CFLAGS $libblkmaker_CFLAGS $hidapi_CFLAGS"`
  1769. echo " LDFLAGS..............: "`wordfilter "$LDFLAGS $AUTOSCAN_LIBS $PTHREAD_FLAGS $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 $libbase58_LIBS $libblkmaker_LIBS"`
  1770. echo " Installation.prefix..: $prefix"
  1771. echo
  1772. echo "${lowllist_print}" | tr '~' '\n'
  1773. echo "${driverlist_print}" | tr '~' '\n'
  1774. echo "${algolist_print}" | tr '~' '\n'
  1775. echo "${optlist_print}" | tr '~' '\n'
  1776. echo