configure.ac 57 KB

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