configure.ac 40 KB

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