configure.ac 36 KB

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