configure.ac 5.1 KB

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