configure.ac 39 KB

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