configure.ac 5.3 KB

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