configure.ac 40 KB

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