configure.ac 52 KB

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