configure.ac 41 KB

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