configure.ac 51 KB

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