configure.ac 40 KB

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