configure.ac 24 KB

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