configure.ac 9.1 KB

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