configure.ac 50 KB

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