configure.ac 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  2. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  3. m4_define([v_maj], [1])
  4. m4_define([v_min], [9])
  5. m4_define([v_mic], [9])
  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([main.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="-pthread"
  54. OPENCL_FLAGS="-lOpenCL"
  55. WS2_LIBS=""
  56. case $target in
  57. x86_64-*)
  58. have_x86_64=true
  59. ;;
  60. *)
  61. have_x86_64=false
  62. ;;
  63. esac
  64. case $target in
  65. *-*-mingw*)
  66. have_x86_64=false
  67. have_win32=true
  68. PTHREAD_FLAGS=""
  69. WS2_LIBS="-lws2_32"
  70. ;;
  71. *-*-darwin*)
  72. OPENCL_FLAGS="-framework OpenCL"
  73. ;;
  74. esac
  75. AC_ARG_ENABLE([opencl],
  76. [AC_HELP_STRING([--disable-opencl],[Override detection and disable building with opencl])],
  77. [opencl=$enableval]
  78. )
  79. if test "x$opencl" != xno; then
  80. # Check for OpenCL (the long way needed on mingw32 due to calling conventions)
  81. AC_MSG_CHECKING([for OpenCL])
  82. SAVED_LIBS=$LIBS
  83. LIBS="$LIBS $OPENCL_FLAGS"
  84. AC_LINK_IFELSE(
  85. [AC_LANG_PROGRAM([[
  86. #ifdef __APPLE_CC__
  87. #include <OpenCL/opencl.h>
  88. #else
  89. #include <CL/cl.h>
  90. #endif
  91. ]],
  92. [[return clSetKernelArg(0, 0, 0, 0); ]])],
  93. [AC_MSG_RESULT(yes)
  94. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL is present on the system.])
  95. found_opencl=1
  96. OPENCL_LIBS=$OPENCL_FLAGS],
  97. [AC_MSG_RESULT(no)
  98. found_opencl=0])
  99. LIBS=$SAVED_LIBS
  100. fi
  101. AC_CHECK_LIB(pthread, pthread_create, ,
  102. AC_MSG_ERROR([Could not find pthread library - please install libpthread]))
  103. PTHREAD_LIBS=-lpthread
  104. AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
  105. AC_ARG_ENABLE([adl],
  106. [AC_HELP_STRING([--disable-adl],[Override detection and disable building with adl])],
  107. [adl=$enableval]
  108. )
  109. if test "$found_opencl" = 1; then
  110. if test "x$adl" != xno; then
  111. AC_CHECK_FILE([ADL_SDK/adl_sdk.h], have_adl=true, have_adl=false,)
  112. if test x$have_adl = xtrue
  113. then
  114. AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
  115. fi
  116. fi
  117. fi
  118. AC_SEARCH_LIBS(addstr, ncurses pdcurses, ,
  119. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev]))
  120. AC_CHECK_LIB(ncurses, addstr, NCURSES_LIBS=-lncurses)
  121. AC_CHECK_LIB(pdcurses, addstr, PDCURSES_LIBS=-lpdcurses)
  122. AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
  123. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  124. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  125. if test x$request_jansson = xtrue
  126. then
  127. JANSSON_LIBS="compat/jansson/libjansson.a"
  128. else
  129. JANSSON_LIBS=-ljansson
  130. fi
  131. dnl Find YASM
  132. has_yasm=false
  133. AC_PATH_PROG([YASM],[yasm],[false])
  134. if test "x$YASM" != "xfalse" ; then
  135. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  136. yasmver=`yasm --version | head -1 | cut -d\ -f2`
  137. yamajor=`echo $yasmver | cut -d. -f1`
  138. yaminor=`echo $yasmver | cut -d. -f2`
  139. yamini=`echo $yasmver | cut -d. -f3`
  140. if test "$yamajor" -ge "1" ; then
  141. if test "$yamajor" -eq "1" ; then
  142. if test "$yaminor" -ge "0" ; then
  143. if test "$yaminor" -eq "0"; then
  144. if test "$yamini" -ge "1"; then
  145. has_yasm=true
  146. fi
  147. else
  148. has_yasm=true
  149. fi
  150. fi
  151. fi
  152. else
  153. has_yasm=false
  154. fi
  155. if test "x$has_yasm" = "xtrue" ; then
  156. AC_MSG_RESULT([yes])
  157. else
  158. AC_MSG_RESULT([no])
  159. fi
  160. fi
  161. if test "x$has_yasm" = "xfalse" ; then
  162. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  163. fi
  164. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  165. PKG_PROG_PKG_CONFIG()
  166. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.15.6], [AC_DEFINE([CURL_HAS_SOCKOPT], [1], [Defined if version of curl supports sockopts.])],
  167. [PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.10.1], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.10.1])])])
  168. AC_SUBST(LIBCURL_LIBS)
  169. dnl CCAN wants to know a lot of vars.
  170. # All the configuration checks. Regrettably, the __attribute__ checks will
  171. # give false positives on old GCCs, since they just cause warnings. But that's
  172. # fairly harmless.
  173. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  174. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  175. [Define if __attribute__((cold))]))
  176. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  177. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  178. [Define if __attribute__((const))]))
  179. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  180. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  181. [Define if __attribute__((noreturn))]))
  182. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  183. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  184. [Define if __attribute__((format(__printf__)))]))
  185. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  186. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  187. [Define if __attribute__((unused))]))
  188. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  189. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  190. [Define if __attribute__((used))]))
  191. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  192. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  193. [Define if have __builtin_constant_p]))
  194. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  195. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  196. [Define if have __builtin_types_compatible_p]))
  197. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  198. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  199. [Define if __attribute__((warn_unused_result))]))
  200. if test "x$prefix" = xNONE; then
  201. prefix=/usr/local
  202. fi
  203. AC_DEFINE_UNQUOTED([CGMINER_PREFIX], ["$prefix/bin"], [Path to cgminer install])
  204. AC_SUBST(OPENCL_LIBS)
  205. AC_SUBST(JANSSON_LIBS)
  206. AC_SUBST(PTHREAD_FLAGS)
  207. AC_SUBST(PTHREAD_LIBS)
  208. AC_SUBST(NCURSES_LIBS)
  209. AC_SUBST(PDCURSES_LIBS)
  210. AC_SUBST(WS2_LIBS)
  211. AC_CONFIG_FILES([
  212. Makefile
  213. compat/Makefile
  214. compat/jansson/Makefile
  215. x86_64/Makefile
  216. x86_32/Makefile
  217. ccan/Makefile
  218. lib/Makefile
  219. ])
  220. AC_OUTPUT
  221. echo
  222. echo
  223. echo
  224. echo "------------------------------------------------------------------------"
  225. echo "$PACKAGE $VERSION"
  226. echo "------------------------------------------------------------------------"
  227. echo
  228. echo
  229. echo "Configuration Options Summary:"
  230. echo
  231. if test "x$opencl" != xno; then
  232. if test $found_opencl = 1; then
  233. echo " OpenCL...............: FOUND. GPU mining support enabled"
  234. else
  235. echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED"
  236. fi
  237. else
  238. echo " OpenCL...............: Detection overrided. GPU mining support DISABLED"
  239. fi
  240. if test "x$adl" != xno; then
  241. if test x$have_adl = xtrue; then
  242. echo " ADL..................: SDK found, GPU monitoring support enabled"
  243. else
  244. echo " ADL..................: SDK NOT found, GPU monitoring support DISABLED"
  245. fi
  246. else
  247. echo " ADL..................: Detection overrided. GPU monitoring support DISABLED"
  248. fi
  249. echo " ASM..................: $has_yasm"
  250. echo
  251. echo "Compilation............: make (or gmake)"
  252. echo " CPPFLAGS.............: $CPPFLAGS"
  253. echo " CFLAGS...............: $CFLAGS"
  254. echo " LDFLAGS..............: $LDFLAGS"
  255. echo
  256. echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
  257. echo " prefix...............: $prefix"
  258. echo