configure.ac 48 KB

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