configure.ac 38 KB

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