configure.ac 28 KB

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