configure.ac 41 KB

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