yoshimi: unbreak musl and arm

This commit is contained in:
newbluemoon 2017-10-20 09:24:55 +02:00 committed by Enno Boland
parent f6be459fb9
commit 5711c545bf
4 changed files with 232 additions and 3 deletions

View File

@ -0,0 +1,33 @@
--- src/CMakeLists.txt.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/CMakeLists.txt 2017-10-20 09:13:13.740336950 +0200
@@ -118,6 +118,19 @@
message(FATAL_ERROR "pkg-config required but not found")
endif (PKG_CONFIG_FOUND)
+include (CheckFunctionExists)
+check_function_exists(random_r HAVE_RANDOM_R)
+
+# musl systems dont have random_r() and also need argp-standalone
+if (NOT HAVE_RANDOM_R)
+ find_library (ARGP_LIB argp REQUIRED)
+ if (ARGP_LIB)
+ message(STATUS "Found argp")
+ else()
+ message(FATAL_ERROR "argp required but not found")
+ endif()
+endif()
+
# libz
set (CMAKE_REQUIRED_LIBRARIES z)
check_c_source_compiles (
@@ -497,6 +510,10 @@
target_link_libraries (yoshimi ${ExternLibraries})
+if (NOT HAVE_RANDOM_R)
+ target_link_libraries (yoshimi ${ARGP_LIB})
+endif()
+
install (TARGETS yoshimi RUNTIME DESTINATION bin)
install (DIRECTORY ../banks DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/yoshimi

View File

@ -0,0 +1,10 @@
--- src/Misc/MiscFuncs.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/MiscFuncs.cpp 2017-10-19 21:24:37.372316448 +0200
@@ -29,6 +29,7 @@
#include <iostream>
#include <string.h>
#include <mutex>
+#include <limits.h>
using namespace std;

View File

@ -0,0 +1,181 @@
--- src/Synth/OscilGen.h.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Synth/OscilGen.h 2017-10-20 08:45:28.828335039 +0200
@@ -204,20 +204,38 @@
unsigned int randseed;
float random_0_1;
+ char random_state[256];
+ int ret;
+
+#if defined (HAVE_RANDOM_R)
int32_t random_result;
struct random_data random_buf;
- char random_state[256];
+#else
+ long int random_result;
+#endif
float harmonic_random_0_1;
+ char harmonic_random_state[256];
+
+#if defined (HAVE_RANDOM_R)
int32_t harmonic_random_result;
struct random_data harmonic_random_buf;
- char harmonic_random_state[256];
+#else
+ long int harmonic_random_result;
+#endif
};
inline float OscilGen::numRandom(void)
{
- if (!random_r(&random_buf, &random_result))
+#if defined (HAVE_RANDOM_R)
+ ret = random_r(&random_buf, &random_result);
+#else
+ random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
random_0_1 = (float)random_result / (float)INT_MAX;
if (isgreater(random_0_1, 1.0f))
@@ -248,7 +266,14 @@
inline float OscilGen::harmonicRandom(void)
{
- if (!random_r(&harmonic_random_buf, &harmonic_random_result))
+#if defined (HAVE_RANDOM_R)
+ ret = random_r(&harmonic_random_buf, &harmonic_random_result);
+#else
+ harmonic_random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
harmonic_random_0_1 = (float)harmonic_random_result / (float)INT_MAX;
harmonic_random_0_1 = (harmonic_random_0_1 > 1.0f) ? 1.0f : harmonic_random_0_1;
@@ -261,9 +286,14 @@
inline unsigned int OscilGen::random(void)
{
+#if defined (HAVE_RANDOM_R)
if (!random_r(&random_buf, &random_result))
return random_result + INT_MAX / 2;
return INT_MAX;
+#else
+ random_result = random();
+ return (unsigned int)random_result + INT_MAX / 2;
+#endif
}
#endif
--- src/Synth/OscilGen.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Synth/OscilGen.cpp 2017-10-20 08:15:44.680540189 +0200
@@ -950,10 +950,16 @@
//int i, j, k;
float a, b, c, d, hmagnew;
memset(random_state, 0, sizeof(random_state));
+#if defined (HAVE_RANDOM_R)
memset(&random_buf, 0, sizeof(random_buf));
if (initstate_r(synth->random(), random_state,
sizeof(random_state), &random_buf))
synth->getRuntime().Log("OscilGen failed to init general randomness");
+#else
+ if (!initstate(synth->random(), random_state, sizeof(random_state)))
+ synth->getRuntime().Log("OscilGen failed to init general randomness");
+#endif
+
if (oldbasepar != Pbasefuncpar
|| oldbasefunc != Pcurrentbasefunc
|| oldbasefuncmodulation != Pbasefuncmodulation
@@ -1292,10 +1298,16 @@
// unsigned int realrnd = random();
// srandom_r(randseed, &harmonic_random_buf);
memset(harmonic_random_state, 0, sizeof(harmonic_random_state));
+#if defined (HAVE_RANDOM_R)
memset(&harmonic_random_buf, 0, sizeof(harmonic_random_buf));
if (initstate_r(randseed, harmonic_random_state,
sizeof(harmonic_random_state), &harmonic_random_buf))
synth->getRuntime().Log("OscilGen failed to init harmonic amplitude amplitude randomness");
+#else
+ if (!initstate(randseed, harmonic_random_state, sizeof(harmonic_random_state)))
+ synth->getRuntime().Log("OscilGen failed to init harmonic amplitude amplitude randomness");
+#endif
+
float power = Pamprandpower / 127.0f;
float normalize = 1.0f / (1.2f - power);
switch (Pamprandtype)
--- src/Misc/SynthEngine.h.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/SynthEngine.h 2017-10-20 08:43:31.915561436 +0200
@@ -269,9 +269,16 @@
XMLwrapper *stateXMLtree;
char random_state[256];
+ float random_0_1;
+ int ret;
+
+#if defined (HAVE_RANDOM_R)
struct random_data random_buf;
int32_t random_result;
- float random_0_1;
+#else
+ long int random_result;
+#endif
+
public:
MasterUI *guiMaster; // need to read this in InterChange::returns
private:
@@ -285,7 +292,14 @@
inline float SynthEngine::numRandom(void)
{
- if (!random_r(&random_buf, &random_result))
+#if defined (HAVE_RANDOM_R)
+ ret = random_r(&random_buf, &random_result);
+#else
+ random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
random_0_1 = (float)random_result / (float)INT_MAX;
random_0_1 = (random_0_1 > 1.0f) ? 1.0f : random_0_1;
@@ -297,9 +311,14 @@
inline unsigned int SynthEngine::random(void)
{
+#if defined (HAVE_RANDOM_R)
if (!random_r(&random_buf, &random_result))
return random_result + INT_MAX / 2;
return INT_MAX / 2;
+#else
+ random_result = random();
+ return (unsigned int)random_result + INT_MAX / 2;
+#endif
}
#endif
--- src/Misc/SynthEngine.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/SynthEngine.cpp 2017-10-20 08:13:09.711523496 +0200
@@ -229,11 +229,16 @@
}
memset(random_state, 0, sizeof(random_state));
+#if defined (HAVE_RANDOM_R)
memset(&random_buf, 0, sizeof(random_buf));
if (initstate_r(samplerate + buffersize + oscilsize, random_state,
sizeof(random_state), &random_buf))
Runtime.Log("SynthEngine Init failed on general randomness");
+#else
+ if (!initstate(samplerate + buffersize + oscilsize, random_state, sizeof(random_state)))
+ Runtime.Log("SynthEngine Init failed on general randomness");
+#endif
if (oscilsize < (buffersize / 2))
{

View File

@ -1,7 +1,7 @@
# Template file for 'yoshimi'
pkgname=yoshimi
version=1.5.4.1
revision=1
revision=2
build_style=cmake
build_wrksrc=src
hostmakedepends="pkg-config fltk"
@ -15,12 +15,17 @@ distfiles="https://github.com/Yoshimi/$pkgname/archive/$version.tar.gz"
checksum=447ea507177d59b090f9ef54c3318cf33ba512df95863a888637b494def4c445
case "$XBPS_TARGET_MACHINE" in
*-musl) broken="https://build.voidlinux.eu/builders/armv6l-musl_builder/builds/10648/steps/shell_3/logs/stdio";;
arm*) broken="https://build.voidlinux.eu/builders/armv6l_builder/builds/25175/steps/shell_3/logs/stdio";;
*-musl) makedepends+=" argp-standalone";;
esac
configure_args="-DCMAKE_INSTALL_DATAROOTDIR=/usr/share"
pre_configure() {
sed -i 's|ncurses|ncursesw|g' CMakeLists.txt
case "$XBPS_TARGET_MACHINE" in
i686*) ;;
x86_64*) ;;
*) sed -i -e "s|-msse -msse2 -mfpmath=sse||g" CMakeLists.txt;;
esac
}