configure.ac 27 KB

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