configure.ac 52 KB

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