configure.ac 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  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], [8])
  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 | sed -E -e 's/^[^:]+:[[:space:]]*(([^[:space:]]|\\\\[[:space:]])*)libusb\\.h([[:space:]].*|$)$/\\1/' -e 't my' -e d -e ': my' -e 's/\\\\?([\\\\[:space:]])/\\\\\\1/g'`
  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 Nano (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 Nano support])
  715. fi
  716. fi
  717. elif test "x$hashbuster" = "xyes"; then
  718. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled HashBuster Nano])
  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 Nano 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 hashbuster2"
  729. AC_ARG_ENABLE([hashbuster2],
  730. [AC_HELP_STRING([--disable-hashbuster2],[Compile support for HashBuster Micro (default if libusb)])],
  731. [hashbuster2=$enableval],
  732. [hashbuster2=auto]
  733. )
  734. if test "x$hashbuster2$want_libusb" = xyesno; then
  735. AC_MSG_ERROR([You disabled libusb, required for HashBuster Micro support])
  736. elif test "x$hashbuster2$libusb" = xyesno; then
  737. AC_MSG_ERROR([Could not find libusb, required for HashBuster Micro support])
  738. elif test "x$hashbuster2" = xauto; then
  739. hashbuster2="$libusb"
  740. if test "x$libusb" = xno; then
  741. AC_MSG_WARN([Could not find libusb, required for HashBuster Micro support])
  742. hashbuster2_enableaction="install libusb 1.0+"
  743. fi
  744. fi
  745. if test "x$hashbuster2" = xyes; then
  746. AC_DEFINE([USE_HASHBUSTER2], [1], [Defined to 1 if HashBuster Micro support is wanted])
  747. need_lowl_usb=yes
  748. has_asic=yes
  749. fi
  750. AM_CONDITIONAL([USE_HASHBUSTER2], [test x$hashbuster2 = xyes])
  751. driverlist="$driverlist metabank"
  752. metabank=no
  753. AC_ARG_ENABLE([metabank],
  754. [AC_HELP_STRING([--enable-metabank],[Compile support for Metabank (default disabled)])],
  755. [metabank=$enableval]
  756. )
  757. if test "x$metabank" = "xyes"; then
  758. if test "x$bitfury" = "xno"; then
  759. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Metabank])
  760. fi
  761. AC_DEFINE([USE_METABANK], [1], [Defined to 1 if Metabank support is wanted])
  762. fi
  763. AM_CONDITIONAL([HAS_METABANK], [test x$metabank = xyes])
  764. if test "x$need_lowl_vcom" != "xno"; then
  765. # Lowlevel VCOM doesn't need libusb, but it can take advantage of it to reattach drivers
  766. need_lowl_usb=yes
  767. fi
  768. if test "x$need_lowl_usb" = "xno"; then
  769. libusb=no
  770. LIBUSB_LIBS=''
  771. LIBUSB_CFLAGS=''
  772. fi
  773. if test "x$libusb" = xyes; then
  774. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  775. save_CFLAGS="$CFLAGS"
  776. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  777. AC_CHECK_DECLS([libusb_error_name],[true],[true],[#include <libusb.h>])
  778. CFLAGS="$save_CFLAGS"
  779. fi
  780. algolist="$algolist scrypt"
  781. scrypt="no"
  782. AC_ARG_ENABLE([scrypt],
  783. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  784. [scrypt=$enableval]
  785. )
  786. if test "x$scrypt" = xyes; then
  787. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  788. fi
  789. if test x$need_lowl_vcom = xyes; then
  790. AC_DEFINE([NEED_BFG_LOWL_VCOM], [1], [Defined to 1 if lowlevel VCOM drivers are being used])
  791. need_lowlevel=yes
  792. if $have_win32; then
  793. echo '#include <iospeeds.h>' >iospeeds_local.h
  794. found_ddkusb=false
  795. AC_CHECK_HEADER([usbiodef.h],[
  796. found_ddkusb=true
  797. ],[
  798. AC_CHECK_HEADER([ddk/usbiodef.h],[
  799. found_ddkusb=true
  800. AUTOSCAN_CPPFLAGS="-I"`echo '#include <ddk/usbiodef.h>' | ${CPP} -M - 2>/dev/null | sed -E -e 's/^[^:]+:[[:space:]]*(([^[:space:]]|\\\\[[:space:]])*)usbiodef\\.h([[:space:]].*|$)$/\\1/' -e 't my' -e d -e ': my' -e 's/\\\\?([\\\\[:space:]])/\\\\\\1/g'`
  801. ],[
  802. true
  803. ],[
  804. #include <windows.h>
  805. #include <ddk/usbioctl.h>
  806. AC_INCLUDES_DEFAULT
  807. ])
  808. ],[
  809. #include <windows.h>
  810. #include <usbioctl.h>
  811. AC_INCLUDES_DEFAULT
  812. ])
  813. if $found_ddkusb; then
  814. AUTOSCAN_LIBS="-lsetupapi"
  815. AC_DEFINE([HAVE_WIN_DDKUSB],[1],[Defined to 1 if Windows DDK USB headers are being used])
  816. fi
  817. else
  818. AC_MSG_CHECKING([what baud rates your system supports])
  819. echo '#include <termios.h>' | ${CPP} -dM - 2>/dev/null | sed 's/.*[ ]B\([0-9][0-9]*\)[ ].*/IOSPEED(\1)/' | grep IOSPEED >iospeeds_local.h
  820. if grep -q IOSPEED iospeeds_local.h; then
  821. AC_MSG_RESULT([done])
  822. else
  823. AC_MSG_RESULT([failed, using standard POSIX])
  824. echo '#include <iospeeds_posix.h>' >iospeeds_local.h
  825. fi
  826. fi
  827. fi
  828. if test "x$opencl$need_lowl_hid" = xnono; then
  829. DLOPEN_FLAGS=""
  830. fi
  831. if test x$need_lowl_hid = xyes; then
  832. AC_DEFINE([NEED_BFG_LOWL_HID], [1], [Defined to 1 if lowlevel hid drivers are being used])
  833. need_lowlevel=yes
  834. fi
  835. if test x$need_lowl_usb = xyes; then
  836. need_lowlevel=yes
  837. fi
  838. if test x$need_lowl_vcom = xyes; then
  839. need_lowlevel=yes
  840. fi
  841. if test x$need_lowlevel = xyes; then
  842. AC_DEFINE([HAVE_BFG_LOWLEVEL], [1], [Defined to 1 if lowlevel drivers are being used])
  843. fi
  844. curses="auto"
  845. AC_ARG_WITH([curses],
  846. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  847. [curses=$withval]
  848. )
  849. if test "x$curses" = "xno"; then
  850. optlist="$optlist curses"
  851. else
  852. curses_enableaction="install a curses library"
  853. orig_libs="$LIBS"
  854. if test "x${curses}" = "xyes"; then
  855. preferl=''
  856. else
  857. preferl="${curses} ${curses}6 ${curses}5"
  858. fi
  859. for wideornot in w u ''; do
  860. for ncursesver in '' 6 5; do
  861. preferl="${preferl} ncurses${wideornot}${ncursesver}"
  862. done
  863. preferl="${preferl} pdcurses${wideornot}"
  864. done
  865. if test "x$cross_compiling" != "xyes"; then
  866. AC_MSG_CHECKING([for best native curses library])
  867. orig_cflags="$CFLAGS"
  868. for curses_lib in ${preferl}; do
  869. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  870. continue
  871. fi
  872. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  873. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  874. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  875. #include <curses.h>
  876. ]], [[
  877. WINDOW *w = NULL;
  878. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  879. ]])], [
  880. curses=yes
  881. optlist="$optlist ${curses_lib}/curses"
  882. AC_MSG_RESULT([$curses_lib])
  883. NCURSES_LIBS=`${curses_lib}-config --libs`
  884. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  885. break
  886. ], [
  887. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  888. ])
  889. done
  890. CFLAGS="$orig_cflags"
  891. if test "x$curses" != "xyes"; then
  892. AC_MSG_RESULT([none?])
  893. fi
  894. fi
  895. if test "x$curses" != "xyes"; then
  896. sym=addstr
  897. AC_SEARCH_LIBS(${sym}, ${preferl}, [
  898. curses=yes
  899. eval "curseslib=\"\${ac_cv_search_${sym}}\""
  900. barelib="${curseslib/-l/}"
  901. optlist="$optlist ${barelib}/curses"
  902. if test "x${curseslib}" != "xnone required"; then
  903. NCURSES_LIBS="${curseslib}"
  904. fi
  905. # Need to check for headers in subdirectories, to ensure we get wide stuff
  906. AC_MSG_CHECKING([for curses header subdirectory])
  907. barelib="${barelib/6/}"
  908. barelib="${barelib/5/}"
  909. cursesincl=`echo '#include <'"${barelib}"'/curses.h>' | ${CPP} -M - 2>/dev/null | sed -E -e 's/^[^:]+:[[:space:]]*(([^[:space:]]|\\\\[[:space:]])*)curses\\.h([[:space:]].*|$)$/\\1/' -e 't my' -e d -e ': my' -e 's/\\\\?([\\\\[:space:]])/\\\\\\1/g'`
  910. if test "x$cursesincl" != "x"; then
  911. NCURSES_CPPFLAGS="-I${cursesincl}"
  912. AC_MSG_RESULT([$cursesincl])
  913. else
  914. AC_MSG_RESULT([none found])
  915. fi
  916. break
  917. ], [
  918. if test "x$curses" = "xyes"; then
  919. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  920. else
  921. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  922. curses=no
  923. optlist="$optlist curses"
  924. fi
  925. ])
  926. fi
  927. if test "x$curses" = "xyes"; then
  928. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  929. AC_MSG_CHECKING([whether curses library supports wide characters])
  930. LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS"
  931. AC_LINK_IFELSE([
  932. AC_LANG_PROGRAM([
  933. #define PDC_WIDE
  934. #include <curses.h>
  935. ],[
  936. addwstr(L"test");
  937. add_wch(WACS_VLINE);
  938. ])
  939. ],[
  940. AC_MSG_RESULT([yes])
  941. AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters])
  942. ],[
  943. AC_MSG_RESULT([no])
  944. ])
  945. fi
  946. LIBS="$orig_libs"
  947. fi
  948. maybe_ldconfig=
  949. 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])
  950. if test "x$with_system_libblkmaker" = "xyes"; then
  951. PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
  952. true
  953. ],[
  954. AC_MSG_ERROR([Could not find system libblkmaker])
  955. ])
  956. else
  957. save_LDFLAGS="$LDFLAGS"
  958. LDFLAGS="$LDFLAGS -Wl,-zorigin"
  959. origin_LDFLAGS=
  960. AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
  961. AC_TRY_LINK([],[],[
  962. AC_MSG_RESULT([yes])
  963. origin_LDFLAGS=',-zorigin'
  964. ],[
  965. AC_MSG_RESULT([no])
  966. ])
  967. LDFLAGS="$save_LDFLAGS"
  968. libblkmaker_CFLAGS='-Ilibblkmaker'
  969. libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS"
  970. libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
  971. AC_CONFIG_SUBDIRS([libblkmaker])
  972. _ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g`
  973. possible_ldconfigs="${target}-ldconfig"
  974. if test "x$cross_compiling" != "xyes"; then
  975. possible_ldconfigs="${possible_ldconfigs} ldconfig"
  976. fi
  977. AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH])
  978. if test "x$LDCONFIG" != "x"; then
  979. maybe_ldconfig=" && $LDCONFIG"
  980. fi
  981. fi
  982. AC_SUBST(libblkmaker_CFLAGS)
  983. AC_SUBST(libblkmaker_LDFLAGS)
  984. AC_SUBST(libblkmaker_LIBS)
  985. AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
  986. AM_CONDITIONAL([NEED_BFG_BINLOADER], [test x$need_binloader = xyes])
  987. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes])
  988. AM_CONDITIONAL([NEED_BFG_LOWL_VCOM], [test x$need_lowl_vcom = xyes])
  989. AM_CONDITIONAL([NEED_BFG_LOWL_HID], [test x$need_lowl_hid = xyes])
  990. AM_CONDITIONAL([NEED_BFG_LOWLEVEL], [test x$need_lowlevel = xyes])
  991. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  992. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  993. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  994. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  995. AM_CONDITIONAL([HAVE_LIBUSB], [test x$libusb = xyes])
  996. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  997. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  998. AM_CONDITIONAL([HAVE_WIN_DDKUSB], [test x$found_ddkusb = xtrue])
  999. AM_CONDITIONAL([HAS_FPGA], [test x$has_fpga != xno])
  1000. AM_CONDITIONAL([HAS_ASIC], [test x$has_asic != xno])
  1001. dnl Find YASM
  1002. has_yasm=false
  1003. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  1004. AC_PATH_PROG([YASM],[yasm],[false])
  1005. if test "x$YASM" != "xfalse" ; then
  1006. has_yasm_enableaction="install yasm 1.0.1+"
  1007. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  1008. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  1009. yamajor=`echo $yasmver | cut -d. -f1`
  1010. yaminor=`echo $yasmver | cut -d. -f2`
  1011. yamini=`echo $yasmver | cut -d. -f3`
  1012. if test "$yamajor" -ge "1" ; then
  1013. if test "$yamajor" -eq "1" ; then
  1014. if test "$yaminor" -ge "0" ; then
  1015. if test "$yaminor" -eq "0"; then
  1016. if test "$yamini" -ge "1"; then
  1017. has_yasm=true
  1018. fi
  1019. else
  1020. has_yasm=true
  1021. fi
  1022. fi
  1023. fi
  1024. else
  1025. has_yasm=false
  1026. fi
  1027. if test "x$has_yasm" = "xtrue" ; then
  1028. AC_MSG_RESULT([yes])
  1029. else
  1030. AC_MSG_RESULT([no])
  1031. fi
  1032. fi
  1033. if test "x$has_yasm" = "xfalse" ; then
  1034. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  1035. else
  1036. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  1037. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  1038. if test "x$have_x86_64" = xtrue; then
  1039. YASM_FMT="win64"
  1040. else
  1041. YASM_FMT="coff"
  1042. fi
  1043. elif test "x$have_macho" = "xtrue"; then
  1044. YASM_FMT="macho$bitness"
  1045. else
  1046. YASM_FMT="elf$bitness"
  1047. fi
  1048. fi
  1049. fi
  1050. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  1051. have_sse2=no
  1052. if test "x$cpumining$have_x86_32" = "xyestrue"; then
  1053. AC_MSG_CHECKING([if SSE2 code compiles])
  1054. save_CFLAGS="$CFLAGS"
  1055. for flags in '' '-msse2'; do
  1056. CFLAGS="$CFLAGS $flags"
  1057. AC_TRY_LINK([
  1058. #include <xmmintrin.h>
  1059. ],[
  1060. int *i = (int *)0xdeadbeef;
  1061. __m128i a, b;
  1062. a = _mm_set1_epi32(i[0]);
  1063. b = _mm_set_epi32(i[0], i[1], i[2], i[3]);
  1064. a = _mm_add_epi32(a, b);
  1065. a = _mm_andnot_si128(a, b);
  1066. a = _mm_or_si128(a, b);
  1067. a = _mm_slli_epi32(a, i[4]);
  1068. a = _mm_and_si128(a, b);
  1069. a = _mm_xor_si128(a, b);
  1070. ],[
  1071. if test "x$flags" = "x"; then
  1072. AC_MSG_RESULT([yes])
  1073. else
  1074. AC_MSG_RESULT([with $flags])
  1075. fi
  1076. SSE2_CFLAGS="$flags"
  1077. have_sse2=yes
  1078. break
  1079. ],[
  1080. true
  1081. ])
  1082. done
  1083. CFLAGS="${save_CFLAGS}"
  1084. if test "x$have_sse2" = "xyes"; then
  1085. AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used])
  1086. else
  1087. AC_MSG_RESULT([no])
  1088. fi
  1089. fi
  1090. AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"])
  1091. if test "x$need_lowl_vcom" = "xyes"; then
  1092. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  1093. [libudev=$withval],
  1094. [libudev=auto]
  1095. )
  1096. if test "x$libudev" != "xno"; then
  1097. AC_CHECK_HEADER([libudev.h],[
  1098. libudev=yes
  1099. UDEV_LIBS=-ludev
  1100. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  1101. ], [
  1102. if test "x$libudev" = "xyes"; then
  1103. AC_MSG_ERROR([libudev not found])
  1104. fi
  1105. libudev=no
  1106. ])
  1107. fi
  1108. fi
  1109. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  1110. AC_SUBST(LIBUSB_LIBS)
  1111. AC_SUBST(LIBUSB_CFLAGS)
  1112. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  1113. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  1114. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  1115. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  1116. fi
  1117. AC_SUBST(LIBCURL_LIBS)
  1118. AC_CHECK_FUNCS([setrlimit])
  1119. dnl CCAN wants to know a lot of vars.
  1120. # All the configuration checks. Regrettably, the __attribute__ checks will
  1121. # give false positives on old GCCs, since they just cause warnings. But that's
  1122. # fairly harmless.
  1123. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  1124. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  1125. [Define if __attribute__((cold))]))
  1126. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  1127. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  1128. [Define if __attribute__((const))]))
  1129. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  1130. [
  1131. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  1132. [Define if __attribute__((noreturn))])
  1133. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  1134. ], [
  1135. AC_DEFINE_UNQUOTED([NORETURN], [])
  1136. ]
  1137. )
  1138. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  1139. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  1140. [Define if __attribute__((format(__printf__)))]))
  1141. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  1142. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  1143. [Define if __attribute__((unused))]))
  1144. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  1145. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  1146. [Define if __attribute__((used))]))
  1147. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  1148. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  1149. [Define if have __builtin_constant_p]))
  1150. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  1151. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  1152. [Define if have __builtin_types_compatible_p]))
  1153. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  1154. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  1155. [Define if __attribute__((warn_unused_result))]))
  1156. # byteswap functions
  1157. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  1158. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  1159. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  1160. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  1161. BSWAP=''
  1162. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  1163. AC_MSG_CHECKING([for ${sym}* functions])
  1164. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  1165. BFG_INCLUDE([headerinclude], [${headerfile}])
  1166. AC_LINK_IFELSE([
  1167. AC_LANG_PROGRAM([
  1168. ${headerinclude}
  1169. ], [
  1170. (void) ${sym}16(0);
  1171. (void) ${sym}32(0);
  1172. (void) ${sym}64(0);
  1173. ])
  1174. ], [
  1175. BSWAP="${sym}"
  1176. if test "x${headerfile}" = "x"; then
  1177. AC_MSG_RESULT([yes])
  1178. else
  1179. AC_MSG_RESULT([found in ${headerfile}])
  1180. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  1181. fi
  1182. break 2
  1183. ])
  1184. done
  1185. AC_MSG_RESULT([no])
  1186. done
  1187. if test "x$BSWAP" = "x"; then
  1188. true # Substitutes are provided in miner.h
  1189. elif test "x$BSWAP" = "xbswap_"; then
  1190. AC_MSG_CHECKING([if bswap_16 is already a macro])
  1191. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  1192. AC_MSG_RESULT([yes])
  1193. BSWAP=""
  1194. ],[
  1195. AC_MSG_RESULT([no])
  1196. ])
  1197. fi
  1198. if test "x$BSWAP" != "x"; then
  1199. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  1200. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  1201. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  1202. fi
  1203. # endian definition macros
  1204. AC_MSG_CHECKING([for platform endian])
  1205. found_endian=no
  1206. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  1207. for pfx in '' '__'; do
  1208. 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}, [
  1209. if test "x$headerfile" = "x"; then
  1210. headerfilec=''
  1211. else
  1212. headerfilec=" (${headerfile})"
  1213. fi
  1214. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  1215. AC_MSG_RESULT([big endian${headerfilec}])
  1216. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  1217. ], [
  1218. AC_MSG_RESULT([little endian${headerfilec}])
  1219. ])
  1220. found_endian=yes
  1221. break 2
  1222. ],[true])
  1223. done
  1224. done
  1225. if test "x$found_endian" = "xno"; then
  1226. if $have_win32 || $have_cygwin; then
  1227. AC_MSG_RESULT([assuming little endian (Windows)])
  1228. else
  1229. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  1230. AC_MSG_RESULT([unknown])
  1231. AC_MSG_ERROR([Unable to identify platform endian])
  1232. fi
  1233. fi
  1234. AC_MSG_CHECKING([if GNU format attribute compiles])
  1235. AC_TRY_COMPILE([
  1236. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  1237. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  1238. int myfunc(char *fmt, ...) {
  1239. return 42;
  1240. }
  1241. ], [
  1242. myfunc("abc%d", 42);
  1243. ], [
  1244. AC_MSG_RESULT([yes])
  1245. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  1246. ], [
  1247. AC_MSG_RESULT([no])
  1248. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  1249. ])
  1250. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC)])
  1251. AC_TRY_COMPILE([
  1252. #define _GNU_SOURCE
  1253. #include <time.h>
  1254. ],[
  1255. struct timespec ts;
  1256. clock_gettime(CLOCK_MONOTONIC, &ts);
  1257. ],[
  1258. AC_MSG_RESULT([yes])
  1259. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC) is defined])
  1260. save_LIBS="${LIBS}"
  1261. AC_SEARCH_LIBS([clock_gettime],[rt posix4],[
  1262. if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then
  1263. RT_LIBS="${ac_cv_search_clock_gettime}"
  1264. fi
  1265. ])
  1266. LIBS="${save_LIBS}"
  1267. AC_CHECK_FUNCS([clock_nanosleep])
  1268. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC_RAW)])
  1269. AC_TRY_COMPILE([
  1270. #define _GNU_SOURCE
  1271. #include <time.h>
  1272. ],[
  1273. struct timespec ts;
  1274. clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  1275. ],[
  1276. AC_MSG_RESULT([yes])
  1277. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC_RAW], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC_RAW) is defined])
  1278. ],[
  1279. AC_MSG_RESULT([no])
  1280. ])
  1281. ],[
  1282. AC_MSG_RESULT([no])
  1283. ])
  1284. if test "x$prefix" = xNONE; then
  1285. prefix=/usr/local
  1286. fi
  1287. AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono])
  1288. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel])
  1289. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel])
  1290. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel])
  1291. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel])
  1292. AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
  1293. m4_define([BFG_PRINT_LIST],[
  1294. eval _mylist="\$$2"
  1295. _yeslist=
  1296. _nolist=
  1297. _enableactions=
  1298. for _opt in $_mylist; do
  1299. IFS=/ read _opt _var <<EOF
  1300. $_opt
  1301. EOF
  1302. test -n "$_var" || _var="$_opt"
  1303. eval "_val=\"\$${_var}\""
  1304. if test "x$_val" = "xno" || test "x$_val" = "xfalse"; then
  1305. _nolist="$_nolist $_opt"
  1306. eval "_enableaction=\"\$${_var}_enableaction\""
  1307. if test -n "$_enableaction"; then
  1308. _enableactions="${_enableactions}~ To enable ${_opt}, ${_enableaction}"
  1309. fi
  1310. else
  1311. _yeslist="$_yeslist $_opt"
  1312. fi
  1313. done
  1314. _yeslist=`echo "$_yeslist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1315. _nolist=`echo "$_nolist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1316. AC_DEFINE_UNQUOTED(AS_TR_CPP([BFG_$2]),["$_yeslist"],[List of drivers being built])
  1317. $2_print=" Enabled..$1..:${_yeslist}~ Disabled.$1..:${_nolist}${_enableactions}"
  1318. ])
  1319. BFG_PRINT_LIST([Drivers...],[driverlist])
  1320. BFG_PRINT_LIST([Algorithms],[algolist])
  1321. BFG_PRINT_LIST([Options...],[optlist])
  1322. AC_SUBST(AUTOSCAN_CPPFLAGS)
  1323. AC_SUBST(AUTOSCAN_LIBS)
  1324. AC_SUBST(PTHREAD_FLAGS)
  1325. AC_SUBST(DLOPEN_FLAGS)
  1326. AC_SUBST(PTHREAD_LIBS)
  1327. AC_SUBST(NCURSES_CPPFLAGS)
  1328. AC_SUBST(NCURSES_LIBS)
  1329. AC_SUBST(PDCURSES_LIBS)
  1330. AC_SUBST(WS2_LIBS)
  1331. AC_SUBST(MM_LIBS)
  1332. AC_SUBST(MATH_LIBS)
  1333. AC_SUBST(RT_LIBS)
  1334. AC_SUBST(UDEV_LIBS)
  1335. AC_SUBST(SSE2_CFLAGS)
  1336. AC_SUBST(YASM_FMT)
  1337. AC_CONFIG_FILES([
  1338. Makefile
  1339. x86_64/Makefile
  1340. x86_32/Makefile
  1341. ccan/Makefile
  1342. lib/Makefile
  1343. ])
  1344. AC_OUTPUT
  1345. wordfilter ()
  1346. {
  1347. echo "$1" | sed 's/ \+/ /g;s/^ *//;s/ *$//'
  1348. }
  1349. echo
  1350. echo "------------------------------------------------------------------------"
  1351. echo "$PACKAGE $VERSION configuration options summary"
  1352. echo "------------------------------------------------------------------------"
  1353. echo
  1354. echo " CFLAGS...............: "`wordfilter "$CPPFLAGS $AUTOSCAN_CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libblkmaker_CFLAGS $hidapi_CFLAGS"`
  1355. 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"`
  1356. echo " Installation.prefix..: $prefix"
  1357. echo
  1358. echo "${driverlist_print}" | tr '~' '\n'
  1359. echo "${algolist_print}" | tr '~' '\n'
  1360. echo "${optlist_print}" | tr '~' '\n'
  1361. echo