Merge branch 'master' into hashfast Conflicts: Makefile.am
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
diff --git a/Makefile.am b/Makefile.am
index 7448600..8eedeb6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,8 +22,6 @@ INCLUDES = $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) $(USBUTILS_
bin_PROGRAMS = cgminer
-bin_SCRIPTS = $(top_srcdir)/*.cl
-
cgminer_LDFLAGS = $(PTHREAD_FLAGS)
cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
@OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ \
@@ -47,11 +45,10 @@ cgminer_SOURCES += elist.h miner.h compat.h bench_block.h \
cgminer_SOURCES += logging.c
-# GPU sources, TODO: make them selectable
-# the GPU portion extracted from original main.c
-cgminer_SOURCES += driver-opencl.h driver-opencl.c
+if HAS_OPENCL
+bin_SCRIPTS = $(top_srcdir)/*.cl
-# the original GPU related sources, unchanged
+cgminer_SOURCES += driver-opencl.h driver-opencl.c
cgminer_SOURCES += ocl.c ocl.h findnonce.c findnonce.h
cgminer_SOURCES += adl.c adl.h adl_functions.h
cgminer_SOURCES += *.cl
@@ -60,7 +57,8 @@ if HAS_SCRYPT
cgminer_SOURCES += scrypt.c scrypt.h
endif
-# Extra utilities required
+endif
+
if NEED_FPGAUTILS
cgminer_SOURCES += fpgautils.c fpgautils.h
endif
diff --git a/cgminer.c b/cgminer.c
index b3dacae..850d6f0 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4975,8 +4975,10 @@ static void *input_thread(void __maybe_unused *userdata)
display_pools();
else if (!strncasecmp(&input, "s", 1))
set_options();
+#if HAVE_OPENCL
else if (have_opencl && !strncasecmp(&input, "g", 1))
manage_gpu();
+#endif
if (opt_realquiet) {
disable_curses();
break;
diff --git a/compat/Makefile.am b/compat/Makefile.am
index 4ed10f8..4cd32d2 100644
--- a/compat/Makefile.am
+++ b/compat/Makefile.am
@@ -2,5 +2,7 @@
SUBDIRS = jansson-2.5
if WANT_USBUTILS
+if WANT_STATIC_LIBUSB
SUBDIRS += libusb-1.0
endif
+endif
diff --git a/configure.ac b/configure.ac
index 27c68ba..e0bc70a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,10 +135,10 @@ if test -n "$CGMINER_SDK"; then
LDFLAGS="-L$CGMINER_SDK/lib/$target $LDFLAGS"
fi
-opencl="yes"
+opencl="no"
AC_ARG_ENABLE([opencl],
- [AC_HELP_STRING([--disable-opencl],[Override detection and disable building with opencl])],
+ [AC_HELP_STRING([--enable-opencl],[Enable support for GPU mining with opencl])],
[opencl=$enableval]
)
if test "x$opencl" != xno; then
@@ -171,6 +171,7 @@ else
OPENCL_FLAGS=""
OPENCL_LIBS=""
fi
+AM_CONDITIONAL([HAS_OPENCL], [test x$opencl = xyes])
has_winpthread=false
if test "x$have_win32" = xtrue; then
@@ -344,21 +345,42 @@ AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
-AC_CONFIG_SUBDIRS([compat/libusb-1.0])
if test "x$want_usbutils" != xfalse; then
+ dlibusb="no"
AC_DEFINE([USE_USBUTILS], [1], [Defined to 1 if usbutils support required])
- LIBUSB_LIBS="compat/libusb-1.0/libusb/.libs/libusb-1.0.a"
- if test "x$have_linux" = "xtrue"; then
- PKG_CHECK_MODULES([UDEV], [libudev], LIBUSB_LIBS+=" -ludev", [AC_MSG_ERROR([Missing required libudev dev])])
- fi
- if test "x$have_darwin" = "xtrue"; then
- LIBUSB_LIBS+=" -lobjc"
- LDFLAGS+=" -framework CoreFoundation -framework IOKit"
+ AC_ARG_WITH([system-libusb],
+ [AC_HELP_STRING([--with-system-libusb],[Compile against dynamic system libusb (default use included static libusb)])],
+ [dlibusb=$withval]
+ )
+
+ if test "x$dlibusb" != xno; then
+ case $target in
+ *-*-freebsd*)
+ LIBUSB_LIBS="-lusb"
+ LIBUSB_CFLAGS=""
+ AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb-1.0])
+ ;;
+ *)
+ PKG_CHECK_MODULES(LIBUSB, libusb-1.0, [AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb-1.0])], [AC_MSG_ERROR([Could not find usb library - please install libusb-1.0])])
+ ;;
+ esac
+ else
+ AC_CONFIG_SUBDIRS([compat/libusb-1.0])
+ LIBUSB_LIBS="compat/libusb-1.0/libusb/.libs/libusb-1.0.a"
+ if test "x$have_linux" = "xtrue"; then
+ LIBUSB_LIBS+=" -ludev"
+ fi
+ if test "x$have_darwin" = "xtrue"; then
+ LIBUSB_LIBS+=" -lobjc"
+ LDFLAGS+=" -framework CoreFoundation -framework IOKit"
+ fi
fi
else
LIBUSB_LIBS=""
fi
+AM_CONDITIONAL([WANT_STATIC_LIBUSB], [test x$dlibusb = xno])
+
AC_CONFIG_SUBDIRS([compat/jansson-2.5])
JANSSON_LIBS="compat/jansson-2.5/src/.libs/libjansson.a"
diff --git a/miner.h b/miner.h
index 6f2ff63..00eeb82 100644
--- a/miner.h
+++ b/miner.h
@@ -886,6 +886,13 @@ static inline void _mutex_init(pthread_mutex_t *lock, const char *file, const ch
INITLOCK(lock, CGLOCK_MUTEX, file, func, line);
}
+static inline void mutex_destroy(pthread_mutex_t *lock)
+{
+ /* Ignore return code. This only invalidates the mutex on linux but
+ * releases resources on windows. */
+ pthread_mutex_destroy(lock);
+}
+
static inline void _rwlock_init(pthread_rwlock_t *lock, const char *file, const char *func, const int line)
{
if (unlikely(pthread_rwlock_init(lock, NULL)))
@@ -893,12 +900,23 @@ static inline void _rwlock_init(pthread_rwlock_t *lock, const char *file, const
INITLOCK(lock, CGLOCK_RW, file, func, line);
}
+static inline void rwlock_destroy(pthread_rwlock_t *lock)
+{
+ pthread_rwlock_destroy(lock);
+}
+
static inline void _cglock_init(cglock_t *lock, const char *file, const char *func, const int line)
{
_mutex_init(&lock->mutex, file, func, line);
_rwlock_init(&lock->rwlock, file, func, line);
}
+static inline void cglock_destroy(cglock_t *lock)
+{
+ rwlock_destroy(&lock->rwlock);
+ mutex_destroy(&lock->mutex);
+}
+
/* Read lock variant of cglock. Cannot be promoted. */
static inline void _cg_rlock(cglock_t *lock, const char *file, const char *func, const int line)
{