configure.ac 28 KB

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