configure.ac 21 KB

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