configure.ac 23 KB

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