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_FOREACH_SAFE],[
  169. true
  170. ],[
  171. AC_MSG_ERROR([Could not find DL_FOREACH_SAFE - install uthash-dev 1.9.2+])
  172. ],[
  173. #include <utlist.h>
  174. ])
  175. ],[
  176. AC_MSG_ERROR([Could not find HASH_ITER - please install uthash-dev 1.9.2+])
  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. AC_ARG_WITH([libusb],
  450. [AC_HELP_STRING([--without-libusb],[Compile using libusb (default enabled)])],
  451. [want_libusb=$withval],
  452. [want_libusb=yes]
  453. )
  454. if test "x$want_libusb" = "xyes"; then
  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. true
  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. fi
  482. driverlist="$driverlist klondike"
  483. AC_ARG_ENABLE([klondike],
  484. [AC_HELP_STRING([--enable-klondike],[Compile support for Klondike (default disabled)])],
  485. [klondike=$enableval],
  486. [klondike=auto]
  487. )
  488. if test "x$klondike$want_libusb" = xyesno; then
  489. AC_MSG_ERROR([You disabled libusb, required for Klondike support])
  490. elif test "x$klondike$libusb" = xyesno; then
  491. AC_MSG_ERROR([Could not find libusb, required for Klondike support])
  492. elif test "x$klondike" = xauto; then
  493. klondike="$libusb"
  494. if test "x$libusb" = xno; then
  495. AC_MSG_WARN([Could not find libusb, required for Klondike support])
  496. klondike_enableaction="install libusb 1.0+"
  497. fi
  498. fi
  499. if test "x$klondike" = xyes; then
  500. AC_DEFINE([USE_KLONDIKE], [1], [Defined to 1 if Klondike support is wanted])
  501. need_lowl_usb=yes
  502. has_asic=yes
  503. fi
  504. AM_CONDITIONAL([HAS_KLONDIKE], [test x$klondike = xyes])
  505. driverlist="$driverlist x6500"
  506. AC_ARG_ENABLE([x6500],
  507. [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])],
  508. [x6500=$enableval],
  509. [x6500=auto]
  510. )
  511. if test "x$x6500$want_libusb" = xyesno; then
  512. AC_MSG_ERROR([You disabled libusb, required for X6500 support])
  513. elif test "x$x6500$libusb" = xyesno; then
  514. AC_MSG_ERROR([Could not find libusb, required for X6500 support])
  515. elif test "x$x6500" = xauto; then
  516. x6500="$libusb"
  517. if test "x$libusb" = xno; then
  518. AC_MSG_WARN([Could not find libusb, required for X6500 support])
  519. x6500_enableaction="install libusb 1.0+"
  520. fi
  521. fi
  522. if test "x$x6500" = xyes; then
  523. AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted])
  524. need_dynclock=yes
  525. need_lowl_usb=yes
  526. need_binloader=yes
  527. has_fpga=yes
  528. fi
  529. AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes])
  530. driverlist="$driverlist ztex"
  531. AC_ARG_ENABLE([ztex],
  532. [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])],
  533. [ztex=$enableval],
  534. [ztex=auto]
  535. )
  536. if test "x$ztex$want_libusb" = xyesno; then
  537. AC_MSG_ERROR([You disabled libusb, required for ZTEX support])
  538. elif test "x$ztex$libusb" = xyesno; then
  539. AC_MSG_ERROR([Could not find libusb, required for ZTEX support])
  540. elif test "x$ztex" = xauto; then
  541. ztex="$libusb"
  542. if test "x$libusb" = xno; then
  543. AC_MSG_WARN([Could not find libusb, required for ZTEX support])
  544. ztex_enableaction="install libusb 1.0+"
  545. fi
  546. fi
  547. if test "x$ztex" = xyes; then
  548. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted])
  549. need_dynclock=yes
  550. need_lowl_usb=yes
  551. need_binloader=yes
  552. has_fpga=yes
  553. fi
  554. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  555. driverlist="$driverlist bitfury_gpio/bitfury"
  556. bitfury=yes
  557. AC_ARG_ENABLE([bitfury],
  558. [AC_HELP_STRING([--disable-bitfury],[Compile support for Bitfury (default enabled)])],
  559. [bitfury=$enableval]
  560. )
  561. if test "x$bitfury" = xyes; then
  562. AC_DEFINE([USE_BITFURY], [1], [Defined to 1 if Bitfury support is wanted])
  563. fi
  564. AM_CONDITIONAL([HAS_BITFURY], [test x$bitfury = xyes])
  565. driverlist="$driverlist bfsb"
  566. bfsb=no
  567. AC_ARG_ENABLE([bfsb],
  568. [AC_HELP_STRING([--enable-bfsb],[Compile support for BFSB (default disabled)])],
  569. [bfsb=$enableval]
  570. )
  571. if test "x$bfsb" = "xyes"; then
  572. if test "x$bitfury" = "xno"; then
  573. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BFSB])
  574. fi
  575. AC_DEFINE([USE_BFSB], [1], [Defined to 1 if BFSB support is wanted])
  576. fi
  577. AM_CONDITIONAL([HAS_BFSB], [test x$bfsb = xyes])
  578. driverlist="$driverlist bigpic"
  579. bigpic=auto
  580. AC_ARG_ENABLE([bigpic],
  581. [AC_HELP_STRING([--disable-bigpic],[Compile support for Big Picture Mining USB (default enabled)])],
  582. [bigpic=$enableval]
  583. )
  584. if test "x$bigpic" = "xno"; then
  585. true
  586. elif test "x$bitfury" = "xyes"; then
  587. bigpic=yes
  588. elif test "x$bigpic" = "xyes"; then
  589. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BigPic])
  590. else
  591. bigpic=no
  592. fi
  593. if test "x$bigpic" = "xyes"; then
  594. AC_DEFINE([USE_BIGPIC], [1], [Defined to 1 if Big Picture Mining USB support is wanted])
  595. need_lowl_vcom=yes
  596. has_asic=yes
  597. fi
  598. AM_CONDITIONAL([HAS_BIGPIC], [test x$bigpic = xyes])
  599. driverlist="$driverlist littlefury"
  600. littlefury=auto
  601. AC_ARG_ENABLE([littlefury],
  602. [AC_HELP_STRING([--disable-littlefury],[Compile support for LittleFury (default enabled)])],
  603. [littlefury=$enableval]
  604. )
  605. if test "x$littlefury" = "xno"; then
  606. true
  607. elif test "x$bitfury" = "xyes"; then
  608. littlefury=yes
  609. elif test "x$littlefury" = "xyes"; then
  610. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled LittleFury])
  611. else
  612. littlefury=no
  613. fi
  614. if test "x$littlefury" = "xyes"; then
  615. AC_DEFINE([USE_LITTLEFURY], [1], [Defined to 1 if LittleFury support is wanted])
  616. need_lowl_vcom=yes
  617. has_asic=yes
  618. fi
  619. AM_CONDITIONAL([HAS_LITTLEFURY], [test x$littlefury = xyes])
  620. found_hidapi=false
  621. for _hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
  622. PKG_CHECK_MODULES([hidapi],[$_hidapi_lib],[
  623. found_hidapi=true
  624. break
  625. ],[
  626. true
  627. ])
  628. done
  629. driverlist="$driverlist nanofury"
  630. nanofury=auto
  631. AC_ARG_ENABLE([nanofury],
  632. [AC_HELP_STRING([--disable-nanofury],[Compile support for NanoFury (default enabled)])],
  633. [nanofury=$enableval]
  634. )
  635. if test "x$nanofury" = "xno"; then
  636. true
  637. elif test "x$bitfury" = "xyes"; then
  638. if test x$found_hidapi = xtrue; then
  639. nanofury=yes
  640. else
  641. if test x$nanofury = xauto; then
  642. nanofury=no
  643. nanofury_enableaction="install hidapi"
  644. else
  645. AC_MSG_ERROR([Could not find hidapi, required for NanoFury support])
  646. fi
  647. fi
  648. elif test "x$nanofury" = "xyes"; then
  649. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled NanoFury])
  650. else
  651. nanofury=no
  652. fi
  653. if test "x$nanofury" = "xyes"; then
  654. AC_DEFINE([USE_NANOFURY], [1], [Defined to 1 if NanoFury support is wanted])
  655. need_lowl_hid=yes
  656. has_asic=yes
  657. fi
  658. AM_CONDITIONAL([HAS_NANOFURY], [test x$nanofury = xyes])
  659. driverlist="$driverlist hashbuster"
  660. hashbuster=auto
  661. AC_ARG_ENABLE([hashbuster],
  662. [AC_HELP_STRING([--disable-hashbuster],[Compile support for HashBuster (default enabled)])],
  663. [hashbuster=$enableval]
  664. )
  665. if test "x$hashbuster" = "xno"; then
  666. true
  667. elif test "x$bitfury" = "xyes"; then
  668. if test x$found_hidapi = xtrue; then
  669. hashbuster=yes
  670. else
  671. if test x$hashbuster = xauto; then
  672. hashbuster=no
  673. hashbuster_enableaction="install hidapi"
  674. else
  675. AC_MSG_ERROR([Could not find hidapi, required for HashBuster support])
  676. fi
  677. fi
  678. elif test "x$hashbuster" = "xyes"; then
  679. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled HashBuster])
  680. else
  681. hashbuster=no
  682. fi
  683. if test "x$hashbuster" = "xyes"; then
  684. AC_DEFINE([USE_HASHBUSTER], [1], [Defined to 1 if HashBuster support is wanted])
  685. need_lowl_hid=yes
  686. has_asic=yes
  687. fi
  688. AM_CONDITIONAL([USE_HASHBUSTER], [test x$hashbuster = xyes])
  689. driverlist="$driverlist metabank"
  690. metabank=no
  691. AC_ARG_ENABLE([metabank],
  692. [AC_HELP_STRING([--enable-metabank],[Compile support for Metabank (default disabled)])],
  693. [metabank=$enableval]
  694. )
  695. if test "x$metabank" = "xyes"; then
  696. if test "x$bitfury" = "xno"; then
  697. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Metabank])
  698. fi
  699. AC_DEFINE([USE_METABANK], [1], [Defined to 1 if Metabank support is wanted])
  700. fi
  701. AM_CONDITIONAL([HAS_METABANK], [test x$metabank = xyes])
  702. if test "x$need_lowl_vcom" != "xno"; then
  703. # Lowlevel VCOM doesn't need libusb, but it can take advantage of it to reattach drivers
  704. need_lowl_usb=yes
  705. fi
  706. if test "x$need_lowl_usb" = "xno"; then
  707. libusb=no
  708. LIBUSB_LIBS=''
  709. LIBUSB_CFLAGS=''
  710. fi
  711. if test "x$libusb" = xyes; then
  712. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  713. save_CFLAGS="$CFLAGS"
  714. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  715. AC_CHECK_DECLS([libusb_error_name],[true],[true],[#include <libusb.h>])
  716. CFLAGS="$save_CFLAGS"
  717. fi
  718. algolist="$algolist scrypt"
  719. scrypt="no"
  720. AC_ARG_ENABLE([scrypt],
  721. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  722. [scrypt=$enableval]
  723. )
  724. if test "x$scrypt" = xyes; then
  725. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  726. fi
  727. if test x$need_lowl_vcom = xyes; then
  728. AC_DEFINE([NEED_BFG_LOWL_VCOM], [1], [Defined to 1 if lowlevel VCOM drivers are being used])
  729. need_lowlevel=yes
  730. if $have_win32; then
  731. echo '#include <iospeeds.h>' >iospeeds_local.h
  732. found_ddkusb=false
  733. AC_CHECK_HEADER([usbiodef.h],[
  734. found_ddkusb=true
  735. ],[
  736. AC_CHECK_HEADER([ddk/usbiodef.h],[
  737. found_ddkusb=true
  738. 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`
  739. ],[
  740. true
  741. ],[
  742. #include <windows.h>
  743. #include <ddk/usbioctl.h>
  744. AC_INCLUDES_DEFAULT
  745. ])
  746. ],[
  747. #include <windows.h>
  748. #include <usbioctl.h>
  749. AC_INCLUDES_DEFAULT
  750. ])
  751. if $found_ddkusb; then
  752. AUTOSCAN_LIBS="-lsetupapi"
  753. AC_DEFINE([HAVE_WIN_DDKUSB],[1],[Defined to 1 if Windows DDK USB headers are being used])
  754. fi
  755. else
  756. AC_MSG_CHECKING([what baud rates your system supports])
  757. echo '#include <termios.h>' | ${CPP} -dM - 2>/dev/null | sed 's/.*[ ]B\([0-9][0-9]*\)[ ].*/IOSPEED(\1)/' | grep IOSPEED >iospeeds_local.h
  758. if grep -q IOSPEED iospeeds_local.h; then
  759. AC_MSG_RESULT([done])
  760. else
  761. AC_MSG_RESULT([failed, using standard POSIX])
  762. echo '#include <iospeeds_posix.h>' >iospeeds_local.h
  763. fi
  764. fi
  765. fi
  766. if test "x$opencl$need_lowl_hid" = xnono; then
  767. DLOPEN_FLAGS=""
  768. fi
  769. if test x$need_lowl_hid = xyes; then
  770. AC_DEFINE([NEED_BFG_LOWL_HID], [1], [Defined to 1 if lowlevel hid drivers are being used])
  771. need_lowlevel=yes
  772. fi
  773. if test x$need_lowl_usb = xyes; then
  774. need_lowlevel=yes
  775. fi
  776. if test x$need_lowl_vcom = xyes; then
  777. need_lowlevel=yes
  778. fi
  779. if test x$need_lowlevel = xyes; then
  780. AC_DEFINE([HAVE_BFG_LOWLEVEL], [1], [Defined to 1 if lowlevel drivers are being used])
  781. fi
  782. curses="auto"
  783. AC_ARG_WITH([curses],
  784. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  785. [curses=$withval]
  786. )
  787. if test "x$curses" = "xno"; then
  788. optlist="$optlist curses"
  789. else
  790. curses_enableaction="install a curses library"
  791. orig_libs="$LIBS"
  792. if test "x${curses}" = "xyes"; then
  793. preferl=''
  794. else
  795. preferl="${curses} ${curses}6 ${curses}5"
  796. fi
  797. for wideornot in w u ''; do
  798. for ncursesver in '' 6 5; do
  799. preferl="${preferl} ncurses${wideornot}${ncursesver}"
  800. done
  801. preferl="${preferl} pdcurses${wideornot}"
  802. done
  803. if test "x$cross_compiling" != "xyes"; then
  804. AC_MSG_CHECKING([for best native curses library])
  805. orig_cflags="$CFLAGS"
  806. for curses_lib in ${preferl}; do
  807. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  808. continue
  809. fi
  810. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  811. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  812. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  813. #include <curses.h>
  814. ]], [[
  815. WINDOW *w = NULL;
  816. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  817. ]])], [
  818. curses=yes
  819. optlist="$optlist ${curses_lib}/curses"
  820. AC_MSG_RESULT([$curses_lib])
  821. NCURSES_LIBS=`${curses_lib}-config --libs`
  822. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  823. break
  824. ], [
  825. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  826. ])
  827. done
  828. CFLAGS="$orig_cflags"
  829. if test "x$curses" != "xyes"; then
  830. AC_MSG_RESULT([none?])
  831. fi
  832. fi
  833. if test "x$curses" != "xyes"; then
  834. sym=addstr
  835. AC_SEARCH_LIBS(${sym}, ${preferl}, [
  836. curses=yes
  837. eval "curseslib=\"\${ac_cv_search_${sym}}\""
  838. barelib="${curseslib/-l/}"
  839. optlist="$optlist ${barelib}/curses"
  840. if test "x${curseslib}" != "xnone required"; then
  841. NCURSES_LIBS="${curseslib}"
  842. fi
  843. # Need to check for headers in subdirectories, to ensure we get wide stuff
  844. AC_MSG_CHECKING([for curses header subdirectory])
  845. barelib="${barelib/6/}"
  846. barelib="${barelib/5/}"
  847. 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`
  848. if test "x$cursesincl" != "x"; then
  849. NCURSES_CPPFLAGS="-I${cursesincl}"
  850. AC_MSG_RESULT([$cursesincl])
  851. else
  852. AC_MSG_RESULT([none found])
  853. fi
  854. break
  855. ], [
  856. if test "x$curses" = "xyes"; then
  857. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  858. else
  859. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  860. curses=no
  861. optlist="$optlist curses"
  862. fi
  863. ])
  864. fi
  865. if test "x$curses" = "xyes"; then
  866. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  867. AC_MSG_CHECKING([whether curses library supports wide characters])
  868. LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS"
  869. AC_LINK_IFELSE([
  870. AC_LANG_PROGRAM([
  871. #define PDC_WIDE
  872. #include <curses.h>
  873. ],[
  874. addwstr(L"test");
  875. add_wch(WACS_VLINE);
  876. ])
  877. ],[
  878. AC_MSG_RESULT([yes])
  879. AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters])
  880. ],[
  881. AC_MSG_RESULT([no])
  882. ])
  883. fi
  884. LIBS="$orig_libs"
  885. fi
  886. maybe_ldconfig=
  887. 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])
  888. if test "x$with_system_libblkmaker" = "xyes"; then
  889. PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
  890. true
  891. ],[
  892. AC_MSG_ERROR([Could not find system libblkmaker])
  893. ])
  894. else
  895. save_LDFLAGS="$LDFLAGS"
  896. LDFLAGS="$LDFLAGS -Wl,-zorigin"
  897. origin_LDFLAGS=
  898. AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
  899. AC_TRY_LINK([],[],[
  900. AC_MSG_RESULT([yes])
  901. origin_LDFLAGS=',-zorigin'
  902. ],[
  903. AC_MSG_RESULT([no])
  904. ])
  905. LDFLAGS="$save_LDFLAGS"
  906. libblkmaker_CFLAGS='-Ilibblkmaker'
  907. libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS"
  908. libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
  909. AC_CONFIG_SUBDIRS([libblkmaker])
  910. _ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g`
  911. possible_ldconfigs="${target}-ldconfig"
  912. if test "x$cross_compiling" != "xyes"; then
  913. possible_ldconfigs="${possible_ldconfigs} ldconfig"
  914. fi
  915. AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH])
  916. if test "x$LDCONFIG" != "x"; then
  917. maybe_ldconfig=" && $LDCONFIG"
  918. fi
  919. fi
  920. AC_SUBST(libblkmaker_CFLAGS)
  921. AC_SUBST(libblkmaker_LDFLAGS)
  922. AC_SUBST(libblkmaker_LIBS)
  923. AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
  924. AM_CONDITIONAL([NEED_BFG_BINLOADER], [test x$need_binloader = xyes])
  925. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes])
  926. AM_CONDITIONAL([NEED_BFG_LOWL_VCOM], [test x$need_lowl_vcom = xyes])
  927. AM_CONDITIONAL([NEED_BFG_LOWL_HID], [test x$need_lowl_hid = xyes])
  928. AM_CONDITIONAL([NEED_BFG_LOWLEVEL], [test x$need_lowlevel = xyes])
  929. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  930. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  931. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  932. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  933. AM_CONDITIONAL([HAVE_LIBUSB], [test x$libusb = xyes])
  934. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  935. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  936. AM_CONDITIONAL([HAVE_WIN_DDKUSB], [test x$found_ddkusb = xtrue])
  937. AM_CONDITIONAL([HAS_FPGA], [test x$has_fpga != xno])
  938. AM_CONDITIONAL([HAS_ASIC], [test x$has_asic != xno])
  939. dnl Find YASM
  940. has_yasm=false
  941. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  942. AC_PATH_PROG([YASM],[yasm],[false])
  943. if test "x$YASM" != "xfalse" ; then
  944. has_yasm_enableaction="install yasm 1.0.1+"
  945. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  946. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  947. yamajor=`echo $yasmver | cut -d. -f1`
  948. yaminor=`echo $yasmver | cut -d. -f2`
  949. yamini=`echo $yasmver | cut -d. -f3`
  950. if test "$yamajor" -ge "1" ; then
  951. if test "$yamajor" -eq "1" ; then
  952. if test "$yaminor" -ge "0" ; then
  953. if test "$yaminor" -eq "0"; then
  954. if test "$yamini" -ge "1"; then
  955. has_yasm=true
  956. fi
  957. else
  958. has_yasm=true
  959. fi
  960. fi
  961. fi
  962. else
  963. has_yasm=false
  964. fi
  965. if test "x$has_yasm" = "xtrue" ; then
  966. AC_MSG_RESULT([yes])
  967. else
  968. AC_MSG_RESULT([no])
  969. fi
  970. fi
  971. if test "x$has_yasm" = "xfalse" ; then
  972. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  973. else
  974. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  975. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  976. if test "x$have_x86_64" = xtrue; then
  977. YASM_FMT="win64"
  978. else
  979. YASM_FMT="coff"
  980. fi
  981. elif test "x$have_macho" = "xtrue"; then
  982. YASM_FMT="macho$bitness"
  983. else
  984. YASM_FMT="elf$bitness"
  985. fi
  986. fi
  987. fi
  988. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  989. have_sse2=no
  990. if test "x$cpumining$have_x86_32" = "xyestrue"; then
  991. AC_MSG_CHECKING([if SSE2 code compiles])
  992. save_CFLAGS="$CFLAGS"
  993. for flags in '' '-msse2'; do
  994. CFLAGS="$CFLAGS $flags"
  995. AC_TRY_LINK([
  996. #include <xmmintrin.h>
  997. ],[
  998. int *i = (int *)0xdeadbeef;
  999. __m128i a, b;
  1000. a = _mm_set1_epi32(i[0]);
  1001. b = _mm_set_epi32(i[0], i[1], i[2], i[3]);
  1002. a = _mm_add_epi32(a, b);
  1003. a = _mm_andnot_si128(a, b);
  1004. a = _mm_or_si128(a, b);
  1005. a = _mm_slli_epi32(a, i[4]);
  1006. a = _mm_and_si128(a, b);
  1007. a = _mm_xor_si128(a, b);
  1008. ],[
  1009. if test "x$flags" = "x"; then
  1010. AC_MSG_RESULT([yes])
  1011. else
  1012. AC_MSG_RESULT([with $flags])
  1013. fi
  1014. SSE2_CFLAGS="$flags"
  1015. have_sse2=yes
  1016. break
  1017. ],[
  1018. true
  1019. ])
  1020. done
  1021. CFLAGS="${save_CFLAGS}"
  1022. if test "x$have_sse2" = "xyes"; then
  1023. AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used])
  1024. else
  1025. AC_MSG_RESULT([no])
  1026. fi
  1027. fi
  1028. AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"])
  1029. if test "x$need_lowl_vcom" = "xyes"; then
  1030. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  1031. [libudev=$withval],
  1032. [libudev=auto]
  1033. )
  1034. if test "x$libudev" != "xno"; then
  1035. AC_CHECK_HEADER([libudev.h],[
  1036. libudev=yes
  1037. UDEV_LIBS=-ludev
  1038. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  1039. ], [
  1040. if test "x$libudev" = "xyes"; then
  1041. AC_MSG_ERROR([libudev not found])
  1042. fi
  1043. libudev=no
  1044. ])
  1045. fi
  1046. fi
  1047. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  1048. AC_SUBST(LIBUSB_LIBS)
  1049. AC_SUBST(LIBUSB_CFLAGS)
  1050. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  1051. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  1052. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  1053. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  1054. fi
  1055. AC_SUBST(LIBCURL_LIBS)
  1056. AC_CHECK_FUNCS([setrlimit])
  1057. dnl CCAN wants to know a lot of vars.
  1058. # All the configuration checks. Regrettably, the __attribute__ checks will
  1059. # give false positives on old GCCs, since they just cause warnings. But that's
  1060. # fairly harmless.
  1061. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  1062. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  1063. [Define if __attribute__((cold))]))
  1064. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  1065. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  1066. [Define if __attribute__((const))]))
  1067. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  1068. [
  1069. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  1070. [Define if __attribute__((noreturn))])
  1071. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  1072. ], [
  1073. AC_DEFINE_UNQUOTED([NORETURN], [])
  1074. ]
  1075. )
  1076. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  1077. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  1078. [Define if __attribute__((format(__printf__)))]))
  1079. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  1080. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  1081. [Define if __attribute__((unused))]))
  1082. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  1083. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  1084. [Define if __attribute__((used))]))
  1085. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  1086. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  1087. [Define if have __builtin_constant_p]))
  1088. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  1089. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  1090. [Define if have __builtin_types_compatible_p]))
  1091. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  1092. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  1093. [Define if __attribute__((warn_unused_result))]))
  1094. # byteswap functions
  1095. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  1096. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  1097. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  1098. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  1099. BSWAP=''
  1100. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  1101. AC_MSG_CHECKING([for ${sym}* functions])
  1102. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  1103. BFG_INCLUDE([headerinclude], [${headerfile}])
  1104. AC_LINK_IFELSE([
  1105. AC_LANG_PROGRAM([
  1106. ${headerinclude}
  1107. ], [
  1108. (void) ${sym}16(0);
  1109. (void) ${sym}32(0);
  1110. (void) ${sym}64(0);
  1111. ])
  1112. ], [
  1113. BSWAP="${sym}"
  1114. if test "x${headerfile}" = "x"; then
  1115. AC_MSG_RESULT([yes])
  1116. else
  1117. AC_MSG_RESULT([found in ${headerfile}])
  1118. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  1119. fi
  1120. break 2
  1121. ])
  1122. done
  1123. AC_MSG_RESULT([no])
  1124. done
  1125. if test "x$BSWAP" = "x"; then
  1126. true # Substitutes are provided in miner.h
  1127. elif test "x$BSWAP" = "xbswap_"; then
  1128. AC_MSG_CHECKING([if bswap_16 is already a macro])
  1129. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  1130. AC_MSG_RESULT([yes])
  1131. BSWAP=""
  1132. ],[
  1133. AC_MSG_RESULT([no])
  1134. ])
  1135. fi
  1136. if test "x$BSWAP" != "x"; then
  1137. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  1138. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  1139. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  1140. fi
  1141. # endian definition macros
  1142. AC_MSG_CHECKING([for platform endian])
  1143. found_endian=no
  1144. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  1145. for pfx in '' '__'; do
  1146. 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}, [
  1147. if test "x$headerfile" = "x"; then
  1148. headerfilec=''
  1149. else
  1150. headerfilec=" (${headerfile})"
  1151. fi
  1152. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  1153. AC_MSG_RESULT([big endian${headerfilec}])
  1154. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  1155. ], [
  1156. AC_MSG_RESULT([little endian${headerfilec}])
  1157. ])
  1158. found_endian=yes
  1159. break 2
  1160. ],[true])
  1161. done
  1162. done
  1163. if test "x$found_endian" = "xno"; then
  1164. if $have_win32 || $have_cygwin; then
  1165. AC_MSG_RESULT([assuming little endian (Windows)])
  1166. else
  1167. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  1168. AC_MSG_RESULT([unknown])
  1169. AC_MSG_ERROR([Unable to identify platform endian])
  1170. fi
  1171. fi
  1172. AC_MSG_CHECKING([if GNU format attribute compiles])
  1173. AC_TRY_COMPILE([
  1174. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  1175. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  1176. int myfunc(char *fmt, ...) {
  1177. return 42;
  1178. }
  1179. ], [
  1180. myfunc("abc%d", 42);
  1181. ], [
  1182. AC_MSG_RESULT([yes])
  1183. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  1184. ], [
  1185. AC_MSG_RESULT([no])
  1186. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  1187. ])
  1188. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC)])
  1189. AC_TRY_COMPILE([
  1190. #define _GNU_SOURCE
  1191. #include <time.h>
  1192. ],[
  1193. struct timespec ts;
  1194. clock_gettime(CLOCK_MONOTONIC, &ts);
  1195. ],[
  1196. AC_MSG_RESULT([yes])
  1197. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC) is defined])
  1198. save_LIBS="${LIBS}"
  1199. AC_SEARCH_LIBS([clock_gettime],[rt posix4],[
  1200. if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then
  1201. RT_LIBS="${ac_cv_search_clock_gettime}"
  1202. fi
  1203. ])
  1204. LIBS="${save_LIBS}"
  1205. AC_CHECK_FUNCS([clock_nanosleep])
  1206. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC_RAW)])
  1207. AC_TRY_COMPILE([
  1208. #define _GNU_SOURCE
  1209. #include <time.h>
  1210. ],[
  1211. struct timespec ts;
  1212. clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  1213. ],[
  1214. AC_MSG_RESULT([yes])
  1215. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC_RAW], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC_RAW) is defined])
  1216. ],[
  1217. AC_MSG_RESULT([no])
  1218. ])
  1219. ],[
  1220. AC_MSG_RESULT([no])
  1221. ])
  1222. if test "x$prefix" = xNONE; then
  1223. prefix=/usr/local
  1224. fi
  1225. AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono])
  1226. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel])
  1227. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel])
  1228. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel])
  1229. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel])
  1230. AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
  1231. AC_SUBST(AUTOSCAN_CPPFLAGS)
  1232. AC_SUBST(AUTOSCAN_LIBS)
  1233. AC_SUBST(PTHREAD_FLAGS)
  1234. AC_SUBST(DLOPEN_FLAGS)
  1235. AC_SUBST(PTHREAD_LIBS)
  1236. AC_SUBST(NCURSES_CPPFLAGS)
  1237. AC_SUBST(NCURSES_LIBS)
  1238. AC_SUBST(PDCURSES_LIBS)
  1239. AC_SUBST(WS2_LIBS)
  1240. AC_SUBST(MM_LIBS)
  1241. AC_SUBST(MATH_LIBS)
  1242. AC_SUBST(RT_LIBS)
  1243. AC_SUBST(UDEV_LIBS)
  1244. AC_SUBST(SSE2_CFLAGS)
  1245. AC_SUBST(YASM_FMT)
  1246. AC_CONFIG_FILES([
  1247. Makefile
  1248. x86_64/Makefile
  1249. x86_32/Makefile
  1250. ccan/Makefile
  1251. lib/Makefile
  1252. ])
  1253. echo
  1254. echo
  1255. echo
  1256. echo "------------------------------------------------------------------------"
  1257. echo "$PACKAGE $VERSION"
  1258. echo "------------------------------------------------------------------------"
  1259. echo
  1260. echo
  1261. echo "Configuration Options Summary:"
  1262. echo
  1263. m4_define([BFG_PRINT_LIST],[
  1264. eval _mylist="\$$2"
  1265. _yeslist=
  1266. _nolist=
  1267. _enableactions=
  1268. for _opt in $_mylist; do
  1269. IFS=/ read _opt _var <<EOF
  1270. $_opt
  1271. EOF
  1272. test -n "$_var" || _var="$_opt"
  1273. eval "_val=\"\$${_var}\""
  1274. if test "x$_val" = "xno" || test "x$_val" = "xfalse"; then
  1275. _nolist="$_nolist $_opt"
  1276. eval "_enableaction=\"\$${_var}_enableaction\""
  1277. if test -n "$_enableaction"; then
  1278. _enableactions="${_enableactions}~ To enable ${_opt}, ${_enableaction}"
  1279. fi
  1280. else
  1281. _yeslist="$_yeslist $_opt"
  1282. fi
  1283. done
  1284. _yeslist=`echo "$_yeslist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1285. _nolist=`echo "$_nolist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1286. AC_DEFINE_UNQUOTED(AS_TR_CPP([BFG_$2]),["$_yeslist"],[List of drivers being built])
  1287. echo " Enabled..$1..:$_yeslist"
  1288. echo " Disabled.$1..:$_nolist"
  1289. if test -n "$_enableactions"; then
  1290. echo "${_enableactions:1}" | tr '~' '\n'
  1291. fi
  1292. ])
  1293. BFG_PRINT_LIST([Drivers...],[driverlist])
  1294. BFG_PRINT_LIST([Algorithms],[algolist])
  1295. BFG_PRINT_LIST([Options...],[optlist])
  1296. echo
  1297. echo "Compilation............: make (or gmake)"
  1298. echo " CFLAGS...............: $CPPFLAGS $AUTOSCAN_CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libblkmaker_CFLAGS $hidapi_CFLAGS"
  1299. 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"
  1300. echo
  1301. echo "Installation...........: make install$maybe_ldconfig #(as root if needed, with 'su' or 'sudo')"
  1302. echo " prefix...............: $prefix"
  1303. echo
  1304. AC_OUTPUT