configure.ac 41 KB

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