dnl * Copyright 2012-2013 Luke Dashjr dnl * Copyright 2011-2013 Con Kolivas dnl * Copyright 2010-2011 Jeff Garzik dnl * Copyright 2012 Xiangfu dnl * Copyright 2011 Rusty Russell dnl * Copyright 2011 Mark Crichton dnl * dnl * This program is free software; you can redistribute it and/or modify it dnl * under the terms of the GNU General Public License as published by the Free dnl * Software Foundation; either version 3 of the License, or (at your option) dnl * any later version. See COPYING for more details. ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## m4_define([v_maj], [3]) m4_define([v_min], [10]) m4_define([v_mic], [0]) ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## m4_define([v_ver], [v_maj.v_min.v_mic]) m4_define([lt_rev], m4_eval(v_maj + v_min)) m4_define([lt_cur], v_mic) m4_define([lt_age], v_min) ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## AC_INIT([bfgminer], [v_ver], [luke-jr+bfgminer@utopios.org]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([miner.c]) AC_CONFIG_HEADERS([config.h]) AH_BOTTOM([ #ifdef WIN32 #include #endif ]) AM_INIT_AUTOMAKE([foreign subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_USE_SYSTEM_EXTENSIONS ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## m4_ifdef([v_rev], , [m4_define([v_rev], [0])]) m4_ifdef([v_rel], , [m4_define([v_rel], [])]) AC_DEFINE_UNQUOTED(CGMINER_MAJOR_VERSION, [v_maj], [Major version]) AC_DEFINE_UNQUOTED(CGMINER_MINOR_VERSION, [v_min], [Minor version]) AC_DEFINE_UNQUOTED(CGMINER_MINOR_SUBVERSION, [v_mic], [Micro version]) version_info="lt_rev:lt_cur:lt_age" release_info="v_rel" AC_SUBST(version_info) AC_SUBST(release_info) ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## VMAJ=v_maj AC_SUBST(VMAJ) AC_CANONICAL_BUILD AC_CANONICAL_HOST dnl Make sure anyone changing configure.ac/Makefile.am has a clue AM_MAINTAINER_MODE([enable]) dnl Checks for programs AC_PROG_CC_C99 gl_EARLY AC_PROG_GCC_TRADITIONAL AM_PROG_CC_C_O AC_PROG_RANLIB AC_PROG_CPP gl_INIT AC_SYS_LARGEFILE dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(syslog.h) AC_CHECK_HEADERS([sys/epoll.h]) AC_CHECK_HEADERS([sys/mman.h]) AC_CHECK_HEADERS([sys/prctl.h]) AC_CHECK_HEADERS([sys/file.h]) AC_CHECK_HEADERS([linux/spi/spidev.h]) AC_CHECK_HEADERS([sys/file.h]) AC_CHECK_MEMBER([struct i2c_msg.buf],[ true ],[ dnl Note the member is different here to avoid caching screwing things up AC_CHECK_MEMBER([struct i2c_msg.len],[ AC_DEFINE([NEED_LINUX_I2C_H],[1],[Defined if linux/i2c.h is needed to supplement linux/i2c-dev.h]) ],[ true ],[ AC_INCLUDES_DEFAULT #include #include ]) ],[ AC_INCLUDES_DEFAULT #include ]) # Setuid AC_CHECK_HEADERS([pwd.h]) # Check for chroot support AC_CHECK_FUNCS([chroot]) AC_CHECK_FUNCS([sleep]) AC_FUNC_ALLOCA lowllist= driverlist= algolist=SHA256d optlist= has_fpga=no has_asic=no need_binloader=no need_dynclock=no need_lowl_vcom=no need_lowlevel=no need_lowl_hid=no need_lowl_pci=no need_lowl_usb=no have_cygwin=false have_win32=false have_macho=false use_udevrules=true have_udevrules=false AUTOSCAN_CPPFLAGS="" AUTOSCAN_LIBS="" DLOPEN_FLAGS="-ldl" WS2_LIBS="" MM_LIBS="" MATH_LIBS="-lm" RT_LIBS="" case $target in amd64-* | x86_64-*) have_x86_32=false have_x86_64=true bitness="64" ;; i386-* | i486-* | i586-* | i686-* | x86-*) have_x86_32=true have_x86_64=false bitness="32" ;; *) have_x86_32=false have_x86_64=false ;; esac case $target in *-*-mingw*) have_win32=true use_udevrules=false DLOPEN_FLAGS="" WS2_LIBS="-lws2_32" MM_LIBS="-lwinmm" AC_DEFINE([_WIN32_WINNT], [0x0501], "WinNT version for XP+ support") AC_DEFINE([FD_SETSIZE], [4096], [Maximum sockets before fd_set overflows]) ;; *-*-cygwin*) have_cygwin=true use_udevrules=false ;; powerpc-*-darwin*) CFLAGS="$CFLAGS -faltivec" have_macho=true use_udevrules=false ;; *-*-darwin*) have_macho=true use_udevrules=false ;; esac m4_define([BFG_INCLUDE], if test "x$2" = "x"; then $1='' else $1="[#]include <$2>" fi ) m4_define([BFG_PREPROC_IFELSE], BFG_INCLUDE([headerinclude], $2) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ ${headerinclude} ], [ #if !( $1 ) #error "$1 false in preprocessor" #endif ]) ],[$3],[$4]) ) AC_CHECK_DECL([HASH_ITER],[ AC_CHECK_DECL([DL_CONCAT],[ true ],[ AC_MSG_ERROR([Could not find DL_FOREACH_SAFE - install uthash-dev 1.9.4+]) ],[ #include ]) ],[ AC_MSG_ERROR([Could not find HASH_ITER - please install uthash-dev 1.9.4+]) ],[ #include ]) lowl_pci=no if test "x$ac_cv_header_sys_mman_h" = "xyes"; then AC_ARG_WITH([uio], [AC_HELP_STRING([--without-uio],[Compile support for PCI devices via Linux UIO interface (default enabled)])], [uio=$withval], [uio=yes]) AC_ARG_WITH([vfio], [AC_HELP_STRING([--without-vfio],[Compile support for PCI devices via Linux VFIO interface (default enabled)])], [vfio=$enableval], [vfio=auto]) if test "x$vfio" != "xno"; then AC_CHECK_HEADER([linux/vfio.h],[ vfio=yes ],[ if test "x$vfio" = "xyes"; then AC_MSG_ERROR([Unable to find linux/vfio.h]) elif test "x$uio" = "xyes"; then AC_MSG_WARN([linux/vfio.h not found; PCI device support will require UIO (and root access)]) else AC_MSG_WARN([linux/vfio.h not found; PCI device support will not be available]) fi vfio=no ]) fi if test "x$vfio$uio" != xnono; then lowl_pci=yes fi fi driverlist="$driverlist cpu/cpumining" cpumining="no" AC_ARG_ENABLE([cpumining], [AC_HELP_STRING([--enable-cpumining],[Build with CPU mining support (default disabled)])], [cpumining=$enableval] ) if test "x$cpumining" = xyes; then AC_DEFINE_UNQUOTED([WANT_CPUMINE], [1], [Enable CPUMINING]) driverlist="$driverlist cpu:asm/has_yasm" driverlist="$driverlist cpu:sse2/have_sse2" fi AM_CONDITIONAL([HAS_CPUMINE], [test x$cpumining = xyes]) driverlist="$driverlist opencl" opencl="no" AC_ARG_ENABLE([opencl], [AC_HELP_STRING([--enable-opencl],[Compile support for OpenCL (default disabled)])], [opencl=$enableval] ) if test "x$opencl" = xyes; then AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL support is wanted]) fi AM_CONDITIONAL([HAVE_OPENCL], [test x$opencl = xyes]) m4_define([BFG_PTHREAD_FLAG_CHECK], AC_MSG_CHECKING([for $1]) for cflag in ' -pthread' ''; do for lib in ' -lpthread' ' -lwinpthread' ''; do CFLAGS="${save_CFLAGS}${cflag}" LIBS="${save_LIBS}${lib}" AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #include ], [ void *f = $1; ]) ], [ found_pthread=true PTHREAD_FLAGS="${cflag}" PTHREAD_LIBS="${lib}" if test "x${cflag}${lib}" = "x"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([with${cflag}${lib}]) fi $2 break 2 ]) done done if test "x${found_pthread}" = "xfalse"; then AC_MSG_RESULT([no]) fi ) save_CFLAGS="${CFLAGS}" save_LIBS="${LIBS}" found_pthread=false BFG_PTHREAD_FLAG_CHECK([pthread_cancel],[ AC_DEFINE([HAVE_PTHREAD_CANCEL], [1], [Define if you have a native pthread_cancel]) ]) if test "x${found_pthread}" = "xfalse"; then BFG_PTHREAD_FLAG_CHECK([pthread_create]) if test "x${found_pthread}" = "xfalse"; then AC_MSG_ERROR([Could not find pthread library - please install libpthread]) fi fi # check for nanosleep here, since it is provided by winpthread AC_CHECK_FUNCS([nanosleep]) CFLAGS="${save_CFLAGS}" LIBS="${save_LIBS}" PKG_CHECK_MODULES([JANSSON],[jansson],[ true ],[ AC_MSG_CHECKING([for jansson in system-default locations]) LIBS="$LIBS -ljansson" AC_TRY_LINK([ #include ],[ json_object(); ],[ AC_MSG_RESULT([found]) JANSSON_LIBS=-ljansson ],[ AC_MSG_RESULT([not found]) AC_MSG_ERROR([Could not find jansson library]) ]) LIBS="${save_LIBS}" ]) AC_SUBST(JANSSON_CFLAGS) AC_SUBST(JANSSON_LIBS) if test "x$opencl" = xyes; then adl="yes" driverlist="$driverlist opencl:sensors/with_sensors" AC_ARG_WITH([sensors], [AC_HELP_STRING([--without-sensors],[Build with libsensors monitoring (default enabled)])], [true],[with_sensors=auto]) if test "x$opencl" != xyes; then with_sensors=no fi if test "x$with_sensors" != xno; then AC_MSG_CHECKING([for libsensors]) save_LIBS="${LIBS}" LIBS="$LIBS -lsensors" AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include #include ],[ const sensors_chip_name *cn; cn = sensors_get_detected_chips(NULL, NULL); ])],[ with_sensors=yes sensors_LIBS="-lsensors" AC_DEFINE([HAVE_SENSORS], [1], [Defined if libsensors was found]) AC_MSG_RESULT([yes]) ],[ with_sensors=no AC_MSG_RESULT([no]) if ! $have_win32; then with_sensors_enableaction="install libsensors" fi ]) LIBS="$save_LIBS" fi AC_SUBST(sensors_LIBS) driverlist="$driverlist opencl:adl/adl" AC_ARG_ENABLE([adl], [AC_HELP_STRING([--disable-adl],[Build without ADL monitoring (default enabled)])], [adl=$enableval] ) if test x$adl = xyes then AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found]) fi else adl="no" fi driverlist="$driverlist bitforce" AC_ARG_ENABLE([bitforce], [AC_HELP_STRING([--disable-bitforce],[Compile support for BitForce (default enabled)])], [bitforce=$enableval], [bitforce=yes] ) if test "x$bitforce" = xyes; then AC_DEFINE([USE_BITFORCE], [1], [Defined to 1 if BitForce support is wanted]) driverlist="$driverlist bitforce:uio/ac_cv_header_sys_mman_h" if test "x$lowl_pci" = "xyes"; then need_lowl_pci=yes fi need_lowl_vcom=yes has_fpga=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes]) driverlist="$driverlist icarus cairnsmore/icarus erupter/icarus antminer/icarus" AC_ARG_ENABLE([icarus], [AC_HELP_STRING([--disable-icarus],[Compile support for Icarus (default enabled)])], [icarus=$enableval], [icarus=yes] ) if test "x$icarus" = xyes; then AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted]) need_dynclock=yes need_lowl_vcom=yes has_fpga=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes]) driverlist="$driverlist avalon" avalon="no" AC_ARG_ENABLE([avalon], [AC_HELP_STRING([--disable-avalon],[Compile support for Avalon (default enabled)])], [avalon=$enableval], [avalon=yes] ) if test "x$avalon" = xyes; then AC_DEFINE([USE_AVALON], [1], [Defined to 1 if Avalon support is wanted]) need_lowl_vcom=yes has_asic=yes fi AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes]) driverlist="$driverlist knc" AC_ARG_ENABLE([knc], [AC_HELP_STRING([--enable-knc],[Compile support for KnC (default disabled)])], [knc=$enableval], [knc=no] ) if test "x$knc" = xyes; then AC_CHECK_HEADERS([linux/i2c-dev-user.h]) AC_CHECK_DECL([i2c_smbus_read_word_data],[true],[ AC_MSG_ERROR([linux/i2c-dev.h header from i2c-tools (NOT linux headers) is required for knc driver]) ],[ #include #ifdef HAVE_LINUX_I2C_DEV_USER_H #include #else #ifdef NEED_LINUX_I2C_H #include #endif #include #endif ]) AC_DEFINE([USE_KNC], [1], [Defined to 1 if KnC support is wanted]) fi AM_CONDITIONAL([USE_KNC], [test x$knc = xyes]) httpsrv=auto AC_ARG_WITH([libmicrohttpd], [AC_HELP_STRING([--without-libmicrohttpd],[Compile support for libmicrohttpd getwork server (default enabled)])], [httpsrv=$withval] ) if test "x$httpsrv" != "xno"; then PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.5],[ AC_DEFINE([USE_LIBMICROHTTPD],[1],[Defined to 1 if libmicrohttpd support is wanted]) httpsrv=yes ],[ httpsrv=no httpsrv_enableaction="install libmicrohttpd 0.9.5+" need_bfg_driver_proxy_enableaction="install libmicrohttpd 0.9.5+" if test "x$httpsrv" = "xyes"; then AC_MSG_ERROR([Unable to find libmicrohttpd 0.9.5+]) else AC_MSG_WARN([libmicrohttpd 0.9.5+ not found; getwork proxy will be unavailable]) fi ]) fi AM_CONDITIONAL([USE_LIBMICROHTTPD], [test x$httpsrv = xyes]) libevent=auto AC_ARG_WITH([libevent], [AC_HELP_STRING([--without-libevent],[Compile support for libevent stratum server (default enabled)])], [libevent=$withval] ) if test "x$libevent" != "xno"; then PKG_CHECK_MODULES([libevent],[libevent >= 2.0.3],[ AC_DEFINE([USE_LIBEVENT],[1],[Defined to 1 if libevent support is wanted]) libevent=yes ],[ libevent=no libevent_enableaction="install libevent 2.0.3+" if test -n "$need_bfg_driver_proxy_enableaction"; then need_bfg_driver_proxy_enableaction="${need_bfg_driver_proxy_enableaction} (getwork) or libevent 2.0.3+ (stratum)" else need_bfg_driver_proxy_enableaction="install libevent 2.0.3+" fi if test "x$libevent" = "xyes"; then AC_MSG_ERROR([Unable to find libevent 2.0.3+]) else AC_MSG_WARN([libevent 2.0.3+ not found; stratum proxy will be unavailable]) fi ]) fi AM_CONDITIONAL([USE_LIBEVENT], [test x$libevent = xyes]) driverlist="$driverlist proxy/need_bfg_driver_proxy" if test x$libevent$httpsrv = xnono; then need_bfg_driver_proxy=no else need_bfg_driver_proxy=yes driverlist="$driverlist proxy:getwork/httpsrv proxy:stratum/libevent" fi AM_CONDITIONAL([NEED_BFG_DRIVER_PROXY], [test x$libevent$httpsrv != xnono]) driverlist="$driverlist modminer" AC_ARG_ENABLE([modminer], [AC_HELP_STRING([--disable-modminer],[Compile support for ModMiner (default enabled)])], [modminer=$enableval], [modminer=yes] ) if test "x$modminer" = xyes; then AC_DEFINE([USE_MODMINER], [1], [Defined to 1 if ModMiner support is wanted]) need_dynclock=yes need_lowl_vcom=yes need_binloader=yes has_fpga=yes have_udevrules=true fi AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes]) PKG_PROG_PKG_CONFIG() optlist="$optlist libusb" libusb=no libusb_include_path="" AC_ARG_WITH([libusb], [AC_HELP_STRING([--without-libusb],[Compile using libusb (default enabled)])], [want_libusb=$withval], [want_libusb=yes] ) if test "x$want_libusb" = "xyes"; then PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],[ libusb=yes ],[ for usb_lib in usb-1.0 usb; do AC_CHECK_LIB($usb_lib, libusb_init, [ libusb=yes break ]) done if test "x$libusb" = xyes; then AC_CHECK_DECL([libusb_init],[ LIBUSB_LIBS="-l$usb_lib" ],[ AC_MSG_CHECKING([whether libusb_init is declared in subdirectory]) libusb_include_path=`echo '#include ' | ${CPP} -M - 2>/dev/null | sed -E -e 's/^[^:]+:[[:space:]]*(([^[:space:]]|\\\\[[:space:]])*)libusb\\.h([[:space:]].*|$)$/\\1/' -e 't my' -e d -e ': my' -e 's/\\\\?([\\\\[:space:]])/\\\\\\1/g'` if test "x$libusb_include_path" != "x"; then LIBUSB_LIBS="-l$usb_lib" LIBUSB_CFLAGS="-I$libusb_include_path" AC_MSG_RESULT([yes]) else libusb=no AC_MSG_RESULT([no]) fi ],[#include ]) fi ]) fi driverlist="$driverlist klondike" AC_ARG_ENABLE([klondike], [AC_HELP_STRING([--disable-klondike],[Compile support for Klondike (default enabled)])], [klondike=$enableval], [klondike=auto] ) if test "x$klondike$want_libusb" = xyesno; then AC_MSG_ERROR([You disabled libusb, required for Klondike support]) elif test "x$klondike$libusb" = xyesno; then AC_MSG_ERROR([Could not find libusb, required for Klondike support]) elif test "x$klondike" = xauto; then klondike="$libusb" if test "x$libusb" = xno; then AC_MSG_WARN([Could not find libusb, required for Klondike support]) klondike_enableaction="install libusb 1.0+" fi fi if test "x$klondike" = xyes; then AC_DEFINE([USE_KLONDIKE], [1], [Defined to 1 if Klondike support is wanted]) need_lowl_usb=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_KLONDIKE], [test x$klondike = xyes]) driverlist="$driverlist x6500" AC_ARG_ENABLE([x6500], [AC_HELP_STRING([--disable-x6500],[Compile support for X6500 (default if libusb)])], [x6500=$enableval], [x6500=auto] ) if test "x$x6500$want_libusb" = xyesno; then AC_MSG_ERROR([You disabled libusb, required for X6500 support]) elif test "x$x6500$libusb" = xyesno; then AC_MSG_ERROR([Could not find libusb, required for X6500 support]) elif test "x$x6500" = xauto; then x6500="$libusb" if test "x$libusb" = xno; then AC_MSG_WARN([Could not find libusb, required for X6500 support]) x6500_enableaction="install libusb 1.0+" fi fi if test "x$x6500" = xyes; then AC_DEFINE([USE_X6500], [1], [Defined to 1 if X6500 support is wanted]) need_dynclock=yes need_lowl_usb=yes need_binloader=yes has_fpga=yes have_udevrules=true fi AM_CONDITIONAL([HAS_X6500], [test x$x6500 = xyes]) driverlist="$driverlist ztex" AC_ARG_ENABLE([ztex], [AC_HELP_STRING([--disable-ztex],[Compile support for ZTEX (default if libusb)])], [ztex=$enableval], [ztex=auto] ) if test "x$ztex$want_libusb" = xyesno; then AC_MSG_ERROR([You disabled libusb, required for ZTEX support]) elif test "x$ztex$libusb" = xyesno; then AC_MSG_ERROR([Could not find libusb, required for ZTEX support]) elif test "x$ztex" = xauto; then ztex="$libusb" if test "x$libusb" = xno; then AC_MSG_WARN([Could not find libusb, required for ZTEX support]) ztex_enableaction="install libusb 1.0+" fi fi if test "x$ztex" = xyes; then AC_DEFINE([USE_ZTEX], [1], [Defined to 1 if ZTEX support is wanted]) need_dynclock=yes need_lowl_usb=yes need_binloader=yes has_fpga=yes have_udevrules=true fi AM_CONDITIONAL([HAS_ZTEX], [test x$ztex = xyes]) driverlist="$driverlist bifury" AC_ARG_ENABLE([bifury], [AC_HELP_STRING([--disable-bifury],[Compile support for Bi*Fury (default enabled)])], [bifury=$enableval], [bifury=yes] ) if test "x$bifury" = "xyes"; then AC_DEFINE([USE_BIFURY], [1], [Defined to 1 if Bi*Fury support is wanted]) need_lowl_vcom=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([USE_BIFURY], [test x$bifury = xyes]) driverlist="$driverlist bitfury_gpio/bitfury" bitfury=yes AC_ARG_ENABLE([bitfury], [AC_HELP_STRING([--disable-bitfury],[Compile support for Bitfury (default enabled)])], [bitfury=$enableval] ) if test "x$bitfury" = xyes; then AC_DEFINE([USE_BITFURY], [1], [Defined to 1 if Bitfury support is wanted]) fi AM_CONDITIONAL([HAS_BITFURY], [test x$bitfury = xyes]) driverlist="$driverlist bfsb" bfsb=no AC_ARG_ENABLE([bfsb], [AC_HELP_STRING([--enable-bfsb],[Compile support for BFSB (default disabled)])], [bfsb=$enableval] ) if test "x$bfsb" = "xyes"; then if test "x$bitfury" = "xno"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BFSB]) fi AC_DEFINE([USE_BFSB], [1], [Defined to 1 if BFSB support is wanted]) fi AM_CONDITIONAL([HAS_BFSB], [test x$bfsb = xyes]) driverlist="$driverlist bigpic" bigpic=auto AC_ARG_ENABLE([bigpic], [AC_HELP_STRING([--disable-bigpic],[Compile support for Big Picture Mining USB (default enabled)])], [bigpic=$enableval] ) if test "x$bigpic" = "xno"; then true elif test "x$bitfury" = "xyes"; then bigpic=yes elif test "x$bigpic" = "xyes"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled BigPic]) else bigpic=no fi if test "x$bigpic" = "xyes"; then AC_DEFINE([USE_BIGPIC], [1], [Defined to 1 if Big Picture Mining USB support is wanted]) need_lowl_vcom=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_BIGPIC], [test x$bigpic = xyes]) driverlist="$driverlist drillbit" AC_ARG_ENABLE([drillbit], [AC_HELP_STRING([--disable-drillbit],[Compile support for DrillBit (default enabled)])], [drillbit=$enableval], [drillbit=auto] ) if test "x$drillbit" = "xno"; then true elif test "x$bitfury" = "xyes"; then drillbit=yes elif test "x$drillbit" = "xyes"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled DrillBit]) else drillbit=no fi if test "x$drillbit" = "xyes"; then AC_DEFINE([USE_DRILLBIT], [1], [Defined to 1 if DrillBit support is wanted]) need_lowl_vcom=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([USE_DRILLBIT], [test x$drillbit = xyes]) driverlist="$driverlist twinfury" twinfury=auto AC_ARG_ENABLE([twinfury], [AC_HELP_STRING([--disable-twinfury],[Compile support for Twinfury USB miner (default enabled)])], [twinfury=$enableval] ) if test "x$twinfury" = "xno"; then true elif test "x$bitfury" = "xyes"; then twinfury=yes elif test "x$twinfury" = "xyes"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Twinfury]) else twinfury=no fi if test "x$twinfury" = "xyes"; then AC_DEFINE([USE_TWINFURY], [1], [Defined to 1 if Twinfury USB miner support is wanted]) need_lowl_vcom=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_TWINFURY], [test x$twinfury = xyes]) driverlist="$driverlist littlefury" littlefury=auto AC_ARG_ENABLE([littlefury], [AC_HELP_STRING([--disable-littlefury],[Compile support for LittleFury (default enabled)])], [littlefury=$enableval] ) if test "x$littlefury" = "xno"; then true elif test "x$bitfury" = "xyes"; then littlefury=yes elif test "x$littlefury" = "xyes"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled LittleFury]) else littlefury=no fi if test "x$littlefury" = "xyes"; then AC_DEFINE([USE_LITTLEFURY], [1], [Defined to 1 if LittleFury support is wanted]) need_lowl_vcom=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_LITTLEFURY], [test x$littlefury = xyes]) found_hidapi=false for _hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do PKG_CHECK_MODULES([hidapi],[$_hidapi_lib],[ found_hidapi=true break ],[ true ]) done driverlist="$driverlist nanofury" nanofury=auto AC_ARG_ENABLE([nanofury], [AC_HELP_STRING([--disable-nanofury],[Compile support for NanoFury (default enabled)])], [nanofury=$enableval] ) if test "x$nanofury" = "xno"; then true elif test "x$bitfury" = "xyes"; then if test x$found_hidapi = xtrue; then nanofury=yes else if test x$nanofury = xauto; then nanofury=no nanofury_enableaction="install hidapi" else AC_MSG_ERROR([Could not find hidapi, required for NanoFury support]) fi fi elif test "x$nanofury" = "xyes"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled NanoFury]) else nanofury=no fi if test "x$nanofury" = "xyes"; then AC_DEFINE([USE_NANOFURY], [1], [Defined to 1 if NanoFury support is wanted]) need_lowl_hid=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([HAS_NANOFURY], [test x$nanofury = xyes]) driverlist="$driverlist hashbuster" hashbuster=auto AC_ARG_ENABLE([hashbuster], [AC_HELP_STRING([--disable-hashbuster],[Compile support for HashBuster Nano (default enabled)])], [hashbuster=$enableval] ) if test "x$hashbuster" = "xno"; then true elif test "x$bitfury" = "xyes"; then if test x$found_hidapi = xtrue; then hashbuster=yes else if test x$hashbuster = xauto; then hashbuster=no hashbuster_enableaction="install hidapi" else AC_MSG_ERROR([Could not find hidapi, required for HashBuster Nano support]) fi fi elif test "x$hashbuster" = "xyes"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled HashBuster Nano]) else hashbuster=no fi if test "x$hashbuster" = "xyes"; then AC_DEFINE([USE_HASHBUSTER], [1], [Defined to 1 if HashBuster Nano support is wanted]) need_lowl_hid=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([USE_HASHBUSTER], [test x$hashbuster = xyes]) driverlist="$driverlist hashbusterusb" AC_ARG_ENABLE([hashbusterusb], [AC_HELP_STRING([--disable-hashbusterusb],[Compile support for HashBuster Micro (default if libusb)])], [hashbusterusb=$enableval], [hashbusterusb=auto] ) if test "x$hashbusterusb$want_libusb" = xyesno; then AC_MSG_ERROR([You disabled libusb, required for HashBuster Micro support]) elif test "x$hashbusterusb$libusb" = xyesno; then AC_MSG_ERROR([Could not find libusb, required for HashBuster Micro support]) elif test "x$hashbusterusb" = xauto; then hashbusterusb="$libusb" if test "x$libusb" = xno; then AC_MSG_WARN([Could not find libusb, required for HashBuster Micro support]) hashbusterusb_enableaction="install libusb 1.0+" fi fi if test "x$hashbusterusb" = xyes; then AC_DEFINE([USE_HASHBUSTERUSB], [1], [Defined to 1 if HashBuster Micro support is wanted]) need_lowl_usb=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([USE_HASHBUSTERUSB], [test x$hashbusterusb = xyes]) driverlist="$driverlist hashfast" hashfast=yes AC_ARG_ENABLE([hashfast], [AC_HELP_STRING([--disable-hashfast],[Compile support for HashFast (default enabled)])], [hashfast=$enableval] ) if test "x$hashfast" = xyes; then AC_DEFINE([USE_HASHFAST], [1], [Defined to 1 if HashFast support is wanted]) need_lowl_vcom=yes has_asic=yes have_udevrules=true fi AM_CONDITIONAL([USE_HASHFAST], [test x$hashfast = xyes]) driverlist="$driverlist metabank" metabank=no AC_ARG_ENABLE([metabank], [AC_HELP_STRING([--enable-metabank],[Compile support for Metabank (default disabled)])], [metabank=$enableval] ) if test "x$metabank" = "xyes"; then if test "x$bitfury" = "xno"; then AC_MSG_ERROR([You explicitly disabled Bitfury and explicitly enabled Metabank]) fi AC_DEFINE([USE_METABANK], [1], [Defined to 1 if Metabank support is wanted]) fi AM_CONDITIONAL([HAS_METABANK], [test x$metabank = xyes]) if test "x$need_lowl_vcom" != "xno"; then # Lowlevel VCOM doesn't need libusb, but it can take advantage of it to reattach drivers need_lowl_usb=yes fi if test "x$need_lowl_usb" = "xno"; then libusb=no LIBUSB_LIBS='' LIBUSB_CFLAGS='' fi if test "x$libusb" = xyes; then AC_DEFINE([HAVE_LIBUSB], [1], [Define if you have libusb-1.0]) save_CFLAGS="$CFLAGS" CFLAGS="$LIBUSB_CFLAGS $CFLAGS" AC_CHECK_DECLS([libusb_error_name],[true],[true],[#include ]) CFLAGS="$save_CFLAGS" fi algolist="$algolist scrypt" scrypt="no" AC_ARG_ENABLE([scrypt], [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])], [scrypt=$enableval] ) if test "x$scrypt" = xyes; then AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted]) fi if test x$need_lowl_vcom = xyes; then AC_DEFINE([NEED_BFG_LOWL_VCOM], [1], [Defined to 1 if lowlevel VCOM drivers are being used]) need_lowlevel=yes if $have_win32; then echo '#include ' >iospeeds_local.h found_ddkusb=false AC_CHECK_HEADER([usbiodef.h],[ found_ddkusb=true ],[ AC_CHECK_HEADER([ddk/usbiodef.h],[ found_ddkusb=true AUTOSCAN_CPPFLAGS="-I"`echo '#include ' | ${CPP} -M - 2>/dev/null | sed -E -e 's/^[^:]+:[[:space:]]*(([^[:space:]]|\\\\[[:space:]])*)usbiodef\\.h([[:space:]].*|$)$/\\1/' -e 't my' -e d -e ': my' -e 's/\\\\?([\\\\[:space:]])/\\\\\\1/g'` ],[ true ],[ #include #include AC_INCLUDES_DEFAULT ]) ],[ #include #include AC_INCLUDES_DEFAULT ]) if $found_ddkusb; then AUTOSCAN_LIBS="-lsetupapi" AC_DEFINE([HAVE_WIN_DDKUSB],[1],[Defined to 1 if Windows DDK USB headers are being used]) fi else AC_MSG_CHECKING([what baud rates your system supports]) echo '#include ' | ${CPP} -dM - 2>/dev/null | sed 's/.*[ ]B\([0-9][0-9]*\)[ ].*/IOSPEED(\1)/' | grep IOSPEED >iospeeds_local.h if grep -q IOSPEED iospeeds_local.h; then AC_MSG_RESULT([done]) else AC_MSG_RESULT([failed, using standard POSIX]) echo '#include ' >iospeeds_local.h fi fi fi if test "x$opencl$need_lowl_hid" = xnono; then DLOPEN_FLAGS="" fi lowllist="$lowllist hid/need_lowl_hid" if test x$need_lowl_hid = xyes; then AC_DEFINE([NEED_BFG_LOWL_HID], [1], [Defined to 1 if lowlevel hid drivers are being used]) need_lowlevel=yes fi lowllist="$lowllist pci/need_lowl_pci" if test x$need_lowl_pci = xyes; then AC_DEFINE([NEED_BFG_LOWL_PCI], [1], [Defined to 1 if lowlevel PCI drivers are being used]) need_lowlevel=yes lowllist="$lowllist pci:uio/uio" if test x$uio = xyes; then AC_DEFINE([USE_UIO], [1], [Defined to 1 if lowlevel PCI drivers should support UIO]) fi lowllist="$lowllist pci:vfio/vfio" if test x$vfio = xyes; then AC_DEFINE([USE_VFIO], [1], [Defined to 1 if lowlevel PCI drivers should support VFIO]) fi fi lowllist="$lowllist usb/need_lowl_usb" if test x$need_lowl_usb = xyes; then need_lowlevel=yes fi lowllist="$lowllist vcom/need_lowl_vcom" if test x$need_lowl_vcom = xyes; then need_lowlevel=yes fi if test x$need_lowlevel = xyes; then AC_DEFINE([HAVE_BFG_LOWLEVEL], [1], [Defined to 1 if lowlevel drivers are being used]) fi curses="auto" AC_ARG_WITH([curses], [AC_HELP_STRING([--without-curses],[Compile support for curses TUI (default enabled)])], [curses=$withval] ) if test "x$curses" = "xno"; then optlist="$optlist curses" else curses_enableaction="install a curses library" orig_libs="$LIBS" if test "x${curses}" = "xyes"; then preferl='' else preferl="${curses} ${curses}6 ${curses}5" fi for wideornot in w u ''; do for ncursesver in '' 6 5; do preferl="${preferl} ncurses${wideornot}${ncursesver}" done preferl="${preferl} pdcurses${wideornot}" done if test "x$cross_compiling" != "xyes"; then AC_MSG_CHECKING([for best native curses library]) orig_cflags="$CFLAGS" for curses_lib in ${preferl}; do if ! ${curses_lib}-config --cflags >/dev/null 2>/dev/null; then continue fi CFLAGS="$orig_cflags $(${curses_lib}-config --cflags)" LIBS="$orig_libs $(${curses_lib}-config --libs)" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ WINDOW *w = NULL; mvwprintw(w, 2, 2, "Testing %s", "o hai"); ]])], [ curses=yes optlist="$optlist ${curses_lib}/curses" AC_MSG_RESULT([$curses_lib]) NCURSES_LIBS=`${curses_lib}-config --libs` NCURSES_CPPFLAGS=`${curses_lib}-config --cflags` break ], [ AC_MSG_WARN([${curses_lib} doesn't seem to be installed properly]) ]) done CFLAGS="$orig_cflags" if test "x$curses" != "xyes"; then AC_MSG_RESULT([none?]) fi fi if test "x$curses" != "xyes"; then sym=addstr AC_SEARCH_LIBS(${sym}, ${preferl}, [ curses=yes eval "curseslib=\"\${ac_cv_search_${sym}}\"" barelib="${curseslib/-l/}" optlist="$optlist ${barelib}/curses" if test "x${curseslib}" != "xnone required"; then NCURSES_LIBS="${curseslib}" fi # Need to check for headers in subdirectories, to ensure we get wide stuff AC_MSG_CHECKING([for curses header subdirectory]) barelib="${barelib/6/}" barelib="${barelib/5/}" cursesincl=`echo '#include <'"${barelib}"'/curses.h>' | ${CPP} -M - 2>/dev/null | sed -E -e 's/^[^:]+:[[:space:]]*(([^[:space:]]|\\\\[[:space:]])*)curses\\.h([[:space:]].*|$)$/\\1/' -e 't my' -e d -e ': my' -e 's/\\\\?([\\\\[:space:]])/\\\\\\1/g'` if test "x$cursesincl" != "x"; then NCURSES_CPPFLAGS="-I${cursesincl}" AC_MSG_RESULT([$cursesincl]) else AC_MSG_RESULT([none found]) fi break ], [ if test "x$curses" = "xyes"; then AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)]) else AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev]) curses=no optlist="$optlist curses" fi ]) fi if test "x$curses" = "xyes"; then AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted]) AC_MSG_CHECKING([whether curses library supports wide characters]) LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS" AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #define PDC_WIDE #include ],[ addwstr(L"test"); add_wch(WACS_VLINE); ]) ],[ AC_MSG_RESULT([yes]) AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters]) ],[ AC_MSG_RESULT([no]) ]) fi LIBS="$orig_libs" fi maybe_ldconfig= AC_ARG_WITH([system-libblkmaker], [AC_HELP_STRING([--with-system-libblkmaker], [Use system libblkmaker rather than bundled one (default disabled)])],[true],[with_system_libblkmaker=no]) if test "x$with_system_libblkmaker" = "xyes"; then PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[ true ],[ AC_MSG_ERROR([Could not find system libblkmaker]) ]) else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,-zorigin" origin_LDFLAGS= AC_MSG_CHECKING([whether the linker recognizes the -zorigin option]) AC_TRY_LINK([],[],[ AC_MSG_RESULT([yes]) origin_LDFLAGS=',-zorigin' ],[ AC_MSG_RESULT([no]) ]) LDFLAGS="$save_LDFLAGS" libblkmaker_CFLAGS='-Ilibblkmaker' libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS" libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1' AC_CONFIG_SUBDIRS([libblkmaker]) _ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g` possible_ldconfigs="${target}-ldconfig" if test "x$cross_compiling" != "xyes"; then possible_ldconfigs="${possible_ldconfigs} ldconfig" fi AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH]) if test "x$LDCONFIG" != "x"; then maybe_ldconfig=" && $LDCONFIG" fi fi AC_SUBST(libblkmaker_CFLAGS) AC_SUBST(libblkmaker_LDFLAGS) AC_SUBST(libblkmaker_LIBS) $have_udevrules || use_udevrules=false if $use_udevrules; then AC_ARG_WITH([udevrulesdir], AS_HELP_STRING([--with-udevrulesdir=DIR], [Install udev rules into this directory]), [], [ if test -d /lib/udev/rules.d; then with_udevrulesdir=/lib/udev/rules.d else with_udevrulesdir=no fi ] ) if test "x$with_udevrulesdir" = "xno"; then use_udevrules=false fi if $use_udevrules; then AC_SUBST([udevrulesdir], [$with_udevrulesdir]) fi fi AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes]) AM_CONDITIONAL([NEED_BFG_BINLOADER], [test x$need_binloader = xyes]) AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes]) AM_CONDITIONAL([NEED_BFG_LOWL_VCOM], [test x$need_lowl_vcom = xyes]) AM_CONDITIONAL([NEED_BFG_LOWL_HID], [test x$need_lowl_hid = xyes]) AM_CONDITIONAL([NEED_BFG_LOWL_PCI], [test x$need_lowl_pci = xyes]) AM_CONDITIONAL([NEED_BFG_LOWLEVEL], [test x$need_lowlevel = xyes]) AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes]) AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes]) AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes]) AM_CONDITIONAL([HAVE_CYGWIN], [test x$have_cygwin = xtrue]) AM_CONDITIONAL([HAVE_LIBUSB], [test x$libusb = xyes]) AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue]) AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue]) AM_CONDITIONAL([HAVE_WIN_DDKUSB], [test x$found_ddkusb = xtrue]) AM_CONDITIONAL([HAS_FPGA], [test x$has_fpga != xno]) AM_CONDITIONAL([HAS_ASIC], [test x$has_asic != xno]) AM_CONDITIONAL([USE_UDEVRULES], [$use_udevrules]) dnl Find YASM has_yasm=false if test "x$have_x86_32$have_x86_64" != "xfalsefalse"; then AC_PATH_PROG([YASM],[yasm],[false]) if test "x$YASM" != "xfalse" ; then has_yasm_enableaction="install yasm 1.0.1+" AC_MSG_CHECKING([if yasm version is greater than 1.0.1]) yasmver=`"$YASM" --version | head -1 | cut -d\ -f2` yamajor=`echo $yasmver | cut -d. -f1` yaminor=`echo $yasmver | cut -d. -f2` yamini=`echo $yasmver | cut -d. -f3` if test "$yamajor" -ge "1" ; then if test "$yamajor" -eq "1" ; then if test "$yaminor" -ge "0" ; then if test "$yaminor" -eq "0"; then if test "$yamini" -ge "1"; then has_yasm=true fi else has_yasm=true fi fi fi else has_yasm=false fi if test "x$has_yasm" = "xtrue" ; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi fi if test "x$has_yasm" = "xfalse" ; then AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.]) else AC_DEFINE([HAVE_YASM], [1], [Defined to 1 if yasm is being used]) if test "x$have_win32$have_cygwin" != "xfalsefalse"; then if test "x$have_x86_64" = xtrue; then YASM_FMT="win64" else YASM_FMT="coff" fi elif test "x$have_macho" = "xtrue"; then YASM_FMT="macho$bitness" else YASM_FMT="elf$bitness" fi fi fi AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue]) have_sse2=no if test "x$cpumining$have_x86_32" = "xyestrue"; then AC_MSG_CHECKING([if SSE2 code compiles]) save_CFLAGS="$CFLAGS" for flags in '' '-msse2'; do CFLAGS="$CFLAGS $flags" AC_TRY_LINK([ #include ],[ int *i = (int *)0xdeadbeef; __m128i a, b; a = _mm_set1_epi32(i[0]); b = _mm_set_epi32(i[0], i[1], i[2], i[3]); a = _mm_add_epi32(a, b); a = _mm_andnot_si128(a, b); a = _mm_or_si128(a, b); a = _mm_slli_epi32(a, i[4]); a = _mm_and_si128(a, b); a = _mm_xor_si128(a, b); ],[ if test "x$flags" = "x"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([with $flags]) fi SSE2_CFLAGS="$flags" have_sse2=yes break ],[ true ]) done CFLAGS="${save_CFLAGS}" if test "x$have_sse2" = "xyes"; then AC_DEFINE([HAVE_SSE2], [1], [Defined to 1 if yasm is being used]) else AC_MSG_RESULT([no]) fi fi AM_CONDITIONAL([HAVE_SSE2], [test "x$have_sse2" = "xyes"]) if test "x$need_lowl_vcom" = "xyes"; then AC_ARG_WITH([libudev], [AC_HELP_STRING([--without-libudev], [Autodetect FPGAs using libudev (default enabled)])], [libudev=$withval], [libudev=auto] ) if test "x$libudev" != "xno"; then AC_CHECK_HEADER([libudev.h],[ libudev=yes UDEV_LIBS=-ludev AC_DEFINE([HAVE_LIBUDEV], [1], [Defined to 1 if libudev is wanted]) ], [ if test "x$libudev" = "xyes"; then AC_MSG_ERROR([libudev not found]) fi libudev=no ]) fi fi AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno]) AC_SUBST(LIBUSB_LIBS) AC_SUBST(LIBUSB_CFLAGS) PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])]) if echo "$LIBCURL_CFLAGS" | grep '@CPPFLAG_CURL_STATICLIB@' >/dev/null 2>&1; then AC_MSG_WARN([Your libcurl pkgconfig file is broken, applying workaround]) LIBCURL_CFLAGS=`echo "$LIBCURL_CFLAGS" | sed 's/@CPPFLAG_CURL_STATICLIB@//'` fi AC_SUBST(LIBCURL_LIBS) AC_CHECK_FUNCS([setrlimit]) dnl CCAN wants to know a lot of vars. # All the configuration checks. Regrettably, the __attribute__ checks will # give false positives on old GCCs, since they just cause warnings. But that's # fairly harmless. AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((cold)) cleanup(void) { }])], AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1], [Define if __attribute__((cold))])) AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((const)) cleanup(void) { }])], AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1], [Define if __attribute__((const))])) AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((noreturn)) cleanup(void) { exit(1); }])], [ AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1], [Define if __attribute__((noreturn))]) AC_DEFINE_UNQUOTED([NORETURN], [__attribute__((noreturn))], [Syntax of noreturn attribute]) ], [ AC_DEFINE_UNQUOTED([NORETURN], []) ] ) AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((format(__printf__, 1, 2))) cleanup(const char *fmt, ...) { }])], AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1], [Define if __attribute__((format(__printf__)))])) AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((unused)) cleanup(void) { }])], AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1], [Define if __attribute__((unused))])) AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((used)) cleanup(void) { }])], AC_DEFINE([HAVE_ATTRIBUTE_USED], [1], [Define if __attribute__((used))])) AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_constant_p(1) ? 0 : 1; }])], AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1], [Define if have __builtin_constant_p])) AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_types_compatible_p(char *, int) ? 1 : 0; }])], AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1], [Define if have __builtin_types_compatible_p])) AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)) func(int x) { return x; }])], AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1], [Define if __attribute__((warn_unused_result))])) # byteswap functions AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h]) AH_TEMPLATE([HAVE_ENDIAN_H], [Define to use byteswap macros from endian.h]) AH_TEMPLATE([HAVE_SYS_ENDIAN_H], [Define to use byteswap macros from sys/endian.h]) AH_TEMPLATE([HAVE_LIBKERN_OSBYTEORDER_H], [Define to use byteswap macros from libkern/OSByteOrder.h]) BSWAP='' for sym in bswap_ __builtin_bswap __bswap_ __swap swap OSSwapInt; do AC_MSG_CHECKING([for ${sym}* functions]) for headerfile in '' byteswap.h endian.h sys/endian.h libkern/OSByteOrder.h; do BFG_INCLUDE([headerinclude], [${headerfile}]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([ ${headerinclude} ], [ (void) ${sym}16(0); (void) ${sym}32(0); (void) ${sym}64(0); ]) ], [ BSWAP="${sym}" if test "x${headerfile}" = "x"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([found in ${headerfile}]) AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$headerfile]), 1) fi break 2 ]) done AC_MSG_RESULT([no]) done if test "x$BSWAP" = "x"; then true # Substitutes are provided in miner.h elif test "x$BSWAP" = "xbswap_"; then AC_MSG_CHECKING([if bswap_16 is already a macro]) BFG_PREPROC_IFELSE([defined(bswap_16)], $headerfile, [ AC_MSG_RESULT([yes]) BSWAP="" ],[ AC_MSG_RESULT([no]) ]) fi if test "x$BSWAP" != "x"; then AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, [Define to 16-bit byteswap macro]) AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, [Define to 16-bit byteswap macro]) AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, [Define to 16-bit byteswap macro]) fi # endian definition macros AC_MSG_CHECKING([for platform endian]) found_endian=no for headerfile in '' endian.h sys/endian.h sys/param.h; do for pfx in '' '__'; do 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}, [ if test "x$headerfile" = "x"; then headerfilec='' else headerfilec=" (${headerfile})" fi BFG_PREPROC_IFELSE([${pfx}BYTE_ORDER == ${pfx}BIG_ENDIAN], ${headerfile}, [ AC_MSG_RESULT([big endian${headerfilec}]) AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if your platform is big endian]) ], [ AC_MSG_RESULT([little endian${headerfilec}]) ]) found_endian=yes break 2 ],[true]) done done if test "x$found_endian" = "xno"; then if $have_win32 || $have_cygwin; then AC_MSG_RESULT([assuming little endian (Windows)]) else # AC_C_BIGENDIAN is reported to have problems, and invasive even if buried in a conditional, so don't use it AC_MSG_RESULT([unknown]) AC_MSG_ERROR([Unable to identify platform endian]) fi fi AC_MSG_CHECKING([if good static asserts compile]) AC_TRY_LINK([ ], [ _Static_assert(1, ":)"); ], [ AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) AC_DEFINE_UNQUOTED([_Static_assert(...)], [], [Turns _Static_assert into noop for compilers that don't support it]) ]) AC_MSG_CHECKING([if GNU format attribute compiles]) AC_TRY_COMPILE([ #define FORMAT_SYNTAX_CHECK(...) __attribute__(( format(__VA_ARGS__) )) int myfunc(char *fmt, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2); int myfunc(char *fmt, ...) { return 42; } ], [ myfunc("abc%d", 42); ], [ AC_MSG_RESULT([yes]) AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], [__attribute__(( format(__VA_ARGS__) ))], [Syntax of format-checking attribute]) ], [ AC_MSG_RESULT([no]) AC_DEFINE_UNQUOTED([FORMAT_SYNTAX_CHECK(...)], []) ]) AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC)]) AC_TRY_COMPILE([ #define _GNU_SOURCE #include ],[ struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); ],[ AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC) is defined]) save_LIBS="${LIBS}" AC_SEARCH_LIBS([clock_gettime],[rt posix4],[ if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then RT_LIBS="${ac_cv_search_clock_gettime}" fi ]) LIBS="${save_LIBS}" AC_CHECK_FUNCS([clock_nanosleep]) AC_MSG_CHECKING([for clock_gettime(CLOCK_MONOTONIC_RAW)]) AC_TRY_COMPILE([ #define _GNU_SOURCE #include ],[ struct timespec ts; clock_gettime(CLOCK_MONOTONIC_RAW, &ts); ],[ AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC_RAW], [1], [Defined to 1 if clock_gettime(CLOCK_MONOTONIC_RAW) is defined]) ],[ AC_MSG_RESULT([no]) ]) ],[ AC_MSG_RESULT([no]) ]) if test "x$prefix" = xNONE; then prefix=/usr/local fi AM_CONDITIONAL([NEED_BITSTREAM_FPGAMINER], [test x$modminer$x6500 != xnono]) AC_DEFINE_UNQUOTED([PHATK_KERNNAME], ["phatk121016"], [Filename for phatk kernel]) AC_DEFINE_UNQUOTED([POCLBM_KERNNAME], ["poclbm130302"], [Filename for poclbm kernel]) AC_DEFINE_UNQUOTED([DIAKGCN_KERNNAME], ["diakgcn121016"], [Filename for diakgcn kernel]) AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo kernel]) AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel]) m4_define([BFG_PRINT_LIST],[ eval _mylist="\$$2" _yeslist= _nolist= _enableactions= for _opt in $_mylist; do IFS=/ read _opt _var <