configure.ac 5.2 KB

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