diff --git a/src/main/c/Windows/Makefile.native b/src/main/c/Windows/Makefile.native new file mode 100644 index 0000000..f104fa5 --- /dev/null +++ b/src/main/c/Windows/Makefile.native @@ -0,0 +1,112 @@ +## Windows specific library variables +COMPILE = cl +LINK = link +CFLAGS = /c /O2 /GF /GL /MT /EHsc /fp:precise /J /nologo /TC +LDFLAGS = /DLL /LTCG /NOASSEMBLY /NOLOGO +INCLUDES = /I"$(JDK_HOME)\include" /I"$(JDK_HOME)\include\win32" +LIBRARIES = Advapi32.lib SetupAPI.lib +DELETE = @del /q /f +RMDIR = @rd /q /s +MKDIR = @md +COPY = @copy /y +MOVE = @move /y +PRINT = @echo +FULL_CLASS = com.fazecast.jSerialComm.SerialPort +JAVAC = "$(JDK_HOME)\bin\javac" +JFLAGS = -source 1.6 -target 1.6 -Xlint:-options +LIBRARY_NAME = jSerialComm.dll +SOURCES = SerialPort_Windows.c WindowsHelperFunctions.c +JAVA_SOURCE_DIR = ..\..\..\..\src\main\java\com\fazecast\jSerialComm +RESOURCE_DIR = ..\..\..\..\src\main\resources\Windows +BUILD_DIR = ..\..\..\..\bin\Windows +JAVA_CLASS_DIR = $(BUILD_DIR)\..\com\fazecast\jSerialComm +OBJECTSx86 = $(BUILD_DIR)\x86\SerialPort_Windows.obj $(BUILD_DIR)\x86\WindowsHelperFunctions.obj +OBJECTSx86_64 = $(BUILD_DIR)\x86_64\SerialPort_Windows.obj $(BUILD_DIR)\x86_64\WindowsHelperFunctions.obj +OBJECTSarmv7 = $(BUILD_DIR)\armv7\SerialPort_Windows.obj $(BUILD_DIR)\armv7\WindowsHelperFunctions.obj +OBJECTSaarch64 = $(BUILD_DIR)\aarch64\SerialPort_Windows.obj $(BUILD_DIR)\aarch64\WindowsHelperFunctions.obj +JNI_HEADER = ..\com_fazecast_jSerialComm_SerialPort.h +JAVA_CLASS = $(JAVA_CLASS_DIR)\SerialPort.class + +# Define phony and suffix rules +.PHONY: all win32 win64 winarm winarm64 checkdirs clean +.SUFFIXES: +.SUFFIXES: .c .obj .class .java .h + +# Default build target not possible due to different architecture compilers +all : + $(PRINT). + $(PRINT) Must specify a target (either win32, win64, winarm, or winarm64), but not at the same time since different versions of the Microsoft Compiler are required for difference architectures. + $(PRINT). + $(PRINT) NOTE: Before attempting to use this Makefile, make sure that you have called 'vcvarsall.bat' for your intended architecture. This file can normally be found in "C:\Program Files (x86)\Microsoft Visual Studio [version]\VC\". + $(PRINT). + $(PRINT) Example: To build 64-bit Windows libraries, you would call: + $(PRINT) C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat x64 + $(PRINT) nmake win64 + $(PRINT). + +# Builds 32-bit Windows libraries +win32 : $(BUILD_DIR)\x86 $(BUILD_DIR)\x86\$(LIBRARY_NAME) + $(COPY) $(BUILD_DIR)\x86\*.dll $(RESOURCE_DIR)\x86 + $(DELETE) ..\*.h + $(RMDIR) $(BUILD_DIR)\.. + +# Builds 64-bit Windows libraries +win64 : $(BUILD_DIR)\x86_64 $(BUILD_DIR)\x86_64\$(LIBRARY_NAME) + $(COPY) $(BUILD_DIR)\x86_64\*.dll $(RESOURCE_DIR)\x86_64 + $(DELETE) ..\*.h + $(RMDIR) $(BUILD_DIR)\.. + +# Builds armv7 Windows libraries +winarm : $(BUILD_DIR)\armv7 $(BUILD_DIR)\armv7\$(LIBRARY_NAME) + $(COPY) $(BUILD_DIR)\armv7\*.dll $(RESOURCE_DIR)\armv7 + $(DELETE) ..\*.h + $(RMDIR) $(BUILD_DIR)\.. + +# Builds arm64 Windows libraries +winarm64 : $(BUILD_DIR)\aarch64 $(BUILD_DIR)\aarch64\$(LIBRARY_NAME) + $(COPY) $(BUILD_DIR)\aarch64\*.dll $(RESOURCE_DIR)\aarch64 + $(DELETE) ..\*.h + $(RMDIR) $(BUILD_DIR)\.. + +# Rule to create build directories +$(BUILD_DIR)\x86 : + $(MKDIR) "$@" +$(BUILD_DIR)\x86_64 : + $(MKDIR) "$@" +$(BUILD_DIR)\armv7 : + $(MKDIR) "$@" +$(BUILD_DIR)\aarch64 : + $(MKDIR) "$@" + +# Rule to build 32-bit library +$(BUILD_DIR)\x86\$(LIBRARY_NAME) : $(JNI_HEADER) $(OBJECTSx86) + $(LINK) $(LDFLAGS) /MACHINE:X86 /OUT:$@ $(OBJECTSx86) $(LIBRARIES) + +# Rule to build 64-bit library +$(BUILD_DIR)\x86_64\$(LIBRARY_NAME) : $(JNI_HEADER) $(OBJECTSx86_64) + $(LINK) $(LDFLAGS) /MACHINE:X64 /OUT:$@ $(OBJECTSx86_64) $(LIBRARIES) + +# Rule to build armv7 library +$(BUILD_DIR)\armv7\$(LIBRARY_NAME) : $(JNI_HEADER) $(OBJECTSarmv7) + $(LINK) $(LDFLAGS) /MACHINE:ARM /OUT:$@ $(OBJECTSarmv7) $(LIBRARIES) + +# Rule to build arm64 library +$(BUILD_DIR)\aarch64\$(LIBRARY_NAME) : $(JNI_HEADER) $(OBJECTSaarch64) + $(LINK) $(LDFLAGS) /MACHINE:ARM64 /OUT:$@ $(OBJECTSaarch64) $(LIBRARIES) + +# Suffix rules to get from *.c -> *.obj +$(OBJECTSx86) : + $(COMPILE) $(CFLAGS) $(INCLUDES) $(*B).c -Fo$@ +$(OBJECTSx86_64) : + $(COMPILE) $(CFLAGS) $(INCLUDES) $(*B).c -Fo$@ +$(OBJECTSarmv7) : + $(COMPILE) $(CFLAGS) $(INCLUDES) $(*B).c -Fo$@ +$(OBJECTSaarch64) : + $(COMPILE) $(CFLAGS) $(INCLUDES) $(*B).c -Fo$@ + +# Rule to build JNI header file +$(JNI_HEADER) : $(JAVA_CLASS) + +# Suffix rule to get from *.java -> *.class +$(JAVA_CLASS) : + $(JAVAC) $(JFLAGS) -d $(JAVA_CLASS_DIR)\..\..\.. -cp $(JAVA_SOURCE_DIR)\..\..\.. $(JAVA_SOURCE_DIR)\$(*B).java -h .. diff --git a/src/main/resources/Windows/aarch64/jSerialComm.dll b/src/main/resources/Windows/aarch64/jSerialComm.dll index 3731083..8307839 100644 Binary files a/src/main/resources/Windows/aarch64/jSerialComm.dll and b/src/main/resources/Windows/aarch64/jSerialComm.dll differ diff --git a/src/main/resources/Windows/armv7/jSerialComm.dll b/src/main/resources/Windows/armv7/jSerialComm.dll index 9835708..a183b72 100644 Binary files a/src/main/resources/Windows/armv7/jSerialComm.dll and b/src/main/resources/Windows/armv7/jSerialComm.dll differ diff --git a/src/main/resources/Windows/x86/jSerialComm.dll b/src/main/resources/Windows/x86/jSerialComm.dll index 101c71b..4fd98f1 100644 Binary files a/src/main/resources/Windows/x86/jSerialComm.dll and b/src/main/resources/Windows/x86/jSerialComm.dll differ diff --git a/src/main/resources/Windows/x86_64/jSerialComm.dll b/src/main/resources/Windows/x86_64/jSerialComm.dll index 10433f6..10f57cf 100644 Binary files a/src/main/resources/Windows/x86_64/jSerialComm.dll and b/src/main/resources/Windows/x86_64/jSerialComm.dll differ