configure.ac 49 KB

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