configure.ac 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. AC_INIT([cgminer], [1.5.7])
  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. # Check for OpenCL (the long way needed on mingw32 due to calling conventions)
  45. AC_MSG_CHECKING([for OpenCL])
  46. SAVED_LIBS=$LIBS
  47. LIBS="$LIBS $OPENCL_FLAGS"
  48. AC_LINK_IFELSE(
  49. [AC_LANG_PROGRAM([[
  50. #ifdef __APPLE_CC__
  51. #include <OpenCL/opencl.h>
  52. #else
  53. #include <CL/cl.h>
  54. #endif
  55. ]],
  56. [[return clSetKernelArg(0, 0, 0, 0); ]])],
  57. [AC_MSG_RESULT(yes)
  58. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL is present on the system.])
  59. found_opencl=1
  60. OPENCL_LIBS=$OPENCL_FLAGS],
  61. [AC_MSG_RESULT(no)
  62. found_opencl=0])
  63. LIBS=$SAVED_LIBS
  64. AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
  65. AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIBS=-lpthread)
  66. AC_CHECK_LIB(ncurses, addstr, NCURSES_LIBS=-lncurses)
  67. AC_CHECK_LIB(pdcurses, addstr, PDCURSES_LIBS=-lpdcurses)
  68. AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
  69. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  70. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  71. if test x$request_jansson = xtrue
  72. then
  73. JANSSON_LIBS="compat/jansson/libjansson.a"
  74. else
  75. JANSSON_LIBS=-ljansson
  76. fi
  77. dnl Find YASM
  78. has_yasm=false
  79. AC_PATH_PROG([YASM],[yasm],[false])
  80. if test "x$YASM" != "xfalse" ; then
  81. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  82. yasmver=`yasm --version | head -1 | cut -d\ -f2`
  83. yamajor=`echo $yasmver | cut -d. -f1`
  84. yaminor=`echo $yasmver | cut -d. -f2`
  85. yamini=`echo $yasmver | cut -d. -f3`
  86. if test "$yamajor" -ge "1" ; then
  87. if test "$yamajor" -eq "1" ; then
  88. if test "$yaminor" -ge "0" ; then
  89. if test "$yaminor" -eq "0"; then
  90. if test "$yamini" -ge "1"; then
  91. has_yasm=true
  92. fi
  93. else
  94. has_yasm=true
  95. fi
  96. fi
  97. fi
  98. else
  99. has_yasm=false
  100. fi
  101. if test "x$has_yasm" = "xtrue" ; then
  102. AC_MSG_RESULT([yes])
  103. else
  104. AC_MSG_RESULT([no])
  105. fi
  106. fi
  107. if test "x$has_yasm" = "xfalse" ; then
  108. AC_MSG_NOTICE([yasm is required for the sse2_64 algorithm. It will be skipped.])
  109. fi
  110. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  111. PKG_PROG_PKG_CONFIG()
  112. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.15.6], [AC_DEFINE([CURL_HAS_SOCKOPT], [1], [Defined if version of curl supports sockopts.])],
  113. [PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.10.1], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.10.1])])])
  114. AC_SUBST(LIBCURL_CPPFLAGS)
  115. AC_SUBST(LIBCURL_LIBS)
  116. dnl CCAN wants to know a lot of vars.
  117. # All the configuration checks. Regrettably, the __attribute__ checks will
  118. # give false positives on old GCCs, since they just cause warnings. But that's
  119. # fairly harmless.
  120. AC_COMPILE_IFELSE([static void __attribute__((cold)) cleanup(void) { }],
  121. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  122. [Define if __attribute__((cold))]))
  123. AC_COMPILE_IFELSE([static void __attribute__((const)) cleanup(void) { }],
  124. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  125. [Define if __attribute__((const))]))
  126. AC_COMPILE_IFELSE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }],
  127. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  128. [Define if __attribute__((noreturn))]))
  129. AC_COMPILE_IFELSE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }],
  130. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  131. [Define if __attribute__((format(__printf__)))]))
  132. AC_COMPILE_IFELSE([static void __attribute__((unused)) cleanup(void) { }],
  133. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  134. [Define if __attribute__((unused))]))
  135. AC_COMPILE_IFELSE([static void __attribute__((used)) cleanup(void) { }],
  136. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  137. [Define if __attribute__((used))]))
  138. AC_LINK_IFELSE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }],
  139. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  140. [Define if have __builtin_constant_p]))
  141. AC_LINK_IFELSE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }],
  142. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  143. [Define if have __builtin_types_compatible_p]))
  144. AC_COMPILE_IFELSE([static int __attribute__((warn_unused_result)) func(int x) { return x; }],
  145. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  146. [Define if __attribute__((warn_unused_result))]))
  147. AC_SUBST(OPENCL_LIBS)
  148. AC_SUBST(JANSSON_LIBS)
  149. AC_SUBST(PTHREAD_FLAGS)
  150. AC_SUBST(PTHREAD_LIBS)
  151. AC_SUBST(NCURSES_LIBS)
  152. AC_SUBST(PDCURSES_LIBS)
  153. AC_SUBST(WS2_LIBS)
  154. AC_CONFIG_FILES([
  155. Makefile
  156. compat/Makefile
  157. compat/jansson/Makefile
  158. x86_64/Makefile
  159. ccan/Makefile
  160. lib/Makefile
  161. ])
  162. AC_OUTPUT
  163. echo ''
  164. if test $found_opencl = 1; then
  165. echo OpenCL: FOUND. GPU mining support enabled.
  166. else
  167. echo OpenCL: NOT FOUND. GPU mining support DISABLED.
  168. fi