configure.ac 54 KB

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