diff --git a/Makefile b/Makefile index cbb27b2..c59283a 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,23 @@ SSE2 := yes TARGET ?= $(shell uname -s 2>/dev/null || echo unknown) override TARGET := $(shell echo $(TARGET) | tr A-Z a-z) -JAVA_HOME ?= $(realpath $(dir $(realpath $(shell which java)))../) +JAVA_HOME ?= $(realpath $(dir $(realpath $(shell which javac)))../) ifeq ($(TARGET), darwin) DYLIB := dylib LDFLAGS := -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -Wl,-single_module CFLAGS += -I $(JAVA_HOME)/Headers/ +else ifeq ($(TARGET), win32) + DYLIB := dll + LDFLAGS := -shared + CC := i586-mingw32msvc-cc + SSE2 := + CFLAGS += -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(TARGET) -DNO_HAVE_POSIX_MEMALIGN +else ifeq ($(TARGET), win64) + DYLIB := dll + LDFLAGS := -shared + CC := x86_64-w64-mingw32-gcc + CFLAGS += -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(TARGET) -DNO_HAVE_POSIX_MEMALIGN else DYLIB := so LDFLAGS := -shared diff --git a/README b/README index 873c303..565c338 100644 --- a/README +++ b/README @@ -82,3 +82,10 @@ Building Native Implementation A precompiled native library for Android 2.3 running on ARM is located in src/android/resources/lib/arm5/libscrypt.so. If placed in an .apk file's lib/armeabi directory it will be automatically loaded. + + To build the Windows shared library, you need MinGW. On Ubuntu, this is: + * mingw32 + * mingw32-binutils + * mingw32-runtime + * mingw-w64 + * mingw-w64-tools diff --git a/src/main/c/crypto_scrypt-nosse.c b/src/main/c/crypto_scrypt-nosse.c index 5f6690b..edf83d8 100644 --- a/src/main/c/crypto_scrypt-nosse.c +++ b/src/main/c/crypto_scrypt-nosse.c @@ -29,7 +29,10 @@ #include "scrypt_platform.h" #include + +#ifdef HAVE_POSIX_MEMALIGN #include +#endif #include #include diff --git a/src/main/c/crypto_scrypt-sse.c b/src/main/c/crypto_scrypt-sse.c index 3da4903..348002d 100644 --- a/src/main/c/crypto_scrypt-sse.c +++ b/src/main/c/crypto_scrypt-sse.c @@ -29,7 +29,9 @@ #include "scrypt_platform.h" #include +#ifdef HAVE_POSIX_MEMALIGN #include +#endif #include #include diff --git a/src/main/include/config.h b/src/main/include/config.h index 1f0dc1e..ba7d8d5 100644 --- a/src/main/include/config.h +++ b/src/main/include/config.h @@ -2,8 +2,10 @@ #define HAVE_MMAP 1 #ifndef __ANDROID__ +#ifndef NO_HAVE_POSIX_MEMALIGN #define HAVE_POSIX_MEMALIGN 1 #endif +#endif #ifdef __ANDROID__ #include diff --git a/src/main/java/com/lambdaworks/jni/JarLibraryLoader.java b/src/main/java/com/lambdaworks/jni/JarLibraryLoader.java index fd9d3ab..892b656 100644 --- a/src/main/java/com/lambdaworks/jni/JarLibraryLoader.java +++ b/src/main/java/com/lambdaworks/jni/JarLibraryLoader.java @@ -134,6 +134,9 @@ private List libCandidates(Platform platform, String name) { candidates.add(sb + ".dylib"); candidates.add(sb + ".jnilib"); break; + case windows: + candidates.add(sb + ".dll"); + break; case linux: case freebsd: candidates.add(sb + ".so"); diff --git a/src/main/java/com/lambdaworks/jni/Platform.java b/src/main/java/com/lambdaworks/jni/Platform.java index 953d593..e9df619 100644 --- a/src/main/java/com/lambdaworks/jni/Platform.java +++ b/src/main/java/com/lambdaworks/jni/Platform.java @@ -27,6 +27,7 @@ public enum Arch { } public enum OS { + windows ("windows .*"), darwin ("darwin|mac os x"), freebsd("freebsd"), linux ("linux"); diff --git a/src/main/resources/lib/x86/windows/libscrypt.dll b/src/main/resources/lib/x86/windows/libscrypt.dll new file mode 100755 index 0000000..cf1ac6b Binary files /dev/null and b/src/main/resources/lib/x86/windows/libscrypt.dll differ diff --git a/src/main/resources/lib/x86_64/windows/libscrypt.dll b/src/main/resources/lib/x86_64/windows/libscrypt.dll new file mode 100755 index 0000000..a4dc08f Binary files /dev/null and b/src/main/resources/lib/x86_64/windows/libscrypt.dll differ