configure.ac 14 KB

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