configure.ac 48 KB

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