configure.ac 50 KB

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