configure.ac 42 KB

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