configure.ac 5.3 KB

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