configure.ac 13 KB

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