configure.ac 21 KB

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