configure.ac 29 KB

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