configure.ac 50 KB

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