configure.ac 40 KB

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