configure.ac 40 KB

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