Re: [hatari-devel] Hatari Windows 2.4.1 release and PortMidi? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
On Dienstag, 23. August 2022 07:19:52 CEST Christian Zietz wrote:
> I remember I had huge difficulties building portmidi (the version from
> the SourceForge in Hatari's doc) from source.
Took a look at the source package from my distro (tumbleweed), which had some
patches to fix build problems. Also took a look at the fedora packages, which
has similar patches, and also a patch to disable java bindings. The attached
patch below is a combination of those, relative to the -217 release. With
that, you can just use
$ cmake -G "MSYS Makefiles" .
and run make. According to some comment in the *.spec files, using a decidated
build directory does not work (but i did not try that). What's not working is
to use -G "MingW Makefiles", that complains about sh.exe being in the PATH.
diff -rup portmidi-orig/CMakeLists.txt portmidi-new/CMakeLists.txt
--- portmidi-orig/CMakeLists.txt 2010-09-20 20:57:48.000000000 +0100
+++ portmidi-new/CMakeLists.txt 2022-08-23 14:12:25.327875000 +0100
@@ -72,6 +72,4 @@ add_subdirectory(pm_test)
add_subdirectory(pm_dylib)
-# Cannot figure out how to make an xcode Java application with CMake
-add_subdirectory(pm_java)
diff -rup portmidi-orig/pm_common/CMakeLists.txt portmidi-new/pm_common/CMakeLists.txt
--- portmidi-orig/pm_common/CMakeLists.txt 2010-09-20 20:57:48.000000000 +0100
+++ portmidi-new/pm_common/CMakeLists.txt 2022-08-23 14:12:25.327875000 +0100
@@ -67,15 +67,6 @@ if(UNIX)
message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
else(APPLE)
# LINUX settings...
- include(FindJNI)
- message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
- message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
- message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
- message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
- set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
- # libjvm.so is found relative to JAVA_INCLUDE_PATH:
- set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
-
set(LINUXSRC pmlinuxalsa pmlinux finddefault)
prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
list(APPEND LIBSRC ../porttime/ptlinux)
@@ -99,7 +90,6 @@ else(UNIX)
set(PM_NEEDED_LIBS winmm.lib)
endif(WIN32)
endif(UNIX)
-set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
# this completes the list of library sources by adding shared code
list(APPEND LIBSRC pmutil portmidi)
@@ -109,19 +99,11 @@ add_library(portmidi-static ${LIBSRC})
set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi_s")
target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
-# define the jni library
-include_directories(${JAVA_INCLUDE_PATHS})
-
-set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
-add_library(pmjni SHARED ${JNISRC})
-target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
-set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
-
# install the libraries (Linux and Mac OS X command line)
if(UNIX)
- INSTALL(TARGETS portmidi-static pmjni
- LIBRARY DESTINATION /usr/local/lib
- ARCHIVE DESTINATION /usr/local/lib)
+ INSTALL(TARGETS portmidi-static
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
# .h files installed by pm_dylib/CMakeLists.txt, so don't need them here
# INSTALL(FILES portmidi.h ../porttime/porttime.h
# DESTINATION /usr/local/include)
diff -rup portmidi-orig/pm_dylib/CMakeLists.txt portmidi-new/pm_dylib/CMakeLists.txt
--- portmidi-orig/pm_dylib/CMakeLists.txt 2009-11-20 06:41:09.000000000 +0100
+++ portmidi-new/pm_dylib/CMakeLists.txt 2022-08-23 14:13:21.937250000 +0100
@@ -59,28 +59,10 @@ if(UNIX)
set(JAVAVM_LIB "${FRAMEWORK_PATH}/JavaVM.framework")
set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
- set(INSTALL_NAME_DIR "/usr/local/lib")
+ set(INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
else(APPLE)
# LINUX settings...
- include(FindJNI)
- # message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
- # message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
- # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
- # note: user might need to set JAVA_INCLUDE_PATH manually
- #
- # this will probably break on BSD and other Unix systems; the fix
- # depends on whether FindJNI can find Java or not. If yes, then
- # we should try to rely on automatically set JAVA_INCLUDE_PATH and
- # JAVA_INCLUDE_PATH2; if no, then we need to make both JAVA_INCLUDE_PATH
- # and JAVA_INCLUDE_PATH2 set by user (will need clear documentation
- # because JAVA_INCLUDE_PATH2 is pretty obscure)
- set(JAVA_INCLUDE_PATH ${JAVA_INCLUDE_PATH-UNKNOWN}
- CACHE STRING "where to find Java SDK include directory")
- set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}/linux)
- # libjvm.so is found relative to JAVA_INCLUDE_PATH:
- set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../jre/lib/i386/client/libjvm.so)
-
set(LINUXSRC pmlinuxalsa pmlinux finddefault)
prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
list(APPEND LIBSRC ../porttime/ptlinux)
@@ -106,7 +88,6 @@ else(UNIX)
# message(STATUS "JAVAVM_LIB: " ${JAVAVM_LIB})
endif(WIN32)
endif(UNIX)
-set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVAVM_LIB})
# this completes the list of library sources by adding shared code
set(SHARED_FILES pmutil portmidi)
@@ -115,13 +96,14 @@ list(APPEND LIBSRC ${SHARED_PATHS})
add_library(portmidi-dynamic SHARED ${LIBSRC})
set_target_properties(portmidi-dynamic PROPERTIES OUTPUT_NAME "portmidi")
+set_target_properties(portmidi-dynamic PROPERTIES SOVERSION ${LIB_SOVERSION} VERSION ${LIB_VERSION})
target_link_libraries(portmidi-dynamic ${PM_NEEDED_LIBS})
# install the libraries (Linux and Mac OS X command line)
if(UNIX)
INSTALL(TARGETS portmidi-dynamic
- LIBRARY DESTINATION /usr/local/lib
- ARCHIVE DESTINATION /usr/local/lib)
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
INSTALL(FILES ../pm_common/portmidi.h ../porttime/porttime.h
- DESTINATION /usr/local/include)
+ DESTINATION ${INC_INSTALL_DIR})
endif(UNIX)
diff -rup portmidi-orig/pm_java/CMakeLists.txt portmidi-new/pm_java/CMakeLists.txt
--- portmidi-orig/pm_java/CMakeLists.txt 2009-11-04 16:20:44.000000000 +0100
+++ portmidi-new/pm_java/CMakeLists.txt 2022-08-23 14:10:39.093500000 +0100
@@ -16,12 +16,12 @@ if(UNIX)
COMMAND javac -classpath . pmdefaults/PmDefaultsFrame.java
MAIN_DEPENDENCY pmdefaults/PmDefaultsFrame.java
DEPENDS pmdefaults/PmDefaults.java
- WORKING_DIRECTORY pm_java)
+ WORKING_DIRECTORY .)
add_custom_command(OUTPUT pmdefaults/PmDefaults.class
COMMAND javac -classpath . pmdefaults/PmDefaults.java
MAIN_DEPENDENCY pmdefaults/PmDefaults.java
DEPENDS pmdefaults/PmDefaultsFrame.java
- WORKING_DIRECTORY pm_java)
+ WORKING_DIRECTORY .)
add_custom_command(OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
COMMAND cp pmdefaults/portmusic_logo.png .
COMMAND jar cmf pmdefaults/manifest.txt pmdefaults.jar
@@ -32,7 +32,7 @@ if(UNIX)
COMMAND rm portmusic_logo.png
MAIN_DEPENDENCY pmdefaults/PmDefaults.class
DEPENDS ${PMDEFAULTS_ALL_CLASSES}
- WORKING_DIRECTORY pm_java)
+ WORKING_DIRECTORY .)
add_custom_target(pmdefaults_target ALL
DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar)
# message(STATUS "add_custom_target: pmdefaults.jar")
@@ -41,7 +41,7 @@ if(UNIX)
INSTALL(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
DESTINATION /usr/share/java)
INSTALL(PROGRAMS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults
- DESTINATION /usr/local/bin)
+ DESTINATION ${BIN_INSTALL_DIR})
endif(APPLE)
endif(UNIX)
# In windows, use pm_java/make.bat
diff -rup portmidi-orig/pm_java/pmdefaults/pmdefaults portmidi-new/pm_java/pmdefaults/pmdefaults
--- portmidi-orig/pm_java/pmdefaults/pmdefaults 2009-01-20 05:04:49.000000000 +0100
+++ portmidi-new/pm_java/pmdefaults/pmdefaults 2022-08-23 14:10:25.202875000 +0100
@@ -1 +1,2 @@
-java -jar /usr/share/java/pmdefaults.jar > /dev/null
+#!/bin/bash
+exec java -jar "@@JAVADIR@@/pmdefaults.jar" "$@" >/dev/null
diff -rup portmidi-orig/pm_test/latency.c portmidi-new/pm_test/latency.c
--- portmidi-orig/pm_test/latency.c 2009-09-16 17:54:04.000000000 +0100
+++ portmidi-new/pm_test/latency.c 2022-08-23 14:31:29.624750000 +0100
@@ -280,7 +280,7 @@ int get_number(char *prompt)
{
char line[STRING_MAX];
int n = 0, i;
- printf(prompt);
+ printf("%s",prompt);
while (n != 1) {
n = scanf("%d", &i);
fgets(line, STRING_MAX, stdin);
diff -rup portmidi-orig/pm_test/midiclock.c portmidi-new/pm_test/midiclock.c
--- portmidi-orig/pm_test/midiclock.c 2009-10-04 20:50:44.000000000 +0100
+++ portmidi-new/pm_test/midiclock.c 2022-08-23 14:30:48.609125000 +0100
@@ -167,7 +167,7 @@ int get_number(char *prompt)
{
char line[STRING_MAX];
int n = 0, i;
- printf(prompt);
+ printf("%s",prompt);
while (n != 1) {
n = scanf("%d", &i);
fgets(line, STRING_MAX, stdin);
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
err = Pm_OpenOutput(&midi, outp, DRIVER_INFO, OUTPUT_BUFFER_SIZE,
TIME_PROC, TIME_INFO, LATENCY);
if (err) {
- printf(Pm_GetErrorText(err));
+ printf("%s",Pm_GetErrorText(err));
goto error_exit_no_device;
}
active = true;
diff -rup portmidi-orig/pm_test/mm.c portmidi-new/pm_test/mm.c
--- portmidi-orig/pm_test/mm.c 2010-10-05 19:49:09.000000000 +0100
+++ portmidi-new/pm_test/mm.c 2022-08-23 14:33:02.702875000 +0100
@@ -119,7 +119,7 @@ int get_number(char *prompt)
{
char line[STRING_MAX];
int n = 0, i;
- printf(prompt);
+ printf("%s",prompt);
while (n != 1) {
n = scanf("%d", &i);
fgets(line, STRING_MAX, stdin);
@@ -136,7 +136,7 @@ void receive_poll(PtTimestamp timestamp,
if (!active) return;
while ((count = Pm_Read(midi_in, &event, 1))) {
if (count == 1) output(event.message);
- else printf(Pm_GetErrorText(count));
+ else printf("%s",Pm_GetErrorText(count));
}
}
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
inp = get_number("Type input device number: ");
err = Pm_OpenInput(&midi_in, inp, NULL, 512, NULL, NULL);
if (err) {
- printf(Pm_GetErrorText(err));
+ printf("%s",Pm_GetErrorText(err));
Pt_Stop();
mmexit(1);
}
@@ -484,7 +484,7 @@ private int put_pitch(int p)
"gs", "a", "bf", "b" };
/* note octave correction below */
sprintf(result, "%s%d", ptos[p % 12], (p / 12) - 1);
- printf(result);
+ printf("%s", result);
return strlen(result);
}
diff -rup portmidi-orig/pm_test/sysex.c portmidi-new/pm_test/sysex.c
--- portmidi-orig/pm_test/sysex.c 2010-09-20 20:57:48.000000000 +0100
+++ portmidi-new/pm_test/sysex.c 2022-08-23 14:33:35.499750000 +0100
@@ -39,7 +39,7 @@ int get_number(char *prompt)
{
char line[STRING_MAX];
int n = 0, i;
- printf(prompt);
+ printf("%s",prompt);
while (n != 1) {
n = scanf("%d", &i);
fgets(line, STRING_MAX, stdin);
diff -rup portmidi-orig/pm_test/test.c portmidi-new/pm_test/test.c
--- portmidi-orig/pm_test/test.c 2009-09-16 17:54:04.000000000 +0100
+++ portmidi-new/pm_test/test.c 2022-08-23 14:30:48.609125000 +0100
@@ -37,7 +37,7 @@ int get_number(char *prompt)
{
char line[STRING_MAX];
int n = 0, i;
- printf(prompt);
+ printf("%s",prompt);
while (n != 1) {
n = scanf("%d", &i);
fgets(line, STRING_MAX, stdin);