configure.ac 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228
  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. httpsrv=auto
  344. AC_ARG_WITH([libmicrohttpd],
  345. [AC_HELP_STRING([--without-libmicrohttpd],[Compile support for libmicrohttpd getwork server (default enabled)])],
  346. [httpsrv=$withval]
  347. )
  348. if test "x$httpsrv" != "xno"; then
  349. PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.5],[
  350. AC_DEFINE([USE_LIBMICROHTTPD],[1],[Defined to 1 if libmicrohttpd support is wanted])
  351. httpsrv=yes
  352. ],[
  353. httpsrv=no
  354. httpsrv_enableaction="install libmicrohttpd 0.9.5+"
  355. need_bfg_driver_proxy_enableaction="install libmicrohttpd 0.9.5+"
  356. if test "x$httpsrv" = "xyes"; then
  357. AC_MSG_ERROR([Unable to find libmicrohttpd 0.9.5+])
  358. else
  359. AC_MSG_WARN([libmicrohttpd 0.9.5+ not found; getwork proxy will be unavailable])
  360. fi
  361. ])
  362. fi
  363. AM_CONDITIONAL([USE_LIBMICROHTTPD], [test x$httpsrv = xyes])
  364. libevent=auto
  365. AC_ARG_WITH([libevent],
  366. [AC_HELP_STRING([--without-libevent],[Compile support for libevent stratum server (default enabled)])],
  367. [libevent=$withval]
  368. )
  369. if test "x$libevent" != "xno"; then
  370. PKG_CHECK_MODULES([libevent],[libevent >= 2.0.3],[
  371. AC_DEFINE([USE_LIBEVENT],[1],[Defined to 1 if libevent support is wanted])
  372. libevent=yes
  373. ],[
  374. libevent=no
  375. libevent_enableaction="install libevent 2.0.3+"
  376. if test -n "$need_bfg_driver_proxy_enableaction"; then
  377. need_bfg_driver_proxy_enableaction="${need_bfg_driver_proxy_enableaction} (getwork) or libevent 2.0.3+ (stratum)"
  378. else
  379. need_bfg_driver_proxy_enableaction="install libevent 2.0.3+"
  380. fi
  381. if test "x$libevent" = "xyes"; then
  382. AC_MSG_ERROR([Unable to find libevent 2.0.3+])
  383. else
  384. AC_MSG_WARN([libevent 2.0.3+ not found; stratum proxy will be unavailable])
  385. fi
  386. ])
  387. fi
  388. AM_CONDITIONAL([USE_LIBEVENT], [test x$libevent = xyes])
  389. driverlist="$driverlist proxy/need_bfg_driver_proxy"
  390. if test x$libevent$httpsrv = xnono; then
  391. need_bfg_driver_proxy=no
  392. else
  393. need_bfg_driver_proxy=yes
  394. driverlist="$driverlist proxy:getwork/httpsrv proxy:stratum/libevent"
  395. fi
  396. AM_CONDITIONAL([NEED_BFG_DRIVER_PROXY], [test x$libevent$httpsrv != xnono])
  397. driverlist="$driverlist modminer"
  398. AC_ARG_ENABLE([modminer],
  399. [AC_HELP_STRING([--disable-modminer],[Compile support for ModMiner (default enabled)])],
  400. [modminer=$enableval],
  401. [modminer=yes]
  402. )
  403. if test "x$modminer" = xyes; then
  404. AC_DEFINE([USE_MODMINER], [1], [Defined to 1 if ModMiner support is wanted])
  405. need_dynclock=yes
  406. need_fpgautils=yes
  407. fi
  408. AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes])
  409. PKG_PROG_PKG_CONFIG()
  410. libusb=no
  411. libusb_include_path=""
  412. PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[
  413. libusb=yes
  414. ],[
  415. for usb_lib in usb-1.0 usb; do
  416. AC_CHECK_LIB($usb_lib, libusb_init, [
  417. libusb=yes
  418. break
  419. ])
  420. done
  421. if test "x$libusb" = xyes; then
  422. AC_CHECK_DECL([libusb_init],[
  423. true
  424. ],[
  425. AC_MSG_CHECKING([whether libusb_init is declared in subdirectory])
  426. 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`
  427. if test "x$libusb_include_path" != "x"; then
  428. LIBUSB_LIBS="-l$usb_lib"
  429. LIBUSB_CFLAGS="-I$libusb_include_path"
  430. AC_MSG_RESULT([yes])
  431. else
  432. libusb=no
  433. AC_MSG_RESULT([no])
  434. fi
  435. ],[#include <libusb.h>])
  436. fi
  437. ])
  438. driverlist="$driverlist x6500"
  439. AC_ARG_ENABLE([x6500],
  440. [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])],
  441. [x6500=$enableval],
  442. [x6500=auto]
  443. )
  444. if test "x$x6500$libusb" = xyesno; then
  445. AC_MSG_ERROR([Could not find libusb, required for X6500 support])
  446. elif test "x$x6500" = xauto; then
  447. x6500="$libusb"
  448. if test "x$libusb" = xno; then
  449. AC_MSG_WARN([Could not find libusb, required for X6500 support])
  450. x6500_enableaction="install libusb 1.0+"
  451. fi
  452. fi
  453. if test "x$x6500" = xyes; then
  454. AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted])
  455. need_dynclock=yes
  456. need_fpgautils=yes
  457. fi
  458. AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes])
  459. driverlist="$driverlist ztex"
  460. AC_ARG_ENABLE([ztex],
  461. [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])],
  462. [ztex=$enableval],
  463. [ztex=auto]
  464. )
  465. if test "x$ztex$libusb" = xyesno; then
  466. AC_MSG_ERROR([Could not find libusb, required for ZTEX support])
  467. elif test "x$ztex" = xauto; then
  468. ztex="$libusb"
  469. if test "x$libusb" = xno; then
  470. AC_MSG_WARN([Could not find libusb, required for ZTEX support])
  471. ztex_enableaction="install libusb 1.0+"
  472. fi
  473. fi
  474. if test "x$ztex" = xyes; then
  475. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted])
  476. need_dynclock=yes
  477. need_fpgautils=yes
  478. fi
  479. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  480. driverlist="$driverlist bitfury_gpio/bitfury"
  481. bitfury=yes
  482. AC_ARG_ENABLE([bitfury],
  483. [AC_HELP_STRING([--disable-bitfury],[Compile support for Bitfury (default enabled)])],
  484. [bitfury=$enableval]
  485. )
  486. if test "x$bitfury" = xyes; then
  487. AC_DEFINE([USE_BITFURY], [1], [Defined to 1 if Bitfury support is wanted])
  488. fi
  489. AM_CONDITIONAL([HAS_BITFURY], [test x$bitfury = xyes])
  490. driverlist="$driverlist bfsb"
  491. bfsb=no
  492. AC_ARG_ENABLE([bfsb],
  493. [AC_HELP_STRING([--enable-bfsb],[Compile support for BFSB (default disabled)])],
  494. [bfsb=$enableval]
  495. )
  496. if test "x$bfsb" = "xyes"; then
  497. if test "x$bitfury" = "xno"; then
  498. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BFSB])
  499. fi
  500. AC_DEFINE([USE_BFSB], [1], [Defined to 1 if BFSB support is wanted])
  501. fi
  502. AM_CONDITIONAL([HAS_BFSB], [test x$bfsb = xyes])
  503. driverlist="$driverlist bigpic"
  504. bigpic=auto
  505. AC_ARG_ENABLE([bigpic],
  506. [AC_HELP_STRING([--disable-bigpic],[Compile support for Big Picture Mining USB (default enabled)])],
  507. [bigpic=$enableval]
  508. )
  509. if test "x$bigpic" = "xno"; then
  510. true
  511. elif test "x$bitfury" = "xyes"; then
  512. bigpic=yes
  513. elif test "x$bigpic" = "xyes"; then
  514. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BigPic])
  515. else
  516. bigpic=no
  517. fi
  518. if test "x$bigpic" = "xyes"; then
  519. AC_DEFINE([USE_BIGPIC], [1], [Defined to 1 if Big Picture Mining USB support is wanted])
  520. need_fpgautils=yes
  521. fi
  522. AM_CONDITIONAL([HAS_BIGPIC], [test x$bigpic = xyes])
  523. driverlist="$driverlist littlefury"
  524. littlefury=auto
  525. AC_ARG_ENABLE([littlefury],
  526. [AC_HELP_STRING([--disable-littlefury],[Compile support for LittleFury (default enabled)])],
  527. [littlefury=$enableval]
  528. )
  529. if test "x$littlefury" = "xno"; then
  530. true
  531. elif test "x$bitfury" = "xyes"; then
  532. littlefury=yes
  533. elif test "x$littlefury" = "xyes"; then
  534. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled LittleFury])
  535. else
  536. littlefury=no
  537. fi
  538. if test "x$littlefury" = "xyes"; then
  539. AC_DEFINE([USE_LITTLEFURY], [1], [Defined to 1 if LittleFury support is wanted])
  540. need_fpgautils=yes
  541. fi
  542. AM_CONDITIONAL([HAS_LITTLEFURY], [test x$littlefury = xyes])
  543. driverlist="$driverlist metabank"
  544. metabank=no
  545. AC_ARG_ENABLE([metabank],
  546. [AC_HELP_STRING([--enable-metabank],[Compile support for Metabank (default disabled)])],
  547. [metabank=$enableval]
  548. )
  549. if test "x$metabank" = "xyes"; then
  550. if test "x$bitfury" = "xno"; then
  551. AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Metabank])
  552. fi
  553. AC_DEFINE([USE_METABANK], [1], [Defined to 1 if Metabank support is wanted])
  554. fi
  555. AM_CONDITIONAL([HAS_METABANK], [test x$metabank = xyes])
  556. if test "x$x6500$ztex" = "xnono"; then
  557. libusb=no
  558. LIBUSB_LIBS=''
  559. LIBUSB_CFLAGS=''
  560. fi
  561. if test "x$libusb" = xyes; then
  562. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  563. save_CFLAGS="$CFLAGS"
  564. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  565. AC_CHECK_DECLS([libusb_error_name],[true],[true],[#include <libusb.h>])
  566. CFLAGS="$save_CFLAGS"
  567. fi
  568. algolist="$algolist scrypt"
  569. scrypt="no"
  570. AC_ARG_ENABLE([scrypt],
  571. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  572. [scrypt=$enableval]
  573. )
  574. if test "x$scrypt" = xyes; then
  575. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  576. fi
  577. if test x$need_fpgautils = xyes; then
  578. AC_DEFINE([HAVE_FPGAUTILS], [1], [Defined to 1 if fpgautils is being used])
  579. if $have_win32; then
  580. echo '#include <iospeeds.h>' >iospeeds_local.h
  581. else
  582. AC_MSG_CHECKING([what baud rates your system supports])
  583. echo '#include <termios.h>' | ${CPP} -dM - 2>/dev/null | sed 's/.*[ ]B\([0-9][0-9]*\)[ ].*/IOSPEED(\1)/' | grep IOSPEED >iospeeds_local.h
  584. if grep -q IOSPEED iospeeds_local.h; then
  585. AC_MSG_RESULT([done])
  586. else
  587. AC_MSG_RESULT([failed, using standard POSIX])
  588. echo '#include <iospeeds_posix.h>' >iospeeds_local.h
  589. fi
  590. fi
  591. fi
  592. curses="auto"
  593. AC_ARG_WITH([curses],
  594. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  595. [curses=$withval]
  596. )
  597. if test "x$curses" = "xno"; then
  598. optlist="$optlist curses"
  599. else
  600. curses_enableaction="install a curses library"
  601. orig_libs="$LIBS"
  602. if test "x${curses}" = "xyes"; then
  603. preferl=''
  604. else
  605. preferl="${curses} ${curses}6 ${curses}5"
  606. fi
  607. for wideornot in w u ''; do
  608. for ncursesver in '' 6 5; do
  609. preferl="${preferl} ncurses${wideornot}${ncursesver}"
  610. done
  611. preferl="${preferl} pdcurses${wideornot}"
  612. done
  613. if test "x$cross_compiling" != "xyes"; then
  614. AC_MSG_CHECKING([for best native curses library])
  615. orig_cflags="$CFLAGS"
  616. for curses_lib in ${preferl}; do
  617. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  618. continue
  619. fi
  620. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  621. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  622. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  623. #include <curses.h>
  624. ]], [[
  625. WINDOW *w = NULL;
  626. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  627. ]])], [
  628. curses=yes
  629. optlist="$optlist ${curses_lib}/curses"
  630. AC_MSG_RESULT([$curses_lib])
  631. NCURSES_LIBS=`${curses_lib}-config --libs`
  632. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  633. break
  634. ], [
  635. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  636. ])
  637. done
  638. CFLAGS="$orig_cflags"
  639. if test "x$curses" != "xyes"; then
  640. AC_MSG_RESULT([none?])
  641. fi
  642. fi
  643. if test "x$curses" != "xyes"; then
  644. sym=addstr
  645. AC_SEARCH_LIBS(${sym}, ${preferl}, [
  646. curses=yes
  647. eval "curseslib=\"\${ac_cv_search_${sym}}\""
  648. barelib="${curseslib/-l/}"
  649. optlist="$optlist ${barelib}/curses"
  650. if test "x${curseslib}" != "xnone required"; then
  651. NCURSES_LIBS="${curseslib}"
  652. fi
  653. # Need to check for headers in subdirectories, to ensure we get wide stuff
  654. AC_MSG_CHECKING([for curses header subdirectory])
  655. barelib="${barelib/6/}"
  656. barelib="${barelib/5/}"
  657. 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`
  658. if test "x$cursesincl" != "x"; then
  659. NCURSES_CPPFLAGS="-I${cursesincl}"
  660. AC_MSG_RESULT([$cursesincl])
  661. else
  662. AC_MSG_RESULT([none found])
  663. fi
  664. break
  665. ], [
  666. if test "x$curses" = "xyes"; then
  667. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  668. else
  669. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  670. curses=no
  671. optlist="$optlist curses"
  672. fi
  673. ])
  674. fi
  675. if test "x$curses" = "xyes"; then
  676. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  677. AC_MSG_CHECKING([whether curses library supports wide characters])
  678. LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS"
  679. AC_LINK_IFELSE([
  680. AC_LANG_PROGRAM([
  681. #define PDC_WIDE
  682. #include <curses.h>
  683. ],[
  684. addwstr(L"test");
  685. add_wch(WACS_VLINE);
  686. ])
  687. ],[
  688. AC_MSG_RESULT([yes])
  689. AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters])
  690. ],[
  691. AC_MSG_RESULT([no])
  692. ])
  693. fi
  694. LIBS="$orig_libs"
  695. fi
  696. maybe_ldconfig=
  697. 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])
  698. if test "x$with_system_libblkmaker" = "xyes"; then
  699. PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
  700. true
  701. ],[
  702. AC_MSG_ERROR([Could not find system libblkmaker])
  703. ])
  704. else
  705. save_LDFLAGS="$LDFLAGS"
  706. LDFLAGS="$LDFLAGS -Wl,-zorigin"
  707. origin_LDFLAGS=
  708. AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
  709. AC_TRY_LINK([],[],[
  710. AC_MSG_RESULT([yes])
  711. origin_LDFLAGS=',-zorigin'
  712. ],[
  713. AC_MSG_RESULT([no])
  714. ])
  715. LDFLAGS="$save_LDFLAGS"
  716. libblkmaker_CFLAGS='-Ilibblkmaker'
  717. libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS"
  718. libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
  719. AC_CONFIG_SUBDIRS([libblkmaker])
  720. _ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g`
  721. possible_ldconfigs="${target}-ldconfig"
  722. if test "x$cross_compiling" != "xyes"; then
  723. possible_ldconfigs="${possible_ldconfigs} ldconfig"
  724. fi
  725. AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH])
  726. if test "x$LDCONFIG" != "x"; then
  727. maybe_ldconfig=" && $LDCONFIG"
  728. fi
  729. fi
  730. AC_SUBST(libblkmaker_CFLAGS)
  731. AC_SUBST(libblkmaker_LDFLAGS)
  732. AC_SUBST(libblkmaker_LIBS)
  733. AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
  734. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes])
  735. AM_CONDITIONAL([NEED_FPGAUTILS], [test x$need_fpgautils = xyes])
  736. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  737. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  738. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  739. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  740. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  741. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  742. AM_CONDITIONAL([HAS_FPGA], [test x$bitforce$icarus$modminer$x6500$ztex != xnonononono])
  743. AM_CONDITIONAL([HAS_ASIC], [test x$avalon$bfsb$bigpic$icarus$httpsrv$metabank != xnononononono])
  744. dnl Find YASM
  745. has_yasm=false
  746. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  747. AC_PATH_PROG([YASM],[yasm],[false])
  748. if test "x$YASM" != "xfalse" ; then
  749. has_yasm_enableaction="install yasm 1.0.1+"
  750. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  751. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  752. yamajor=`echo $yasmver | cut -d. -f1`
  753. yaminor=`echo $yasmver | cut -d. -f2`
  754. yamini=`echo $yasmver | cut -d. -f3`
  755. if test "$yamajor" -ge "1" ; then
  756. if test "$yamajor" -eq "1" ; then
  757. if test "$yaminor" -ge "0" ; then
  758. if test "$yaminor" -eq "0"; then
  759. if test "$yamini" -ge "1"; then
  760. has_yasm=true
  761. fi
  762. else
  763. has_yasm=true
  764. fi
  765. fi
  766. fi
  767. else
  768. has_yasm=false
  769. fi
  770. if test "x$has_yasm" = "xtrue" ; then
  771. AC_MSG_RESULT([yes])
  772. else
  773. AC_MSG_RESULT([no])
  774. fi
  775. fi
  776. if test "x$has_yasm" = "xfalse" ; then
  777. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  778. else
  779. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  780. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  781. if test "x$have_x86_64" = xtrue; then
  782. YASM_FMT="win64"
  783. else
  784. YASM_FMT="coff"
  785. fi
  786. elif test "x$have_macho" = "xtrue"; then
  787. YASM_FMT="macho$bitness"
  788. else
  789. YASM_FMT="elf$bitness"
  790. fi
  791. fi
  792. fi
  793. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  794. have_sse2=no
  795. if test "x$cpumining$have_x86_32" = "xyestrue"; then
  796. AC_MSG_CHECKING([if SSE2 code compiles])
  797. save_CFLAGS="$CFLAGS"
  798. for flags in '' '-msse2'; do
  799. CFLAGS="$CFLAGS $flags"
  800. AC_TRY_LINK([
  801. #include <xmmintrin.h>
  802. ],[
  803. int *i = (int *)0xdeadbeef;
  804. __m128i a, b;
  805. a = _mm_set1_epi32(i[0]);
  806. b = _mm_set_epi32(i[0], i[1], i[2], i[3]);
  807. a = _mm_add_epi32(a, b);
  808. a = _mm_andnot_si128(a, b);
  809. a = _mm_or_si128(a, b);
  810. a = _mm_slli_epi32(a, i[4]);
  811. a = _mm_and_si128(a, b);
  812. a = _mm_xor_si128(a, b);
  813. ],[
  814. if test "x$flags" = "x"; then
  815. AC_MSG_RESULT([yes])
  816. else
  817. AC_MSG_RESULT([with $flags])
  818. fi
  819. SSE2_CFLAGS="$flags"
  820. have_sse2=yes
  821. break
  822. ],[
  823. true
  824. ])
  825. done
  826. CFLAGS="${save_CFLAGS}"
  827. if test "x$have_sse2" = "xyes"; then
  828. AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used])
  829. else
  830. AC_MSG_RESULT([no])
  831. fi
  832. fi
  833. AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"])
  834. if test "x$need_fpgautils" = "xyes"; then
  835. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  836. [libudev=$withval],
  837. [libudev=auto]
  838. )
  839. if test "x$libudev" != "xno"; then
  840. AC_CHECK_HEADER([libudev.h],[
  841. libudev=yes
  842. UDEV_LIBS=-ludev
  843. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  844. ], [
  845. if test "x$libudev" = "xyes"; then
  846. AC_MSG_ERROR([libudev not found])
  847. fi
  848. libudev=no
  849. ])
  850. fi
  851. fi
  852. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  853. AC_SUBST(LIBUSB_LIBS)
  854. AC_SUBST(LIBUSB_CFLAGS)
  855. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  856. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  857. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  858. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  859. fi
  860. AC_SUBST(LIBCURL_LIBS)
  861. AC_CHECK_FUNCS([setrlimit])
  862. dnl CCAN wants to know a lot of vars.
  863. # All the configuration checks. Regrettably, the __attribute__ checks will
  864. # give false positives on old GCCs, since they just cause warnings. But that's
  865. # fairly harmless.
  866. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  867. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  868. [Define if __attribute__((cold))]))
  869. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  870. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  871. [Define if __attribute__((const))]))
  872. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  873. [
  874. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  875. [Define if __attribute__((noreturn))])
  876. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  877. ], [
  878. AC_DEFINE_UNQUOTED([NORETURN], [])
  879. ]
  880. )
  881. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  882. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  883. [Define if __attribute__((format(__printf__)))]))
  884. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  885. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  886. [Define if __attribute__((unused))]))
  887. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  888. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  889. [Define if __attribute__((used))]))
  890. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  891. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  892. [Define if have __builtin_constant_p]))
  893. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  894. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  895. [Define if have __builtin_types_compatible_p]))
  896. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  897. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  898. [Define if __attribute__((warn_unused_result))]))
  899. AC_MSG_CHECKING([for roundl function])
  900. save_LIBS="${LIBS}"
  901. LIBS="$LIBS -lm"
  902. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  903. #include <math.h>
  904. ]], [[
  905. return (roundl(*(long double *)0xdeadbeef) == 1.0);
  906. ]])], [
  907. AC_MSG_RESULT([yes])
  908. ], [
  909. AC_MSG_RESULT([no])
  910. AC_DEFINE([NEED_ROUNDL], [1], [Defined to 1 if C99 roundl is missing])
  911. ])
  912. LIBS="${save_LIBS}"
  913. # byteswap functions
  914. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  915. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  916. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  917. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  918. BSWAP=''
  919. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  920. AC_MSG_CHECKING([for ${sym}* functions])
  921. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  922. BFG_INCLUDE([headerinclude], [${headerfile}])
  923. AC_LINK_IFELSE([
  924. AC_LANG_PROGRAM([
  925. ${headerinclude}
  926. ], [
  927. (void) ${sym}16(0);
  928. (void) ${sym}32(0);
  929. (void) ${sym}64(0);
  930. ])
  931. ], [
  932. BSWAP="${sym}"
  933. if test "x${headerfile}" = "x"; then
  934. AC_MSG_RESULT([yes])
  935. else
  936. AC_MSG_RESULT([found in ${headerfile}])
  937. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  938. fi
  939. break 2
  940. ])
  941. done
  942. AC_MSG_RESULT([no])
  943. done
  944. if test "x$BSWAP" = "x"; then
  945. true # Substitutes are provided in miner.h
  946. elif test "x$BSWAP" = "xbswap_"; then
  947. AC_MSG_CHECKING([if bswap_16 is already a macro])
  948. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  949. AC_MSG_RESULT([yes])
  950. BSWAP=""
  951. ],[
  952. AC_MSG_RESULT([no])
  953. ])
  954. fi
  955. if test "x$BSWAP" != "x"; then
  956. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  957. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  958. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  959. fi
  960. # endian definition macros
  961. AC_MSG_CHECKING([for platform endian])
  962. found_endian=no
  963. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  964. for pfx in '' '__'; do
  965. 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}, [
  966. if test "x$headerfile" = "x"; then
  967. headerfilec=''
  968. else
  969. headerfilec=" (${headerfile})"
  970. fi
  971. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  972. AC_MSG_RESULT([big endian${headerfilec}])
  973. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  974. ], [
  975. AC_MSG_RESULT([little endian${headerfilec}])
  976. ])
  977. found_endian=yes
  978. break 2
  979. ],[true])
  980. done
  981. done
  982. if test "x$found_endian" = "xno"; then
  983. if $have_win32 || $have_cygwin; then
  984. AC_MSG_RESULT([assuming little endian (Windows)])
  985. else
  986. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  987. AC_MSG_RESULT([unknown])
  988. AC_MSG_ERROR([Unable to identify platform endian])
  989. fi
  990. fi
  991. AC_MSG_CHECKING([if GNU format attribute compiles])
  992. AC_TRY_COMPILE([
  993. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  994. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  995. int myfunc(char *fmt, ...) {
  996. return 42;
  997. }
  998. ], [
  999. myfunc("abc%d", 42);
  1000. ], [
  1001. AC_MSG_RESULT([yes])
  1002. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  1003. ], [
  1004. AC_MSG_RESULT([no])
  1005. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  1006. ])
  1007. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC)])
  1008. AC_TRY_COMPILE([
  1009. #define _GNU_SOURCE
  1010. #include <time.h>
  1011. ],[
  1012. struct timespec ts;
  1013. clock_gettime(CLOCK_MONOTONIC, &ts);
  1014. ],[
  1015. AC_MSG_RESULT([yes])
  1016. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC) is defined])
  1017. save_LIBS="${LIBS}"
  1018. AC_SEARCH_LIBS([clock_gettime],[rt posix4],[
  1019. if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then
  1020. RT_LIBS="${ac_cv_search_clock_gettime}"
  1021. fi
  1022. ])
  1023. LIBS="${save_LIBS}"
  1024. AC_CHECK_FUNCS([clock_nanosleep])
  1025. AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC_RAW)])
  1026. AC_TRY_COMPILE([
  1027. #define _GNU_SOURCE
  1028. #include <time.h>
  1029. ],[
  1030. struct timespec ts;
  1031. clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  1032. ],[
  1033. AC_MSG_RESULT([yes])
  1034. AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC_RAW], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC_RAW) is defined])
  1035. ],[
  1036. AC_MSG_RESULT([no])
  1037. ])
  1038. ],[
  1039. AC_MSG_RESULT([no])
  1040. ])
  1041. if test "x$prefix" = xNONE; then
  1042. prefix=/usr/local
  1043. fi
  1044. AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono])
  1045. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel])
  1046. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel])
  1047. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel])
  1048. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel])
  1049. AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
  1050. AC_SUBST(PTHREAD_FLAGS)
  1051. AC_SUBST(DLOPEN_FLAGS)
  1052. AC_SUBST(PTHREAD_LIBS)
  1053. AC_SUBST(NCURSES_CPPFLAGS)
  1054. AC_SUBST(NCURSES_LIBS)
  1055. AC_SUBST(PDCURSES_LIBS)
  1056. AC_SUBST(WS2_LIBS)
  1057. AC_SUBST(MM_LIBS)
  1058. AC_SUBST(MATH_LIBS)
  1059. AC_SUBST(RT_LIBS)
  1060. AC_SUBST(UDEV_LIBS)
  1061. AC_SUBST(SSE2_CFLAGS)
  1062. AC_SUBST(YASM_FMT)
  1063. AC_CONFIG_FILES([
  1064. Makefile
  1065. x86_64/Makefile
  1066. x86_32/Makefile
  1067. ccan/Makefile
  1068. lib/Makefile
  1069. ])
  1070. AC_OUTPUT
  1071. echo
  1072. echo
  1073. echo
  1074. echo "------------------------------------------------------------------------"
  1075. echo "$PACKAGE $VERSION"
  1076. echo "------------------------------------------------------------------------"
  1077. echo
  1078. echo
  1079. echo "Configuration Options Summary:"
  1080. echo
  1081. m4_define([BFG_PRINT_LIST],[
  1082. eval _mylist="\$$2"
  1083. _yeslist=
  1084. _nolist=
  1085. _enableactions=
  1086. for _opt in $_mylist; do
  1087. IFS=/ read _opt _var <<EOF
  1088. $_opt
  1089. EOF
  1090. test -n "$_var" || _var="$_opt"
  1091. eval "_val=\"\$${_var}\""
  1092. if test "x$_val" = "xno" || test "x$_val" = "xfalse"; then
  1093. _nolist="$_nolist $_opt"
  1094. eval "_enableaction=\"\$${_var}_enableaction\""
  1095. if test -n "$_enableaction"; then
  1096. _enableactions="${_enableactions}~ To enable ${_opt}, ${_enableaction}"
  1097. fi
  1098. else
  1099. _yeslist="$_yeslist $_opt"
  1100. fi
  1101. done
  1102. _yeslist=`echo "$_yeslist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1103. _nolist=`echo "$_nolist" | tr ' ' '\n' | sort | tr '\n' ' '`
  1104. echo " Enabled..$1..:$_yeslist"
  1105. echo " Disabled.$1..:$_nolist"
  1106. if test -n "$_enableactions"; then
  1107. echo "${_enableactions:1}" | tr '~' '\n'
  1108. fi
  1109. ])
  1110. BFG_PRINT_LIST([Drivers...],[driverlist])
  1111. BFG_PRINT_LIST([Algorithms],[algolist])
  1112. BFG_PRINT_LIST([Options...],[optlist])
  1113. echo
  1114. echo "Compilation............: make (or gmake)"
  1115. echo " CFLAGS...............: $CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libblkmaker_CFLAGS"
  1116. 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"
  1117. echo
  1118. echo "Installation...........: make install$maybe_ldconfig #(as root if needed, with 'su' or 'sudo')"
  1119. echo " prefix...............: $prefix"
  1120. echo