configure.ac 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. AC_INIT([cgminer], [1.6.0])
  2. AC_PREREQ(2.59)
  3. AC_CANONICAL_SYSTEM
  4. AC_CONFIG_MACRO_DIR([m4])
  5. AC_CONFIG_SRCDIR([main.c])
  6. AC_CONFIG_HEADERS([config.h])
  7. AM_INIT_AUTOMAKE([foreign])
  8. dnl Make sure anyone changing configure.ac/Makefile.am has a clue
  9. AM_MAINTAINER_MODE
  10. dnl Checks for programs
  11. AC_PROG_CC
  12. gl_EARLY
  13. AC_PROG_GCC_TRADITIONAL
  14. AM_PROG_CC_C_O
  15. AC_PROG_RANLIB
  16. gl_INIT
  17. dnl Checks for header files.
  18. AC_HEADER_STDC
  19. AC_CHECK_HEADERS(syslog.h)
  20. AC_FUNC_ALLOCA
  21. have_win32=false
  22. PTHREAD_FLAGS="-pthread"
  23. OPENCL_FLAGS="-lOpenCL"
  24. WS2_LIBS=""
  25. case $target in
  26. x86_64-*)
  27. have_x86_64=true
  28. ;;
  29. *)
  30. have_x86_64=false
  31. ;;
  32. esac
  33. case $target in
  34. *-*-mingw*)
  35. have_x86_64=false
  36. have_win32=true
  37. PTHREAD_FLAGS=""
  38. WS2_LIBS="-lws2_32"
  39. ;;
  40. *-*-darwin*)
  41. OPENCL_FLAGS="-framework OpenCL"
  42. ;;
  43. esac
  44. AC_ARG_ENABLE([opencl],
  45. [AC_HELP_STRING([--disable-opencl],[Override detection and disable building with opencl])],
  46. [opencl=$enableval]
  47. )
  48. if test "x$opencl" != xno; then
  49. # Check for OpenCL (the long way needed on mingw32 due to calling conventions)
  50. AC_MSG_CHECKING([for OpenCL])
  51. SAVED_LIBS=$LIBS
  52. LIBS="$LIBS $OPENCL_FLAGS"
  53. AC_LINK_IFELSE(
  54. [AC_LANG_PROGRAM([[
  55. #ifdef __APPLE_CC__
  56. #include <OpenCL/opencl.h>
  57. #else
  58. #include <CL/cl.h>
  59. #endif
  60. ]],
  61. [[return clSetKernelArg(0, 0, 0, 0); ]])],
  62. [AC_MSG_RESULT(yes)
  63. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL is present on the system.])
  64. found_opencl=1
  65. OPENCL_LIBS=$OPENCL_FLAGS],
  66. [AC_MSG_RESULT(no)
  67. found_opencl=0])
  68. LIBS=$SAVED_LIBS
  69. fi
  70. AC_CHECK_LIB(pthread, pthread_create, ,
  71. AC_MSG_ERROR([Could not find pthread library - please install libpthread]))
  72. PTHREAD_LIBS=-lpthread
  73. AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
  74. AC_SEARCH_LIBS(addstr, ncurses pdcurses, ,
  75. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev]))
  76. AC_CHECK_LIB(ncurses, addstr, NCURSES_LIBS=-lncurses)
  77. AC_CHECK_LIB(pdcurses, addstr, PDCURSES_LIBS=-lpdcurses)
  78. AC_CHECK_LIB(curl, curl_easy_init, ,
  79. AC_MSG_ERROR([Could not find curl library - please install libcurl-dev]))
  80. AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
  81. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  82. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  83. if test x$request_jansson = xtrue
  84. then
  85. JANSSON_LIBS="compat/jansson/libjansson.a"
  86. else
  87. JANSSON_LIBS=-ljansson
  88. fi
  89. dnl Find YASM
  90. has_yasm=false
  91. AC_PATH_PROG([YASM],[yasm],[false])
  92. if test "x$YASM" != "xfalse" ; then
  93. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  94. yasmver=`yasm --version | head -1 | cut -d\ -f2`
  95. yamajor=`echo $yasmver | cut -d. -f1`
  96. yaminor=`echo $yasmver | cut -d. -f2`
  97. yamini=`echo $yasmver | cut -d. -f3`
  98. if test "$yamajor" -ge "1" ; then
  99. if test "$yamajor" -eq "1" ; then
  100. if test "$yaminor" -ge "0" ; then
  101. if test "$yaminor" -eq "0"; then
  102. if test "$yamini" -ge "1"; then
  103. has_yasm=true
  104. fi
  105. else
  106. has_yasm=true
  107. fi
  108. fi
  109. fi
  110. else
  111. has_yasm=false
  112. fi
  113. if test "x$has_yasm" = "xtrue" ; then
  114. AC_MSG_RESULT([yes])
  115. else
  116. AC_MSG_RESULT([no])
  117. fi
  118. fi
  119. if test "x$has_yasm" = "xfalse" ; then
  120. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  121. fi
  122. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  123. PKG_PROG_PKG_CONFIG()
  124. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.15.6], [AC_DEFINE([CURL_HAS_SOCKOPT], [1], [Defined if version of curl supports sockopts.])],
  125. [PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.10.1], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.10.1])])])
  126. AC_SUBST(LIBCURL_CPPFLAGS)
  127. AC_SUBST(LIBCURL_LIBS)
  128. dnl CCAN wants to know a lot of vars.
  129. # All the configuration checks. Regrettably, the __attribute__ checks will
  130. # give false positives on old GCCs, since they just cause warnings. But that's
  131. # fairly harmless.
  132. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  133. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  134. [Define if __attribute__((cold))]))
  135. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  136. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  137. [Define if __attribute__((const))]))
  138. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  139. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  140. [Define if __attribute__((noreturn))]))
  141. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  142. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  143. [Define if __attribute__((format(__printf__)))]))
  144. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  145. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  146. [Define if __attribute__((unused))]))
  147. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  148. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  149. [Define if __attribute__((used))]))
  150. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  151. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  152. [Define if have __builtin_constant_p]))
  153. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  154. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  155. [Define if have __builtin_types_compatible_p]))
  156. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  157. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  158. [Define if __attribute__((warn_unused_result))]))
  159. if test "x$prefix" = xNONE; then
  160. prefix=/usr
  161. fi
  162. AC_DEFINE_UNQUOTED([CGMINER_PREFIX], ["$prefix/bin"], [Path to cgminer install])
  163. AC_SUBST(OPENCL_LIBS)
  164. AC_SUBST(JANSSON_LIBS)
  165. AC_SUBST(PTHREAD_FLAGS)
  166. AC_SUBST(PTHREAD_LIBS)
  167. AC_SUBST(NCURSES_LIBS)
  168. AC_SUBST(PDCURSES_LIBS)
  169. AC_SUBST(WS2_LIBS)
  170. AC_CONFIG_FILES([
  171. Makefile
  172. compat/Makefile
  173. compat/jansson/Makefile
  174. x86_64/Makefile
  175. x86_32/Makefile
  176. ccan/Makefile
  177. lib/Makefile
  178. ])
  179. AC_OUTPUT
  180. echo ''
  181. if test "x$opencl" != xno; then
  182. if test $found_opencl = 1; then
  183. echo OpenCL: FOUND. GPU mining support enabled.
  184. else
  185. echo OpenCL: NOT FOUND. GPU mining support DISABLED.
  186. fi
  187. else
  188. echo OpenCL: Detection overrided. GPU mining support DISABLED.
  189. fi