configure.ac 51 KB

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