configure.ac 41 KB

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