configure.ac 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  2. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  3. m4_define([v_maj], [2])
  4. m4_define([v_min], [3])
  5. m4_define([v_mic], [3])
  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.59)
  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_GNU_SOURCE
  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
  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_FUNC_ALLOCA
  53. have_win32=false
  54. PTHREAD_FLAGS="-lpthread"
  55. USB_LIBS=""
  56. USB_FLAGS=""
  57. DLOPEN_FLAGS="-ldl"
  58. OPENCL_LIBS="-lOpenCL"
  59. WS2_LIBS=""
  60. MATH_LIBS="-lm"
  61. case $target in
  62. x86_64-*)
  63. have_x86_64=true
  64. ;;
  65. *)
  66. have_x86_64=false
  67. ;;
  68. esac
  69. case $target in
  70. x86_64-w64-mingw32)
  71. have_x86_64=true
  72. have_win32=true
  73. PTHREAD_FLAGS=""
  74. DLOPEN_FLAGS=""
  75. WS2_LIBS="-lws2_32"
  76. ;;
  77. *-*-mingw*)
  78. have_x86_64=false
  79. have_win32=true
  80. PTHREAD_FLAGS=""
  81. DLOPEN_FLAGS=""
  82. WS2_LIBS="-lws2_32"
  83. ;;
  84. powerpc-*-darwin*)
  85. CFLAGS="$CFLAGS -faltivec"
  86. OPENCL_LIBS=""
  87. PTHREAD_FLAGS=""
  88. ;;
  89. *-*-darwin*)
  90. OPENCL_LIBS="-framework OpenCL"
  91. PTHREAD_FLAGS=""
  92. ;;
  93. esac
  94. if test "x$ATISTREAMSDKROOT" != x; then
  95. if test "x$have_x86_64" = xtrue; then
  96. ATI_STREAM_ARCH_DIR=x86_64
  97. else
  98. ATI_STREAM_ARCH_DIR=x86
  99. fi
  100. OPENCL_FLAGS="-I$ATISTREAMSDKROOT/include $OPENCL_FLAGS"
  101. OPENCL_LIBS="-L$ATISTREAMSDKROOT/lib/$ATI_STREAM_ARCH_DIR $OPENCL_LIBS"
  102. fi
  103. cpumining="no"
  104. AC_ARG_ENABLE([cpumining],
  105. [AC_HELP_STRING([--enable-cpumining],[Build with cpu mining support(default disabled)])],
  106. [cpumining=$enableval]
  107. )
  108. if test "x$cpumining" = xyes; then
  109. AC_DEFINE_UNQUOTED([WANT_CPUMINE], [1], [Enable CPUMINING])
  110. fi
  111. AM_CONDITIONAL([HAS_CPUMINE], [test x$cpumining = xyes])
  112. opencl="yes"
  113. AC_ARG_ENABLE([opencl],
  114. [AC_HELP_STRING([--disable-opencl],[Override detection and disable building with opencl])],
  115. [opencl=$enableval]
  116. )
  117. if test "x$opencl" != xno; then
  118. # Check for OpenCL (the long way needed on mingw32 due to calling conventions)
  119. AC_MSG_CHECKING([for OpenCL])
  120. SAVED_LIBS=$LIBS
  121. SAVED_CFLAGS=$CFLAGS
  122. LIBS="$LIBS $OPENCL_LIBS"
  123. CFLAGS="$CFLAGS $OPENCL_FLAGS"
  124. AC_LINK_IFELSE(
  125. [AC_LANG_PROGRAM([[
  126. #ifdef __APPLE_CC__
  127. #include <OpenCL/opencl.h>
  128. #else
  129. #include <CL/cl.h>
  130. #endif
  131. ]],
  132. [[return clSetKernelArg(0, 0, 0, 0); ]])],
  133. [AC_MSG_RESULT(yes)
  134. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL is present on the system.])
  135. found_opencl=1
  136. ],
  137. [AC_MSG_RESULT(no)
  138. OPENCL_FLAGS=
  139. OPENCL_LIBS=
  140. found_opencl=0])
  141. LIBS=$SAVED_LIBS
  142. CFLAGS=$SAVED_CFLAGS
  143. else
  144. OPENCL_FLAGS=""
  145. OPENCL_LIBS=""
  146. fi
  147. AC_CHECK_LIB(pthread, pthread_create, ,
  148. AC_MSG_ERROR([Could not find pthread library - please install libpthread]))
  149. PTHREAD_LIBS=-lpthread
  150. AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
  151. AC_ARG_ENABLE([adl],
  152. [AC_HELP_STRING([--disable-adl],[Override detection and disable building with adl])],
  153. [adl=$enableval]
  154. )
  155. if test "$found_opencl" = 1; then
  156. if test "x$adl" != xno; then
  157. AC_CHECK_FILE([ADL_SDK/adl_sdk.h], have_adl=true, have_adl=false,)
  158. if test x$have_adl = xtrue
  159. then
  160. AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
  161. else
  162. DLOPEN_FLAGS=""
  163. fi
  164. fi
  165. else
  166. DLOPEN_FLAGS=""
  167. fi
  168. bitforce="no"
  169. AC_ARG_ENABLE([bitforce],
  170. [AC_HELP_STRING([--enable-bitforce],[Compile support for BitForce FPGAs(default disabled)])],
  171. [bitforce=$enableval]
  172. )
  173. if test "x$bitforce" = xyes; then
  174. AC_DEFINE([USE_BITFORCE], [1], [Defined to 1 if BitForce support is wanted])
  175. fi
  176. AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
  177. icarus="no"
  178. AC_ARG_ENABLE([icarus],
  179. [AC_HELP_STRING([--enable-icarus],[Compile support for Icarus (default disabled)])],
  180. [icarus=$enableval]
  181. )
  182. if test "x$icarus" = xyes; then
  183. AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
  184. fi
  185. AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
  186. ztex="no"
  187. AC_ARG_ENABLE([ztex],
  188. [AC_HELP_STRING([--enable-ztex],[Compile support for Ztex (default disabled)])],
  189. [ztex=$enableval]
  190. )
  191. if test "x$ztex" = xyes; then
  192. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if Ztex support is wanted])
  193. fi
  194. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  195. curses="auto"
  196. AC_ARG_WITH([curses],
  197. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  198. [curses=$withval]
  199. )
  200. if test "x$curses" = "xno"; then
  201. cursesmsg='User specified --without-curses. TUI support DISABLED'
  202. else
  203. AC_SEARCH_LIBS(addstr, ncurses pdcurses, [
  204. curses=yes
  205. cursesmsg="FOUND: ${ac_cv_search_addstr:2}"
  206. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  207. ], [
  208. if test "x$curses" = "xyes"; then
  209. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  210. else
  211. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  212. curses=no
  213. cursesmsg='NOT FOUND. TUI support DISABLED'
  214. fi
  215. ])
  216. fi
  217. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  218. AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
  219. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  220. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  221. if test x$request_jansson = xtrue
  222. then
  223. JANSSON_LIBS="compat/jansson/libjansson.a"
  224. else
  225. JANSSON_LIBS=-ljansson
  226. fi
  227. dnl Find YASM
  228. has_yasm=false
  229. AC_PATH_PROG([YASM],[yasm],[false])
  230. if test "x$YASM" != "xfalse" ; then
  231. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  232. yasmver=`yasm --version | head -1 | cut -d\ -f2`
  233. yamajor=`echo $yasmver | cut -d. -f1`
  234. yaminor=`echo $yasmver | cut -d. -f2`
  235. yamini=`echo $yasmver | cut -d. -f3`
  236. if test "$yamajor" -ge "1" ; then
  237. if test "$yamajor" -eq "1" ; then
  238. if test "$yaminor" -ge "0" ; then
  239. if test "$yaminor" -eq "0"; then
  240. if test "$yamini" -ge "1"; then
  241. has_yasm=true
  242. fi
  243. else
  244. has_yasm=true
  245. fi
  246. fi
  247. fi
  248. else
  249. has_yasm=false
  250. fi
  251. if test "x$has_yasm" = "xtrue" ; then
  252. AC_MSG_RESULT([yes])
  253. else
  254. AC_MSG_RESULT([no])
  255. fi
  256. fi
  257. if test "x$has_yasm" = "xfalse" ; then
  258. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  259. fi
  260. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  261. if test "x$bitforce" != xno; then
  262. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  263. [libudev=$withval],
  264. [libudev=auto]
  265. )
  266. if test "x$libudev" != "xno"; then
  267. AC_CHECK_HEADER([libudev.h],[
  268. libudev=yes
  269. UDEV_LIBS=-ludev
  270. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  271. ], [
  272. if test "x$libudev" = "xyes"; then
  273. AC_MSG_ERROR([libudev not found])
  274. fi
  275. libudev=no
  276. ])
  277. fi
  278. fi
  279. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  280. if test "x$ztex" != xno; then
  281. AC_CHECK_LIB(usb-1.0, libusb_init, ,
  282. AC_MSG_ERROR([Could not find usb library - please install libusb]))
  283. AC_DEFINE([HAVE_LIBUSB], [1], [Defined to 1 if libusb is wanted])
  284. USB_LIBS="-lusb-1.0"
  285. USB_FLAGS=""
  286. fi
  287. PKG_PROG_PKG_CONFIG()
  288. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.15.6], [AC_DEFINE([CURL_HAS_SOCKOPT], [1], [Defined if version of curl supports sockopts.])],
  289. [PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.10.1], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.10.1])])])
  290. AC_SUBST(LIBCURL_LIBS)
  291. dnl CCAN wants to know a lot of vars.
  292. # All the configuration checks. Regrettably, the __attribute__ checks will
  293. # give false positives on old GCCs, since they just cause warnings. But that's
  294. # fairly harmless.
  295. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  296. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  297. [Define if __attribute__((cold))]))
  298. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  299. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  300. [Define if __attribute__((const))]))
  301. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  302. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  303. [Define if __attribute__((noreturn))]))
  304. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  305. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  306. [Define if __attribute__((format(__printf__)))]))
  307. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  308. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  309. [Define if __attribute__((unused))]))
  310. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  311. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  312. [Define if __attribute__((used))]))
  313. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  314. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  315. [Define if have __builtin_constant_p]))
  316. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  317. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  318. [Define if have __builtin_types_compatible_p]))
  319. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  320. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  321. [Define if __attribute__((warn_unused_result))]))
  322. if test "x$prefix" = xNONE; then
  323. prefix=/usr/local
  324. fi
  325. AC_DEFINE_UNQUOTED([CGMINER_PREFIX], ["$prefix/bin"], [Path to bfgminer install])
  326. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk120223"], [Filename for phatk kernel])
  327. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm120327"], [Filename for poclbm kernel])
  328. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn120223"], [Filename for diakgcn kernel])
  329. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo120328"], [Filename for diablo kernel])
  330. AC_SUBST(OPENCL_LIBS)
  331. AC_SUBST(OPENCL_FLAGS)
  332. AC_SUBST(JANSSON_LIBS)
  333. AC_SUBST(PTHREAD_FLAGS)
  334. AC_SUBST(DLOPEN_FLAGS)
  335. AC_SUBST(PTHREAD_LIBS)
  336. AC_SUBST(NCURSES_LIBS)
  337. AC_SUBST(PDCURSES_LIBS)
  338. AC_SUBST(WS2_LIBS)
  339. AC_SUBST(MATH_LIBS)
  340. AC_SUBST(UDEV_LIBS)
  341. AC_SUBST(USB_LIBS)
  342. AC_SUBST(USB_FLAGS)
  343. AC_CONFIG_FILES([
  344. Makefile
  345. compat/Makefile
  346. compat/jansson/Makefile
  347. x86_64/Makefile
  348. x86_32/Makefile
  349. ccan/Makefile
  350. lib/Makefile
  351. ])
  352. AC_OUTPUT
  353. echo
  354. echo
  355. echo
  356. echo "------------------------------------------------------------------------"
  357. echo "$PACKAGE $VERSION"
  358. echo "------------------------------------------------------------------------"
  359. echo
  360. echo
  361. echo "Configuration Options Summary:"
  362. echo
  363. echo " curses.TUI...........: $cursesmsg"
  364. if test "x$opencl" != xno; then
  365. if test $found_opencl = 1; then
  366. echo " OpenCL...............: FOUND. GPU mining support enabled"
  367. else
  368. echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED"
  369. if test "x$cpumining$bitforce$icarus$ztex" = xnononono; then
  370. AC_MSG_ERROR([No mining configured in])
  371. fi
  372. fi
  373. else
  374. echo " OpenCL...............: Detection overrided. GPU mining support DISABLED"
  375. if test "x$cpumining$bitforce$icarus$ztex" = xnononono; then
  376. AC_MSG_ERROR([No mining configured in])
  377. fi
  378. fi
  379. if test "x$adl" != xno; then
  380. if test x$have_adl = xtrue; then
  381. echo " ADL..................: SDK found, GPU monitoring support enabled"
  382. else
  383. echo " ADL..................: SDK NOT found, GPU monitoring support DISABLED"
  384. fi
  385. else
  386. echo " ADL..................: Detection overrided. GPU monitoring support DISABLED"
  387. fi
  388. echo
  389. if test "x$bitforce" = xyes; then
  390. echo " BitForce.FPGAs.......: Enabled"
  391. else
  392. echo " BitForce.FPGAs.......: Disabled"
  393. fi
  394. if test "x$icarus" = xyes; then
  395. echo " Icarus.FPGAs.........: Enabled"
  396. else
  397. echo " Icarus.FPGAs.........: Disabled"
  398. fi
  399. if test "x$ztex" = xyes; then
  400. echo " Ztex.FPGAs...........: Enabled"
  401. else
  402. echo " Ztex.FPGAs...........: Disabled"
  403. fi
  404. if test "x$bitforce" != xno; then
  405. echo " libudev.detection....: $libudev"
  406. fi
  407. if test "x$cpumining" = xyes; then
  408. echo
  409. echo " CPU Mining...........: Enabled"
  410. echo " ASM.(for CPU mining).: $has_yasm"
  411. fi
  412. echo
  413. echo "Compilation............: make (or gmake)"
  414. echo " CPPFLAGS.............: $CPPFLAGS"
  415. echo " CFLAGS...............: $CFLAGS"
  416. echo " LDFLAGS..............: $LDFLAGS $PTHREAD_FLAGS $USB_FLAGS"
  417. echo " LDADD................: $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $PTHREAD_LIBS $OPENCL_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $UDEV_LIBS $USB_LIBS"
  418. echo
  419. echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
  420. echo " prefix...............: $prefix"
  421. echo