Build on Windows using mingw32.
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
diff --git a/.gitignore b/.gitignore
index 4e55d78..be4faad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
minerd
+minerd.exe
*.o
autom4te.cache
@@ -19,3 +20,5 @@ compile
config.log
config.status
+mingw32-config.cache
+
diff --git a/Makefile.am b/Makefile.am
index 299787e..a7b09fa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,13 +7,13 @@ endif
SUBDIRS = compat
-INCLUDES = -pthread -fno-strict-aliasing $(JANSSON_INCLUDES)
+INCLUDES = $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES)
bin_PROGRAMS = minerd
EXTRA_DIST = sha256_generic.c
minerd_SOURCES = util.c cpu-miner.c miner.h compat.h
-minerd_LDFLAGS = -pthread
+minerd_LDFLAGS = $(PTHREAD_FLAGS)
minerd_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@
diff --git a/compat.h b/compat.h
index a318991..1fdf6d1 100644
--- a/compat.h
+++ b/compat.h
@@ -10,6 +10,16 @@ static inline void sleep(int secs)
Sleep(secs * 1000);
}
+enum {
+ PRIO_PROCESS = 0,
+};
+
+static inline int setpriority(int which, int who, int prio)
+{
+ /* FIXME - actually do something */
+ return 0;
+}
+
#endif /* WIN32 */
#endif /* __COMPAT_H__ */
diff --git a/compat/jansson/.gitignore b/compat/jansson/.gitignore
new file mode 100644
index 0000000..173737b
--- /dev/null
+++ b/compat/jansson/.gitignore
@@ -0,0 +1,3 @@
+
+libjansson.a
+
diff --git a/configure.ac b/configure.ac
index b60fbfb..2543ae3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,18 @@ AC_PROG_RANLIB
dnl Checks for header files.
AC_HEADER_STDC
+case $host in
+ *-*-mingw*)
+ have_win32=true
+ PTHREAD_FLAGS=""
+ ;;
+ *)
+ have_win32=false
+ PTHREAD_FLAGS="-pthread"
+ ;;
+esac
+
+
AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIBS=-lpthread)
@@ -35,6 +47,7 @@ LIBCURL_CHECK_CONFIG(, 7.10.1, ,
[AC_MSG_ERROR([Missing required libcurl >= 7.10.1])])
AC_SUBST(JANSSON_LIBS)
+AC_SUBST(PTHREAD_FLAGS)
AC_SUBST(PTHREAD_LIBS)
AC_CONFIG_FILES([
diff --git a/cpu-miner.c b/cpu-miner.c
index f1eacf7..45e4e55 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -16,7 +16,9 @@
#include <stdbool.h>
#include <unistd.h>
#include <sys/time.h>
+#ifndef WIN32
#include <sys/resource.h>
+#endif
#include <pthread.h>
#include <getopt.h>
#include <jansson.h>
@@ -352,7 +354,7 @@ static void parse_cmdline(int argc, char *argv[])
static void calc_stats(void)
{
uint64_t hashes;
- long double hd, sd;
+ double hd, sd;
pthread_mutex_lock(&stats_mutex);
@@ -366,7 +368,8 @@ static void calc_stats(void)
hd = hashes;
sd = STAT_SLEEP_INTERVAL;
- fprintf(stderr, "wildly inaccurate HashMeter: %.2Lf khash/sec\n", hd / sd);
+ fprintf(stderr, "wildly inaccurate HashMeter: %.2f khash/sec\n",
+ hd / sd);
}
int main (int argc, char *argv[])