configure.ac 25 KB

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