configure.ac 37 KB

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