configure.ac 40 KB

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