configure.ac 24 KB

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