configure.ac 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. AC_INIT([cgminer], [1.2.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. 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. AC_CHECK_LIB(ncurses, addstr, NCURSES_LIBS=-lncurses)
  55. AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
  56. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  57. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  58. if test x$request_jansson = xtrue
  59. then
  60. JANSSON_LIBS="compat/jansson/libjansson.a"
  61. else
  62. JANSSON_LIBS=-ljansson
  63. fi
  64. dnl Find YASM
  65. has_yasm=false
  66. AC_PATH_PROG([YASM],[yasm],[false])
  67. if test "x$YASM" != "xfalse" ; then
  68. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  69. yasmver=`yasm --version | head -1 | cut -d\ -f2`
  70. yamajor=`echo $yasmver | cut -d. -f1`
  71. yaminor=`echo $yasmver | cut -d. -f2`
  72. yamini=`echo $yasmver | cut -d. -f3`
  73. if test "$yamajor" -ge "1" ; then
  74. if test "$yamajor" -eq "1" ; then
  75. if test "$yaminor" -ge "0" ; then
  76. if test "$yaminor" -eq "0"; then
  77. if test "$yamini" -ge "1"; then
  78. has_yasm=true
  79. fi
  80. else
  81. has_yasm=true
  82. fi
  83. fi
  84. fi
  85. else
  86. has_yasm=false
  87. fi
  88. if test "x$has_yasm" = "xtrue" ; then
  89. AC_MSG_RESULT([yes])
  90. else
  91. AC_MSG_RESULT([no])
  92. fi
  93. fi
  94. if test "x$has_yasm" = "xfalse" ; then
  95. AC_MSG_NOTICE([yasm is required for the sse2_64 algorithm. It will be skipped.])
  96. fi
  97. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  98. PKG_PROG_PKG_CONFIG()
  99. LIBCURL_CHECK_CONFIG(, 7.10.1, , [AC_MSG_ERROR([Missing required libcurl dev >= 7.10.1])])
  100. dnl CCAN wants to know a lot of vars.
  101. # All the configuration checks. Regrettably, the __attribute__ checks will
  102. # give false positives on old GCCs, since they just cause warnings. But that's
  103. # fairly harmless.
  104. AC_COMPILE_IFELSE([static void __attribute__((cold)) cleanup(void) { }],
  105. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  106. [Define if __attribute__((cold))]))
  107. AC_COMPILE_IFELSE([static void __attribute__((const)) cleanup(void) { }],
  108. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  109. [Define if __attribute__((const))]))
  110. AC_COMPILE_IFELSE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }],
  111. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  112. [Define if __attribute__((noreturn))]))
  113. AC_COMPILE_IFELSE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }],
  114. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  115. [Define if __attribute__((format(__printf__)))]))
  116. AC_COMPILE_IFELSE([static void __attribute__((unused)) cleanup(void) { }],
  117. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  118. [Define if __attribute__((unused))]))
  119. AC_COMPILE_IFELSE([static void __attribute__((used)) cleanup(void) { }],
  120. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  121. [Define if __attribute__((used))]))
  122. AC_LINK_IFELSE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }],
  123. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  124. [Define if have __builtin_constant_p]))
  125. AC_LINK_IFELSE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }],
  126. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  127. [Define if have __builtin_types_compatible_p]))
  128. AC_COMPILE_IFELSE([static int __attribute__((warn_unused_result)) func(int x) { return x; }],
  129. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  130. [Define if __attribute__((warn_unused_result))]))
  131. AC_SUBST(OPENCL_LIBS)
  132. AC_SUBST(JANSSON_LIBS)
  133. AC_SUBST(PTHREAD_FLAGS)
  134. AC_SUBST(PTHREAD_LIBS)
  135. AC_SUBST(NCURSES_LIBS)
  136. AC_CONFIG_FILES([
  137. Makefile
  138. compat/Makefile
  139. compat/jansson/Makefile
  140. x86_64/Makefile
  141. ccan/Makefile
  142. lib/Makefile
  143. ])
  144. AC_OUTPUT
  145. echo ''
  146. if test $found_opencl = 1; then
  147. echo OpenCL: FOUND. GPU mining support enabled.
  148. else
  149. echo OpenCL: NOT FOUND. GPU mining support DISABLED.
  150. fi