configure.ac 35 KB

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