configure.ac 26 KB

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