configure.ac 13 KB

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