configure.ac 35 KB

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