configure.ac 40 KB

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