configure.ac 40 KB

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