configure.ac 50 KB

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