configure.ac 26 KB

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