configure.ac 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  2. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  3. m4_define([v_maj], [3])
  4. m4_define([v_min], [0])
  5. m4_define([v_mic], [99])
  6. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  7. m4_define([v_ver], [v_maj.v_min.v_mic])
  8. m4_define([lt_rev], m4_eval(v_maj + v_min))
  9. m4_define([lt_cur], v_mic)
  10. m4_define([lt_age], v_min)
  11. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  12. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  13. AC_INIT([bfgminer], [v_ver], [luke-jr+bfgminer@utopios.org])
  14. AC_PREREQ([2.59c])
  15. AC_CANONICAL_SYSTEM
  16. AC_CONFIG_MACRO_DIR([m4])
  17. AC_CONFIG_SRCDIR([miner.c])
  18. AC_CONFIG_HEADERS([config.h])
  19. AM_INIT_AUTOMAKE([foreign])
  20. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  21. AC_USE_SYSTEM_EXTENSIONS
  22. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  23. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  24. m4_ifdef([v_rev], , [m4_define([v_rev], [0])])
  25. m4_ifdef([v_rel], , [m4_define([v_rel], [])])
  26. AC_DEFINE_UNQUOTED(CGMINER_MAJOR_VERSION, [v_maj], [Major version])
  27. AC_DEFINE_UNQUOTED(CGMINER_MINOR_VERSION, [v_min], [Minor version])
  28. AC_DEFINE_UNQUOTED(CGMINER_MINOR_SUBVERSION, [v_mic], [Micro version])
  29. version_info="lt_rev:lt_cur:lt_age"
  30. release_info="v_rel"
  31. AC_SUBST(version_info)
  32. AC_SUBST(release_info)
  33. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  34. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  35. VMAJ=v_maj
  36. AC_SUBST(VMAJ)
  37. AC_CANONICAL_BUILD
  38. AC_CANONICAL_HOST
  39. dnl Make sure anyone changing configure.ac/Makefile.am has a clue
  40. AM_MAINTAINER_MODE
  41. dnl Checks for programs
  42. AC_PROG_CC_C99
  43. gl_EARLY
  44. AC_PROG_GCC_TRADITIONAL
  45. AM_PROG_CC_C_O
  46. AC_PROG_RANLIB
  47. gl_INIT
  48. dnl Checks for header files.
  49. AC_HEADER_STDC
  50. AC_CHECK_HEADERS(syslog.h)
  51. AC_CHECK_HEADERS([sys/epoll.h])
  52. AC_CHECK_HEADERS([sys/prctl.h])
  53. AC_FUNC_ALLOCA
  54. have_cygwin=false
  55. have_win32=false
  56. have_macho=false
  57. DLOPEN_FLAGS="-ldl"
  58. WS2_LIBS=""
  59. MM_LIBS=""
  60. MATH_LIBS="-lm"
  61. case $target in
  62. amd64-* | x86_64-*)
  63. have_x86_32=false
  64. have_x86_64=true
  65. bitness="64"
  66. ;;
  67. i386-* | i486-* | i586-* | i686-* | x86-*)
  68. have_x86_32=true
  69. have_x86_64=false
  70. bitness="32"
  71. ;;
  72. *)
  73. have_x86_32=false
  74. have_x86_64=false
  75. ;;
  76. esac
  77. case $target in
  78. *-*-mingw*)
  79. have_win32=true
  80. DLOPEN_FLAGS=""
  81. WS2_LIBS="-lws2_32"
  82. MM_LIBS="-lwinmm"
  83. AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support")
  84. AC_DEFINE([FD_SETSIZE], [4096], [Maximum sockets before fd_set overflows])
  85. ;;
  86. *-*-cygwin*)
  87. have_cygwin=true
  88. ;;
  89. powerpc-*-darwin*)
  90. CFLAGS="$CFLAGS -faltivec"
  91. have_macho=true
  92. ;;
  93. *-*-darwin*)
  94. have_macho=true
  95. ;;
  96. esac
  97. m4_define([BFG_INCLUDE],
  98. if test "x$2" = "x"; then
  99. $1=''
  100. else
  101. $1="[#]include <$2>"
  102. fi
  103. )
  104. m4_define([BFG_PREPROC_IFELSE],
  105. BFG_INCLUDE([headerinclude], $2)
  106. AC_COMPILE_IFELSE([
  107. AC_LANG_PROGRAM([
  108. ${headerinclude}
  109. ], [
  110. #if !( $1 )
  111. #error "$1 false in preprocessor"
  112. #endif
  113. ])
  114. ],[$3],[$4])
  115. )
  116. cpumining="no"
  117. AC_ARG_ENABLE([cpumining],
  118. [AC_HELP_STRING([--enable-cpumining],[Build with CPU mining support (default disabled)])],
  119. [cpumining=$enableval]
  120. )
  121. if test "x$cpumining" = xyes; then
  122. AC_DEFINE_UNQUOTED([WANT_CPUMINE], [1], [Enable CPUMINING])
  123. fi
  124. AM_CONDITIONAL([HAS_CPUMINE], [test x$cpumining = xyes])
  125. opencl="yes"
  126. AC_ARG_ENABLE([opencl],
  127. [AC_HELP_STRING([--disable-opencl],[Build without support for OpenCL (default enabled)])],
  128. [opencl=$enableval]
  129. )
  130. if test "x$opencl" = xyes; then
  131. AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL support is wanted])
  132. else
  133. DLOPEN_FLAGS=""
  134. fi
  135. AM_CONDITIONAL([HAVE_OPENCL], [test x$opencl = xyes])
  136. m4_define([BFG_PTHREAD_FLAG_CHECK],
  137. AC_MSG_CHECKING([for $1])
  138. for cflag in ' -pthread' ''; do
  139. for lib in ' -lpthread' ' -lwinpthread' ''; do
  140. CFLAGS="${save_CFLAGS}${cflag}"
  141. LIBS="${save_LIBS}${lib}"
  142. AC_LINK_IFELSE([
  143. AC_LANG_PROGRAM([
  144. #include <pthread.h>
  145. ], [
  146. void *f = $1;
  147. ])
  148. ], [
  149. found_pthread=true
  150. PTHREAD_FLAGS="${cflag}"
  151. PTHREAD_LIBS="${lib}"
  152. if test "x${cflag}${lib}" = "x"; then
  153. AC_MSG_RESULT([yes])
  154. else
  155. AC_MSG_RESULT([with${cflag}${lib}])
  156. fi
  157. $2
  158. break 2
  159. ],[])
  160. done
  161. done
  162. if test "x${found_pthread}" = "xfalse"; then
  163. AC_MSG_RESULT([no])
  164. fi
  165. )
  166. save_CFLAGS="${CFLAGS}"
  167. save_LIBS="${LIBS}"
  168. found_pthread=false
  169. BFG_PTHREAD_FLAG_CHECK([pthread_cancel],[
  170. AC_DEFINE([HAVE_PTHREAD_CANCEL], [1], [Define if you have a native pthread_cancel])
  171. ])
  172. if test "x${found_pthread}" = "xfalse"; then
  173. BFG_PTHREAD_FLAG_CHECK([pthread_create])
  174. if test "x${found_pthread}" = "xfalse"; then
  175. AC_MSG_ERROR([Could not find pthread library - please install libpthread])
  176. fi
  177. fi
  178. # check for nanosleep here, since it is provided by winpthread
  179. AC_CHECK_FUNCS([nanosleep])
  180. CFLAGS="${save_CFLAGS}"
  181. LIBS="${save_LIBS}"
  182. PKG_CHECK_MODULES([JANSSON],[jansson],[
  183. true
  184. ],[
  185. AC_MSG_CHECKING([for jansson in system-default locations])
  186. LIBS="$LIBS -ljansson"
  187. AC_TRY_LINK([
  188. #include <jansson.h>
  189. ],[
  190. json_object();
  191. ],[
  192. AC_MSG_RESULT([found])
  193. JANSSON_LIBS=-ljansson
  194. ],[
  195. AC_MSG_RESULT([not found])
  196. AC_MSG_ERROR([Could not find jansson library])
  197. ])
  198. LIBS="${save_LIBS}"
  199. ])
  200. AC_SUBST(JANSSON_CFLAGS)
  201. AC_SUBST(JANSSON_LIBS)
  202. if test "x$opencl" = xyes; then
  203. adl="yes"
  204. AC_ARG_WITH([sensors],[Build with libsensors monitoring],[true],[with_sensors=auto])
  205. if test "x$opencl" != xyes; then
  206. with_sensors=no
  207. fi
  208. if test "x$with_sensors" != xno; then
  209. AC_MSG_CHECKING([for libsensors])
  210. save_LIBS="${LIBS}"
  211. LIBS="$LIBS -lsensors"
  212. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  213. #include <stddef.h>
  214. #include <sensors/sensors.h>
  215. ],[
  216. const sensors_chip_name *cn;
  217. cn = sensors_get_detected_chips(NULL, NULL);
  218. ])],[
  219. with_sensors=yes
  220. sensors_LIBS="-lsensors"
  221. AC_DEFINE([HAVE_SENSORS], [1], [Defined if libsensors was found])
  222. AC_MSG_RESULT([yes])
  223. ],[
  224. with_sensors=no
  225. AC_MSG_RESULT([no])
  226. ])
  227. LIBS="$save_LIBS"
  228. fi
  229. AC_SUBST(sensors_LIBS)
  230. AC_ARG_ENABLE([adl],
  231. [AC_HELP_STRING([--disable-adl],[Build without ADL monitoring (default enabled)])],
  232. [adl=$enableval]
  233. )
  234. if test x$adl = xyes
  235. then
  236. AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
  237. fi
  238. else
  239. adl="no"
  240. fi
  241. AC_ARG_ENABLE([bitforce],
  242. [AC_HELP_STRING([--disable-bitforce],[Compile support for BitForce (default enabled)])],
  243. [bitforce=$enableval],
  244. [bitforce=yes]
  245. )
  246. if test "x$bitforce" = xyes; then
  247. AC_DEFINE([USE_BITFORCE], [1], [Defined to 1 if BitForce support is wanted])
  248. fi
  249. AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
  250. AC_ARG_ENABLE([icarus],
  251. [AC_HELP_STRING([--disable-icarus],[Compile support for Icarus (default enabled)])],
  252. [icarus=$enableval],
  253. [icarus=yes]
  254. )
  255. if test "x$icarus" = xyes; then
  256. AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
  257. fi
  258. AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
  259. avalon="no"
  260. AC_ARG_ENABLE([avalon],
  261. [AC_HELP_STRING([--enable-avalon],[Compile support for Avalon (default disabled)])],
  262. [avalon=$enableval]
  263. )
  264. if test "x$avalon" = xyes; then
  265. AC_DEFINE([USE_AVALON], [1], [Defined to 1 if Avalon support is wanted])
  266. fi
  267. AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes])
  268. AC_ARG_ENABLE([modminer],
  269. [AC_HELP_STRING([--disable-modminer],[Compile support for ModMiner (default enabled)])],
  270. [modminer=$enableval],
  271. [modminer=yes]
  272. )
  273. if test "x$modminer" = xyes; then
  274. AC_DEFINE([USE_MODMINER], [1], [Defined to 1 if ModMiner support is wanted])
  275. fi
  276. AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes])
  277. PKG_PROG_PKG_CONFIG()
  278. libusb=no
  279. libusb_include_path=""
  280. PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[
  281. libusb=yes
  282. ],[
  283. for usb_lib in usb-1.0 usb; do
  284. AC_CHECK_LIB($usb_lib, libusb_init, [
  285. libusb=yes
  286. break
  287. ], [])
  288. done
  289. if test "x$libusb" = xyes; then
  290. AC_CHECK_DECL([libusb_init],[
  291. true
  292. ],[
  293. AC_PROG_CPP
  294. AC_MSG_CHECKING([whether libusb_init is declared in subdirectory])
  295. libusb_include_path=`echo '#include <libusb-1.0/libusb.h>' | ${CPP} -M - 2>/dev/null | sed 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]]\+\)\/.*$/\1/;t;d'`
  296. if test "x$libusb_include_path" != "x"; then
  297. LIBUSB_LIBS="-l$usb_lib"
  298. LIBUSB_CFLAGS="-I$libusb_include_path"
  299. AC_MSG_RESULT([yes])
  300. else
  301. libusb=no
  302. AC_MSG_RESULT([no])
  303. fi
  304. ],[#include <libusb.h>])
  305. fi
  306. ])
  307. AC_ARG_ENABLE([x6500],
  308. [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])],
  309. [x6500=$enableval],
  310. [x6500=auto]
  311. )
  312. if test "x$x6500$libusb" = xyesno; then
  313. AC_MSG_ERROR([Could not find libusb, required for X6500 support])
  314. elif test "x$x6500" = xauto; then
  315. x6500="$libusb"
  316. if test "x$libusb" = xno; then
  317. AC_MSG_WARN([Could not find libusb, required for X6500 support])
  318. x6500warn=yes
  319. fi
  320. fi
  321. if test "x$x6500" = xyes; then
  322. AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted])
  323. fi
  324. AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes])
  325. AC_ARG_ENABLE([ztex],
  326. [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])],
  327. [ztex=$enableval],
  328. [ztex=auto]
  329. )
  330. if test "x$ztex$libusb" = xyesno; then
  331. AC_MSG_ERROR([Could not find libusb, required for ZTEX support])
  332. elif test "x$ztex" = xauto; then
  333. ztex="$libusb"
  334. if test "x$libusb" = xno; then
  335. AC_MSG_WARN([Could not find libusb, required for ZTEX support])
  336. ztexwarn=yes
  337. fi
  338. fi
  339. if test "x$ztex" = xyes; then
  340. AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted])
  341. fi
  342. AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes])
  343. if test "x$x6500$ztex" = "xnono"; then
  344. libusb=no
  345. LIBUSB_LIBS=''
  346. LIBUSB_CFLAGS=''
  347. fi
  348. if test "x$libusb" = xyes; then
  349. AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0])
  350. save_CFLAGS="$CFLAGS"
  351. CFLAGS="$LIBUSB_CFLAGS $CFLAGS"
  352. AC_CHECK_DECLS([libusb_error_name],[],[],[#include <libusb.h>])
  353. CFLAGS="$save_CFLAGS"
  354. fi
  355. scrypt="no"
  356. AC_ARG_ENABLE([scrypt],
  357. [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
  358. [scrypt=$enableval]
  359. )
  360. if test "x$scrypt" = xyes; then
  361. AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
  362. fi
  363. curses="auto"
  364. AC_ARG_WITH([curses],
  365. [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])],
  366. [curses=$withval]
  367. )
  368. if test "x$curses" = "xno"; then
  369. cursesmsg='User specified --without-curses. TUI support DISABLED'
  370. else
  371. orig_libs="$LIBS"
  372. if test "x${curses}" = "xyes"; then
  373. prefer=''
  374. preferl=''
  375. else
  376. prefer="${curses}"
  377. preferl="${curses} ${curses}6 ${curses}5"
  378. fi
  379. if test "x$cross_compiling" != "xyes"; then
  380. AC_MSG_CHECKING([for best native curses library])
  381. orig_cflags="$CFLAGS"
  382. for curses_lib in ${preferl} ncurses{w,}{,6,5}; do
  383. if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then
  384. continue
  385. fi
  386. CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)"
  387. LIBS="$orig_libs $(${curses_lib}-config --libs)"
  388. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  389. #include <curses.h>
  390. ]], [[
  391. WINDOW *w = NULL;
  392. mvwprintw(w, 2, 2, "Testing %s", "o hai");
  393. ]])], [
  394. curses=yes
  395. cursesmsg="FOUND: ${curses_lib}"
  396. AC_MSG_RESULT([$curses_lib])
  397. NCURSES_LIBS=`${curses_lib}-config --libs`
  398. NCURSES_CPPFLAGS=`${curses_lib}-config --cflags`
  399. break
  400. ], [
  401. AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly])
  402. ])
  403. done
  404. CFLAGS="$orig_cflags"
  405. if test "x$curses" != "xyes"; then
  406. AC_MSG_RESULT([none?])
  407. fi
  408. fi
  409. if test "x$curses" != "xyes"; then
  410. AC_SEARCH_LIBS(addstr, ${prefer} ncursesw ncurses pdcurses, [
  411. curses=yes
  412. cursesmsg="FOUND: ${ac_cv_search_addstr}"
  413. cursesmsg="${cursesmsg/-l/}"
  414. if test "x${ac_cv_search_addstr}" != "xnone required"; then
  415. NCURSES_LIBS="${ac_cv_search_addstr}"
  416. fi
  417. ], [
  418. if test "x$curses" = "xyes"; then
  419. AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
  420. else
  421. AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
  422. curses=no
  423. cursesmsg='NOT FOUND. TUI support DISABLED'
  424. fi
  425. ])
  426. fi
  427. if test "x$curses" = "xyes"; then
  428. AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
  429. fi
  430. LIBS="$orig_libs"
  431. fi
  432. AC_ARG_WITH([system-libblkmaker], [AC_HELP_STRING([--with-system-libblkmaker], [Use system libblkmaker rather than bundled one (default disabled)])],[],[with_system_libblkmaker=no])
  433. if test "x$with_system_libblkmaker" = "xyes"; then
  434. PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
  435. true
  436. ],[
  437. AC_MSG_ERROR([Could not find system libblkmaker])
  438. ])
  439. else
  440. libblkmaker_CFLAGS='-Ilibblkmaker'
  441. libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,libblkmaker/.libs'
  442. libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
  443. AC_CONFIG_SUBDIRS([libblkmaker])
  444. fi
  445. AC_SUBST(libblkmaker_CFLAGS)
  446. AC_SUBST(libblkmaker_LDFLAGS)
  447. AC_SUBST(libblkmaker_LIBS)
  448. AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
  449. AM_CONDITIONAL([NEED_DYNCLOCK], [test x$icarus$modminer$x6500$ztex != xnonono])
  450. AM_CONDITIONAL([NEED_FPGAUTILS], [test x$avalon$icarus$bitforce$modminer$x6500$ztex != xnononononono])
  451. AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
  452. AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
  453. AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])
  454. AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue])
  455. AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
  456. AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
  457. dnl Find YASM
  458. has_yasm=false
  459. if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then
  460. AC_PATH_PROG([YASM],[yasm],[false])
  461. if test "x$YASM" != "xfalse" ; then
  462. AC_MSG_CHECKING([if yasm version is greater than 1.0.1])
  463. yasmver=`"$YASM" --version | head -1 | cut -d\ -f2`
  464. yamajor=`echo $yasmver | cut -d. -f1`
  465. yaminor=`echo $yasmver | cut -d. -f2`
  466. yamini=`echo $yasmver | cut -d. -f3`
  467. if test "$yamajor" -ge "1" ; then
  468. if test "$yamajor" -eq "1" ; then
  469. if test "$yaminor" -ge "0" ; then
  470. if test "$yaminor" -eq "0"; then
  471. if test "$yamini" -ge "1"; then
  472. has_yasm=true
  473. fi
  474. else
  475. has_yasm=true
  476. fi
  477. fi
  478. fi
  479. else
  480. has_yasm=false
  481. fi
  482. if test "x$has_yasm" = "xtrue" ; then
  483. AC_MSG_RESULT([yes])
  484. else
  485. AC_MSG_RESULT([no])
  486. fi
  487. fi
  488. if test "x$has_yasm" = "xfalse" ; then
  489. AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
  490. else
  491. AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used])
  492. if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
  493. if test "x$have_x86_64" = xtrue; then
  494. YASM_FMT="win64"
  495. else
  496. YASM_FMT="coff"
  497. fi
  498. elif test "x$have_macho" = "xtrue"; then
  499. YASM_FMT="macho$bitness"
  500. else
  501. YASM_FMT="elf$bitness"
  502. fi
  503. fi
  504. fi
  505. AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])
  506. if test "x$bitforce$modminer" != xnono; then
  507. AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])],
  508. [libudev=$withval],
  509. [libudev=auto]
  510. )
  511. if test "x$libudev" != "xno"; then
  512. AC_CHECK_HEADER([libudev.h],[
  513. libudev=yes
  514. UDEV_LIBS=-ludev
  515. AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted])
  516. ], [
  517. if test "x$libudev" = "xyes"; then
  518. AC_MSG_ERROR([libudev not found])
  519. fi
  520. libudev=no
  521. ])
  522. fi
  523. fi
  524. AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
  525. AC_SUBST(LIBUSB_LIBS)
  526. AC_SUBST(LIBUSB_CFLAGS)
  527. PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
  528. if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then
  529. AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround])
  530. LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'`
  531. fi
  532. AC_SUBST(LIBCURL_LIBS)
  533. AC_CHECK_FUNCS([setrlimit])
  534. dnl CCAN wants to know a lot of vars.
  535. # All the configuration checks. Regrettably, the __attribute__ checks will
  536. # give false positives on old GCCs, since they just cause warnings. But that's
  537. # fairly harmless.
  538. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])],
  539. AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1],
  540. [Define if __attribute__((cold))]))
  541. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])],
  542. AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1],
  543. [Define if __attribute__((const))]))
  544. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])],
  545. [
  546. AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1],
  547. [Define if __attribute__((noreturn))])
  548. AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute])
  549. ], [
  550. AC_DEFINE_UNQUOTED([NORETURN], [])
  551. ]
  552. )
  553. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])],
  554. AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1],
  555. [Define if __attribute__((format(__printf__)))]))
  556. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])],
  557. AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1],
  558. [Define if __attribute__((unused))]))
  559. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])],
  560. AC_DEFINE([HAVE_ATTRIBUTE_USED], [1],
  561. [Define if __attribute__((used))]))
  562. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])],
  563. AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1],
  564. [Define if have __builtin_constant_p]))
  565. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])],
  566. AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1],
  567. [Define if have __builtin_types_compatible_p]))
  568. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])],
  569. AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
  570. [Define if __attribute__((warn_unused_result))]))
  571. AC_MSG_CHECKING([for roundl function])
  572. save_LIBS="${LIBS}"
  573. LIBS="$LIBS -lm"
  574. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  575. #include <math.h>
  576. ]], [[
  577. return (roundl(*(long double *)0xdeadbeef) == 1.0);
  578. ]])], [
  579. AC_MSG_RESULT([yes])
  580. ], [
  581. AC_MSG_RESULT([no])
  582. AC_DEFINE([NEED_ROUNDL], [1], [Defined to 1 if C99 roundl is missing])
  583. ])
  584. LIBS="${save_LIBS}"
  585. # byteswap functions
  586. AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
  587. AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h])
  588. AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h])
  589. AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h])
  590. BSWAP=''
  591. for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do
  592. AC_MSG_CHECKING([for ${sym}* functions])
  593. for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do
  594. BFG_INCLUDE([headerinclude], [${headerfile}])
  595. AC_LINK_IFELSE([
  596. AC_LANG_PROGRAM([
  597. ${headerinclude}
  598. ], [
  599. (void) ${sym}16(0);
  600. (void) ${sym}32(0);
  601. (void) ${sym}64(0);
  602. ])
  603. ], [
  604. BSWAP="${sym}"
  605. if test "x${headerfile}" = "x"; then
  606. AC_MSG_RESULT([yes])
  607. else
  608. AC_MSG_RESULT([found in ${headerfile}])
  609. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1)
  610. fi
  611. break 2
  612. ],[])
  613. done
  614. AC_MSG_RESULT([no])
  615. done
  616. if test "x$BSWAP" = "x"; then
  617. true # Substitutes are provided in miner.h
  618. elif test "x$BSWAP" = "xbswap_"; then
  619. AC_MSG_CHECKING([if bswap_16 is already a macro])
  620. BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [
  621. AC_MSG_RESULT([yes])
  622. BSWAP=""
  623. ],[
  624. AC_MSG_RESULT([no])
  625. ])
  626. fi
  627. if test "x$BSWAP" != "x"; then
  628. AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro])
  629. AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro])
  630. AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro])
  631. fi
  632. # endian definition macros
  633. AC_MSG_CHECKING([for platform endian])
  634. found_endian=no
  635. for headerfile in '' endian.h sys/endian.h sys/param.h; do
  636. for pfx in '' '__'; do
  637. BFG_PREPROC_IFELSE([defined(${pfx}BYTE_ORDER) && defined(${pfx}BIG_ENDIAN) && defined(${pfx}LITTLE_ENDIAN) && (${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN || ${pfx}BYTE_ORDER == ${pfx}LITTLE_ENDIAN)], ${headerfile}, [
  638. if test "x$headerfile" = "x"; then
  639. headerfilec=''
  640. else
  641. headerfilec=" (${headerfile})"
  642. fi
  643. BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [
  644. AC_MSG_RESULT([big endian${headerfilec}])
  645. AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian])
  646. ], [
  647. AC_MSG_RESULT([little endian${headerfilec}])
  648. ])
  649. found_endian=yes
  650. break 2
  651. ],[true])
  652. done
  653. done
  654. if test "x$found_endian" = "xno"; then
  655. if $have_win32 || $have_cygwin; then
  656. AC_MSG_RESULT([assuming little endian (Windows)])
  657. else
  658. # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it
  659. AC_MSG_RESULT([unknown])
  660. AC_MSG_ERROR([Unable to identify platform endian])
  661. fi
  662. fi
  663. AC_MSG_CHECKING([if GNU format attribute compiles])
  664. AC_TRY_COMPILE([
  665. #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) ))
  666. int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
  667. int myfunc(char *fmt, ...) {
  668. return 42;
  669. }
  670. ], [
  671. myfunc("abc%d", 42);
  672. ], [
  673. AC_MSG_RESULT([yes])
  674. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute])
  675. ], [
  676. AC_MSG_RESULT([no])
  677. AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [])
  678. ])
  679. if test "x$prefix" = xNONE; then
  680. prefix=/usr/local
  681. fi
  682. AC_DEFINE_UNQUOTED([CGMINER_PREFIX], ["$prefix/bin"], [Path to bfgminer install])
  683. AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel])
  684. AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel])
  685. AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel])
  686. AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel])
  687. AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
  688. AC_SUBST(PTHREAD_FLAGS)
  689. AC_SUBST(DLOPEN_FLAGS)
  690. AC_SUBST(PTHREAD_LIBS)
  691. AC_SUBST(NCURSES_CPPFLAGS)
  692. AC_SUBST(NCURSES_LIBS)
  693. AC_SUBST(PDCURSES_LIBS)
  694. AC_SUBST(WS2_LIBS)
  695. AC_SUBST(MM_LIBS)
  696. AC_SUBST(MATH_LIBS)
  697. AC_SUBST(UDEV_LIBS)
  698. AC_SUBST(YASM_FMT)
  699. AC_CONFIG_FILES([
  700. Makefile
  701. x86_64/Makefile
  702. x86_32/Makefile
  703. ccan/Makefile
  704. lib/Makefile
  705. ])
  706. AC_OUTPUT
  707. echo
  708. echo
  709. echo
  710. echo "------------------------------------------------------------------------"
  711. echo "$PACKAGE $VERSION"
  712. echo "------------------------------------------------------------------------"
  713. echo
  714. echo
  715. echo "Configuration Options Summary:"
  716. echo
  717. echo " curses.TUI...........: $cursesmsg"
  718. if test "x$scrypt" != xno; then
  719. echo " scrypt...............: Enabled"
  720. else
  721. echo " scrypt...............: Disabled"
  722. fi
  723. echo
  724. if test "x$opencl" = xyes; then
  725. echo " OpenCL...............: Enabled"
  726. else
  727. echo " OpenCL...............: Disabled"
  728. fi
  729. if test "x$with_sensors" = xyes; then
  730. echo " sensors.monitoring.: Enabled"
  731. elif test "x$opencl" = xyes; then
  732. echo " sensors.monitoring.: Disabled"
  733. else
  734. echo " sensors.monitoring.: n/a"
  735. fi
  736. if test "x$adl" = xyes; then
  737. echo " ADL.monitoring.....: Enabled"
  738. elif test "x$opencl" = xyes; then
  739. echo " ADL.monitoring.....: Disabled"
  740. else
  741. echo " ADL.monitoring.....: n/a"
  742. fi
  743. if test "x$avalon" = xyes; then
  744. echo " Avalon.ASICs.........: Enabled"
  745. else
  746. echo " Avalon.ASICs.........: Disabled"
  747. fi
  748. if test "x$bitforce" = xyes; then
  749. echo " BitForce.devices.....: Enabled"
  750. else
  751. echo " BitForce.devices.....: Disabled"
  752. fi
  753. if test "x$icarus" = xyes; then
  754. echo " Icarus.FPGAs.........: Enabled"
  755. else
  756. echo " Icarus.FPGAs.........: Disabled"
  757. fi
  758. if test "x$modminer" = xyes; then
  759. echo " ModMiner.FPGAs.......: Enabled"
  760. else
  761. echo " ModMiner.FPGAs.......: Disabled"
  762. fi
  763. if test "x$x6500" = xyes; then
  764. echo " X6500.FPGAs..........: Enabled"
  765. elif test "x$ztexwarn" = xyes; then
  766. echo " X6500.FPGAs..........: Disabled (libusb not found)"
  767. else
  768. echo " X6500.FPGAs..........: Disabled"
  769. fi
  770. if test "x$ztex" = xyes; then
  771. echo " ZTEX.FPGAs...........: Enabled"
  772. elif test "x$ztexwarn" = xyes; then
  773. echo " ZTEX.FPGAs...........: Disabled (libusb not found)"
  774. else
  775. echo " ZTEX.FPGAs...........: Disabled"
  776. fi
  777. if test "x$bitforce$modminer" != xnono; then
  778. echo " libudev.detection....: $libudev"
  779. fi
  780. echo
  781. if test "x$cpumining" = xyes; then
  782. echo " CPU Mining...........: Enabled"
  783. echo " ASM.(for CPU mining).: $has_yasm"
  784. else
  785. echo " CPU Mining...........: Disabled"
  786. fi
  787. echo
  788. echo "Compilation............: make (or gmake)"
  789. echo " CPPFLAGS.............:" $CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS
  790. echo " CFLAGS...............:" $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS
  791. echo " LDFLAGS..............:" $LDFLAGS $PTHREAD_FLAGS $PTHREAD_LIBS
  792. echo " LDADD................:" $LIBS $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $UDEV_LIBS $LIBUSB_LIBS
  793. echo
  794. echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
  795. echo " prefix...............: $prefix"
  796. echo