configure.ac 36 KB

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