configure.ac 36 KB

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