configure.ac 24 KB

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