configure.ac 22 KB

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