configure.ac 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  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. ################################################################################
  265. AC_ARG_ENABLE([bf1],
  266. [AC_HELP_STRING([--disable-bf1],[Compile support for Bitfury BF1 (default enabled)])],
  267. [bf1=$enableval],
  268. [bf1=yes]
  269. )
  270. if test "x$bf1" = xyes; then
  271. AC_DEFINE([USE_BF1], [1], [Defined to 1 if Bitfury BF1 support is wanted])
  272. fi
  273. AM_CONDITIONAL([HAS_BF1], [test x$bf1 = xyes])
  274. AC_ARG_ENABLE([bitforce],
  275. [AC_HELP_STRING([--disable-bitforce],[Compile support for BitForce (default enabled)])],
  276. [bitforce=$enableval],
  277. [bitforce=yes]
  278. )
  279. if test "x$bitforce" = xyes; then
  280. AC_DEFINE([USE_BITFORCE], [1], [Defined to 1 if BitForce support is wanted])
  281. fi
  282. AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
  283. AC_ARG_ENABLE([icarus],
  284. [AC_HELP_STRING([--disable-icarus],[Compile support for Icarus (default enabled)])],
  285. [icarus=$enableval],
  286. [icarus=yes]
  287. )
  288. if test "x$icarus" = xyes; then
  289. AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
  290. fi
  291. AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
  292. avalon="no"
  293. AC_ARG_ENABLE([avalon],
  294. [AC_HELP_STRING([--disable-avalon],[Compile support for Avalon (default enabled)])],
  295. [avalon=$enableval],
  296. [avalon=yes]
  297. )
  298. if test "x$avalon" = xyes; then
  299. AC_DEFINE([USE_AVALON], [1], [Defined to 1 if Avalon support is wanted])
  300. fi
  301. AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes])
  302. AC_ARG_ENABLE([modminer],
  303. [AC_HELP_STRING([--disable-modminer],[Compile support for ModMiner (default enabled)])],
  304. [modminer=$enableval],
  305. [modminer=yes]
  306. )
  307. if test "x$modminer" = xyes; then
  308. AC_DEFINE([USE_MODMINER], [1], [Defined to 1 if ModMiner support is wanted])
  309. fi
  310. AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes])
  311. PKG_PROG_PKG_CONFIG()
  312. libusb=no
  313. libusb_include_path=""
  314. PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[
  315. libusb=yes
  316. ],[
  317. for usb_lib in usb-1.0 usb; do
  318. AC_CHECK_LIB($usb_lib, libusb_init, [
  319. libusb=yes
  320. break
  321. ], [])
  322. done
  323. if test "x$libusb" = xyes; then
  324. AC_CHECK_DECL([libusb_init],[
  325. true
  326. ],[
  327. AC_PROG_CPP
  328. AC_MSG_CHECKING([whether libusb_init is declared in subdirectory])
  329. libusb_include_path=`echo '#include <libusb-1.0/libusb.h>' | ${CPP} -M - 2>/dev/null | sed 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]]\+\)\/.*$/\1/;t;d'`
  330. if test "x$libusb_include_path" != "x"; then
  331. LIBUSB_LIBS="-l$usb_lib"
  332. LIBUSB_CFLAGS="-I$libusb_include_path"
  333. AC_MSG_RESULT([yes])
  334. else
  335. libusb=no
  336. AC_MSG_RESULT([no])
  337. fi
  338. ],[#include <libusb.h>])
  339. fi
  340. ])
  341. AC_ARG_ENABLE([x6500],
  342. [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])],
  343. [x6500=$enableval],
  344. [x6500=auto]
  345. )
  346. if test "x$x6500$libusb" = xyesno; then
  347. AC_MSG_ERROR([Could not find libusb, required for X6500 support])
  348. elif test "x$x6500" = xauto; then
  349. x6500="$libusb"
  350. if test "x$libusb" = xno; then
  351. AC_MSG_WARN([Could not find libusb, required for X6500 support])
  352. x6500warn=yes
  353. fi
  354. fi
  355. if test "x$x6500" = xyes; then
  356. AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted])
  357. fi
  358. AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes])
  359. AC_ARG_ENABLE([ztex],
  360. [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])],
  361. [ztex=$enableval],
  362. [ztex=auto]
  363. )
  364. if test "x$ztex$libusb" = xyesno; then
  365. AC_MSG_ERROR([Could not find libusb, required for ZTEX support])
  366. elif test "x$ztex" = xauto; then
  367. ztex="$libusb"
  368. if test "x$libusb" = xno; then
  369. AC_MSG_WARN([Could not find libusb, required for ZTEX support])
  370. ztexwarn=yes
  371. fi
  372. fi
  373. if test "x$ztex" = xyes; then
  374. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted])
  375. fi
  376. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  377. if test "x$x6500$ztex" = "xnono"; then
  378. libusb=no
  379. LIBUSB_LIBS=''
  380. LIBUSB_CFLAGS=''
  381. fi
  382. if test "x$libusb" = xyes; then
  383. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  384. save_CFLAGS="$CFLAGS"
  385. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  386. AC_CHECK_DECLS([libusb_error_name],[],[],[#include <libusb.h>])
  387. CFLAGS="$save_CFLAGS"
  388. fi
  389. scrypt="no"
  390. AC_ARG_ENABLE([scrypt],
  391. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  392. [scrypt=$enableval]
  393. )
  394. if test "x$scrypt" = xyes; then
  395. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  396. fi
  397. need_fpgautils=no
  398. if test x$avalon$icarus$bitforce$modminer$opencl$x6500$ztex != xnonononononono; then
  399. need_fpgautils=yes
  400. if $have_win32; then
  401. echo '#include <iospeeds.h>' >iospeeds_local.h
  402. else
  403. AC_PROG_CPP
  404. AC_MSG_CHECKING([what baud rates your system supports])
  405. echo '#include <termios.h>' | ${CPP} -dM - 2>/dev/null | sed 's/.* B\([0-9]\+\) .*/IOSPEED(\1)/;t;d' >iospeeds_local.h
  406. if grep -q IOSPEED iospeeds_local.h; then
  407. AC_MSG_RESULT([done])
  408. else
  409. AC_MSG_RESULT([failed, using standard POSIX])
  410. echo '#include <iospeeds_posix.h>' >iospeeds_local.h
  411. fi
  412. fi
  413. fi
  414. curses="auto"
  415. AC_ARG_WITH([curses],
  416. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  417. [curses=$withval]
  418. )
  419. if test "x$curses" = "xno"; then
  420. cursesmsg='User specified --without-curses. TUI support DISABLED'
  421. else
  422. orig_libs="$LIBS"
  423. if test "x${curses}" = "xyes"; then
  424. prefer=''
  425. preferl=''
  426. else
  427. prefer="${curses}"
  428. preferl="${curses} ${curses}6 ${curses}5"
  429. fi
  430. if test "x$cross_compiling" != "xyes"; then
  431. AC_MSG_CHECKING([for best native curses library])
  432. orig_cflags="$CFLAGS"
  433. for curses_lib in ${preferl} ncurses{w,}{,6,5}; do
  434. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  435. continue
  436. fi
  437. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  438. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  439. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  440. #include <curses.h>
  441. ]], [[
  442. WINDOW *w = NULL;
  443. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  444. ]])], [
  445. curses=yes
  446. cursesmsg="FOUND: ${curses_lib}"
  447. AC_MSG_RESULT([$curses_lib])
  448. NCURSES_LIBS=`${curses_lib}-config --libs`
  449. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  450. break
  451. ], [
  452. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  453. ])
  454. done
  455. CFLAGS="$orig_cflags"
  456. if test "x$curses" != "xyes"; then
  457. AC_MSG_RESULT([none?])
  458. fi
  459. fi
  460. if test "x$curses" != "xyes"; then
  461. AC_SEARCH_LIBS(addstr, ${prefer} ncursesw ncurses pdcurses, [
  462. curses=yes
  463. cursesmsg="FOUND: ${ac_cv_search_addstr}"
  464. cursesmsg="${cursesmsg/-l/}"
  465. if test "x${ac_cv_search_addstr}" != "xnone required"; then
  466. NCURSES_LIBS="${ac_cv_search_addstr}"
  467. fi
  468. ], [
  469. if test "x$curses" = "xyes"; then
  470. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  471. else
  472. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  473. curses=no
  474. cursesmsg='NOT FOUND. TUI support DISABLED'
  475. fi
  476. ])
  477. fi
  478. if test "x$curses" = "xyes"; then
  479. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  480. fi
  481. LIBS="$orig_libs"
  482. fi
  483. AC_ARG_WITH([system-libblkmaker], [AC_HELP_STRING([--with-system-libblkmaker], [Use system libblkmaker rather than bundled one (default disabled)])],[],[with_system_libblkmaker=no])
  484. if test "x$with_system_libblkmaker" = "xyes"; then
  485. PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
  486. true
  487. ],[
  488. AC_MSG_ERROR([Could not find system libblkmaker])
  489. ])
  490. else
  491. save_LDFLAGS="$LDFLAGS"
  492. LDFLAGS="$LDFLAGS -Wl,-zorigin"
  493. origin_LDFLAGS=
  494. AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
  495. AC_TRY_LINK([],[],[
  496. AC_MSG_RESULT([yes])
  497. origin_LDFLAGS=',-zorigin'
  498. ],[
  499. AC_MSG_RESULT([no])
  500. ])
  501. LDFLAGS="$save_LDFLAGS"
  502. libblkmaker_CFLAGS='-Ilibblkmaker'
  503. libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS"
  504. libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
  505. AC_CONFIG_SUBDIRS([libblkmaker])
  506. fi
  507. AC_SUBST(libblkmaker_CFLAGS)
  508. AC_SUBST(libblkmaker_LDFLAGS)
  509. AC_SUBST(libblkmaker_LIBS)
  510. AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
  511. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$icarus$modminer$x6500$ztex != xnonono])
  512. AM_CONDITIONAL([NEED_FPGAUTILS], [test x$need_fpgautils = xyes])
  513. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  514. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  515. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  516. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  517. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  518. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  519. AM_CONDITIONAL([HAS_FPGA], [test x$bitforce$icarus$modminer$x6500$ztex != xnonononono])
  520. dnl Find YASM
  521. has_yasm=false
  522. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  523. AC_PATH_PROG([YASM],[yasm],[false])
  524. if test "x$YASM" != "xfalse" ; then
  525. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  526. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  527. yamajor=`echo $yasmver | cut -d. -f1`
  528. yaminor=`echo $yasmver | cut -d. -f2`
  529. yamini=`echo $yasmver | cut -d. -f3`
  530. if test "$yamajor" -ge "1" ; then
  531. if test "$yamajor" -eq "1" ; then
  532. if test "$yaminor" -ge "0" ; then
  533. if test "$yaminor" -eq "0"; then
  534. if test "$yamini" -ge "1"; then
  535. has_yasm=true
  536. fi
  537. else
  538. has_yasm=true
  539. fi
  540. fi
  541. fi
  542. else
  543. has_yasm=false
  544. fi
  545. if test "x$has_yasm" = "xtrue" ; then
  546. AC_MSG_RESULT([yes])
  547. else
  548. AC_MSG_RESULT([no])
  549. fi
  550. fi
  551. if test "x$has_yasm" = "xfalse" ; then
  552. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  553. else
  554. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  555. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  556. if test "x$have_x86_64" = xtrue; then
  557. YASM_FMT="win64"
  558. else
  559. YASM_FMT="coff"
  560. fi
  561. elif test "x$have_macho" = "xtrue"; then
  562. YASM_FMT="macho$bitness"
  563. else
  564. YASM_FMT="elf$bitness"
  565. fi
  566. fi
  567. fi
  568. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  569. have_sse2=no
  570. if test "x$cpumining$have_x86_32" = "xyestrue"; then
  571. AC_MSG_CHECKING([if SSE2 code compiles])
  572. save_CFLAGS="$CFLAGS"
  573. for flags in '' '-msse2'; do
  574. CFLAGS="$CFLAGS $flags"
  575. AC_TRY_LINK([
  576. #include <xmmintrin.h>
  577. ],[
  578. int *i = (int *)0xdeadbeef;
  579. __m128i a, b;
  580. a = _mm_set1_epi32(i[0]);
  581. b = _mm_set_epi32(i[0], i[1], i[2], i[3]);
  582. a = _mm_add_epi32(a, b);
  583. a = _mm_andnot_si128(a, b);
  584. a = _mm_or_si128(a, b);
  585. a = _mm_slli_epi32(a, i[4]);
  586. a = _mm_and_si128(a, b);
  587. a = _mm_xor_si128(a, b);
  588. ],[
  589. if test "x$flags" = "x"; then
  590. AC_MSG_RESULT([yes])
  591. else
  592. AC_MSG_RESULT([with $flags])
  593. fi
  594. SSE2_CFLAGS="$flags"
  595. have_sse2=yes
  596. break
  597. ],[
  598. true
  599. ])
  600. done
  601. CFLAGS="${save_CFLAGS}"
  602. if test "x$have_sse2" = "xyes"; then
  603. AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used])
  604. else
  605. AC_MSG_RESULT([no])
  606. fi
  607. fi
  608. AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"])
  609. if test "x$bitforce$modminer$icarus" != "xnonono"; then
  610. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  611. [libudev=$withval],
  612. [libudev=auto]
  613. )
  614. if test "x$libudev" != "xno"; then
  615. AC_CHECK_HEADER([libudev.h],[
  616. libudev=yes
  617. UDEV_LIBS=-ludev
  618. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  619. ], [
  620. if test "x$libudev" = "xyes"; then
  621. AC_MSG_ERROR([libudev not found])
  622. fi
  623. libudev=no
  624. ])
  625. fi
  626. fi
  627. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  628. AC_SUBST(LIBUSB_LIBS)
  629. AC_SUBST(LIBUSB_CFLAGS)
  630. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  631. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  632. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  633. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  634. fi
  635. AC_SUBST(LIBCURL_LIBS)
  636. AC_CHECK_FUNCS([setrlimit])
  637. dnl CCAN wants to know a lot of vars.
  638. # All the configuration checks. Regrettably, the __attribute__ checks will
  639. # give false positives on old GCCs, since they just cause warnings. But that's
  640. # fairly harmless.
  641. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  642. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  643. [Define if __attribute__((cold))]))
  644. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  645. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  646. [Define if __attribute__((const))]))
  647. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  648. [
  649. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  650. [Define if __attribute__((noreturn))])
  651. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  652. ], [
  653. AC_DEFINE_UNQUOTED([NORETURN], [])
  654. ]
  655. )
  656. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  657. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  658. [Define if __attribute__((format(__printf__)))]))
  659. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  660. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  661. [Define if __attribute__((unused))]))
  662. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  663. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  664. [Define if __attribute__((used))]))
  665. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  666. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  667. [Define if have __builtin_constant_p]))
  668. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  669. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  670. [Define if have __builtin_types_compatible_p]))
  671. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  672. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  673. [Define if __attribute__((warn_unused_result))]))
  674. AC_MSG_CHECKING([for roundl function])
  675. save_LIBS="${LIBS}"
  676. LIBS="$LIBS -lm"
  677. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  678. #include <math.h>
  679. ]], [[
  680. return (roundl(*(long double *)0xdeadbeef) == 1.0);
  681. ]])], [
  682. AC_MSG_RESULT([yes])
  683. ], [
  684. AC_MSG_RESULT([no])
  685. AC_DEFINE([NEED_ROUNDL], [1], [Defined to 1 if C99 roundl is missing])
  686. ])
  687. LIBS="${save_LIBS}"
  688. # byteswap functions
  689. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  690. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  691. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  692. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  693. BSWAP=''
  694. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  695. AC_MSG_CHECKING([for ${sym}* functions])
  696. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  697. BFG_INCLUDE([headerinclude], [${headerfile}])
  698. AC_LINK_IFELSE([
  699. AC_LANG_PROGRAM([
  700. ${headerinclude}
  701. ], [
  702. (void) ${sym}16(0);
  703. (void) ${sym}32(0);
  704. (void) ${sym}64(0);
  705. ])
  706. ], [
  707. BSWAP="${sym}"
  708. if test "x${headerfile}" = "x"; then
  709. AC_MSG_RESULT([yes])
  710. else
  711. AC_MSG_RESULT([found in ${headerfile}])
  712. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  713. fi
  714. break 2
  715. ],[])
  716. done
  717. AC_MSG_RESULT([no])
  718. done
  719. if test "x$BSWAP" = "x"; then
  720. true # Substitutes are provided in miner.h
  721. elif test "x$BSWAP" = "xbswap_"; then
  722. AC_MSG_CHECKING([if bswap_16 is already a macro])
  723. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  724. AC_MSG_RESULT([yes])
  725. BSWAP=""
  726. ],[
  727. AC_MSG_RESULT([no])
  728. ])
  729. fi
  730. if test "x$BSWAP" != "x"; then
  731. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  732. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  733. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  734. fi
  735. # endian definition macros
  736. AC_MSG_CHECKING([for platform endian])
  737. found_endian=no
  738. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  739. for pfx in '' '__'; do
  740. 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}, [
  741. if test "x$headerfile" = "x"; then
  742. headerfilec=''
  743. else
  744. headerfilec=" (${headerfile})"
  745. fi
  746. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  747. AC_MSG_RESULT([big endian${headerfilec}])
  748. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  749. ], [
  750. AC_MSG_RESULT([little endian${headerfilec}])
  751. ])
  752. found_endian=yes
  753. break 2
  754. ],[true])
  755. done
  756. done
  757. if test "x$found_endian" = "xno"; then
  758. if $have_win32 || $have_cygwin; then
  759. AC_MSG_RESULT([assuming little endian (Windows)])
  760. else
  761. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  762. AC_MSG_RESULT([unknown])
  763. AC_MSG_ERROR([Unable to identify platform endian])
  764. fi
  765. fi
  766. AC_MSG_CHECKING([if GNU format attribute compiles])
  767. AC_TRY_COMPILE([
  768. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  769. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  770. int myfunc(char *fmt, ...) {
  771. return 42;
  772. }
  773. ], [
  774. myfunc("abc%d", 42);
  775. ], [
  776. AC_MSG_RESULT([yes])
  777. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  778. ], [
  779. AC_MSG_RESULT([no])
  780. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  781. ])
  782. if test "x$prefix" = xNONE; then
  783. prefix=/usr/local
  784. fi
  785. AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono])
  786. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel])
  787. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel])
  788. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel])
  789. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel])
  790. AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
  791. AC_SUBST(PTHREAD_FLAGS)
  792. AC_SUBST(DLOPEN_FLAGS)
  793. AC_SUBST(PTHREAD_LIBS)
  794. AC_SUBST(NCURSES_CPPFLAGS)
  795. AC_SUBST(NCURSES_LIBS)
  796. AC_SUBST(PDCURSES_LIBS)
  797. AC_SUBST(WS2_LIBS)
  798. AC_SUBST(MM_LIBS)
  799. AC_SUBST(MATH_LIBS)
  800. AC_SUBST(UDEV_LIBS)
  801. AC_SUBST(SSE2_CFLAGS)
  802. AC_SUBST(YASM_FMT)
  803. AC_CONFIG_FILES([
  804. Makefile
  805. x86_64/Makefile
  806. x86_32/Makefile
  807. ccan/Makefile
  808. lib/Makefile
  809. ])
  810. AC_OUTPUT
  811. echo
  812. echo
  813. echo
  814. echo "------------------------------------------------------------------------"
  815. echo "$PACKAGE $VERSION"
  816. echo "------------------------------------------------------------------------"
  817. echo
  818. echo
  819. echo "Configuration Options Summary:"
  820. echo
  821. echo " curses.TUI...........: $cursesmsg"
  822. if test "x$scrypt" != xno; then
  823. echo " scrypt...............: Enabled"
  824. else
  825. echo " scrypt...............: Disabled"
  826. fi
  827. echo
  828. if test "x$opencl" = xyes; then
  829. echo " OpenCL...............: Enabled"
  830. else
  831. echo " OpenCL...............: Disabled"
  832. fi
  833. if test "x$with_sensors" = xyes; then
  834. echo " sensors.monitoring.: Enabled"
  835. elif test "x$opencl" = xyes; then
  836. echo " sensors.monitoring.: Disabled"
  837. else
  838. echo " sensors.monitoring.: n/a"
  839. fi
  840. if test "x$adl" = xyes; then
  841. echo " ADL.monitoring.....: Enabled"
  842. elif test "x$opencl" = xyes; then
  843. echo " ADL.monitoring.....: Disabled"
  844. else
  845. echo " ADL.monitoring.....: n/a"
  846. fi
  847. if test "x$avalon" = xyes; then
  848. echo " Avalon.ASICs.........: Enabled"
  849. else
  850. echo " Avalon.ASICs.........: Disabled"
  851. fi
  852. if test "x$bf1" = xyes; then
  853. echo " Bitfury BF1.ASICs....: Enabled"
  854. else
  855. echo " Bitfury BF1.ASICs....: Disabled"
  856. fi
  857. if test "x$bitforce" = xyes; then
  858. echo " BitForce.devices.....: Enabled"
  859. else
  860. echo " BitForce.devices.....: Disabled"
  861. fi
  862. if test "x$icarus" = xyes; then
  863. echo " Icarus.FPGAs.........: Enabled"
  864. else
  865. echo " Icarus.FPGAs.........: Disabled"
  866. fi
  867. if test "x$modminer" = xyes; then
  868. echo " ModMiner.FPGAs.......: Enabled"
  869. else
  870. echo " ModMiner.FPGAs.......: Disabled"
  871. fi
  872. if test "x$x6500" = xyes; then
  873. echo " X6500.FPGAs..........: Enabled"
  874. elif test "x$ztexwarn" = xyes; then
  875. echo " X6500.FPGAs..........: Disabled (libusb not found)"
  876. else
  877. echo " X6500.FPGAs..........: Disabled"
  878. fi
  879. if test "x$ztex" = xyes; then
  880. echo " ZTEX.FPGAs...........: Enabled"
  881. elif test "x$ztexwarn" = xyes; then
  882. echo " ZTEX.FPGAs...........: Disabled (libusb not found)"
  883. else
  884. echo " ZTEX.FPGAs...........: Disabled"
  885. fi
  886. if test "x$bitforce$modminer" != xnono; then
  887. echo " libudev.detection....: $libudev"
  888. fi
  889. echo
  890. if test "x$cpumining" = xyes; then
  891. echo " CPU Mining...........: Enabled"
  892. echo " ASM.(for CPU mining).: $has_yasm"
  893. else
  894. echo " CPU Mining...........: Disabled"
  895. fi
  896. echo
  897. echo "Compilation............: make (or gmake)"
  898. echo " CPPFLAGS.............:" $CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS
  899. echo " CFLAGS...............:" $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS
  900. echo " LDFLAGS..............:" $LDFLAGS $PTHREAD_FLAGS $PTHREAD_LIBS
  901. echo " LDADD................:" $LIBS $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $UDEV_LIBS $LIBUSB_LIBS
  902. echo
  903. echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
  904. echo " prefix...............: $prefix"
  905. echo