Makefile, CMake and other build fixes for OpentMPT

This commit is contained in:
alufolie91 committed 2023-08-09 17:34:13 +02:00
1 parent 7ad28e484e
commit 84445e4673
8 files changed
+115 -49

No files matched your search

+10 -3
View File
@@ -25,6 +25,13 @@ jobs:
- run:
name: Add i386 arch
command: dpkg --add-architecture i386
- run:
name: Add STJr PPA
command: |
apt-get -qq update
apt-get -qq -y install dirmngr
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6
echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" >> /etc/apt/sources.list
- run:
name: Update APT listing
command: apt-get -qq update
@@ -36,7 +43,7 @@ jobs:
- v1-SRB2-APT
- run:
name: Install SDK
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
- save_cache:
key: v1-SRB2-APT
paths:
@@ -50,13 +57,13 @@ jobs:
# command: make -C src LINUX=1 cleandep
- run:
name: rebuild depend
command: make -C src LINUX=1 NOOPENMPT=1 clean
command: make -C src LINUX=1 clean
- restore_cache:
keys:
- v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }}
- run:
name: Compile
command: make -C src LINUX=1 ERRORMODE=1 NOOPENMPT=1 -k
command: make -C src LINUX=1 ERRORMODE=1 -k
- store_artifacts:
path: /root/SRB2/bin/Linux/Release/
destination: bin
+23
View File
@@ -0,0 +1,23 @@
include(LibFindMacros)
libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
find_path(OPENMPT_INCLUDE_DIR
NAMES libopenmpt.h
PATHS
${OPENMPT_PKGCONF_INCLUDE_DIRS}
"/usr/include/libopenmpt"
"/usr/local/include/libopenmpt"
)
find_library(OPENMPT_LIBRARY
NAMES openmpt
PATHS
${OPENMPT_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
libfind_process(OPENMPT)
+3
View File
@@ -7,6 +7,7 @@ Here are the required DLLs, per build. For each architecture, copy all the binar
* libs\dll-binaries\[i686/x86_64]
* libs\SDL2\[i686/x86_64]...\bin
* libs\SDL2_mixer\[i686/x86_64]...\bin
* libs\libopenmpt\[x86/x86_64]...\bin\mingw
and don't forget to build r_opengl.dll for srb2dd.
@@ -18,6 +19,7 @@ and don't forget to build r_opengl.dll for srb2dd.
* libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll)
* libs\SDL2\i686-w64-mingw32\bin\SDL2.dll
* libs\SDL2_mixer\i686-w64-mingw32\bin\*.dll (get everything)
* libs\libopenmpt\x86\bin\mingw\libopenmpt.dll
## srb2kart, 64-bit
@@ -27,3 +29,4 @@ and don't forget to build r_opengl.dll for srb2dd.
* libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll)
* libs\SDL2\x86_64-w64-mingw32\bin\SDL2.dll
* libs\SDL2_mixer\x86_64-w64-mingw32\bin\*.dll (get everything)
* libs\libopenmpt\x86_64\bin\mingw\libopenmpt.dll
+23 -1
View File
@@ -231,6 +231,8 @@ set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
"Enable zlib support.")
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT support.")
set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL
"Enable Discord rich presence support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
@@ -247,7 +249,7 @@ set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME).")
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).")
endif()
if(${SRB2_CONFIG_HAVE_BLUA})
@@ -389,6 +391,26 @@ if(${SRB2_CONFIG_HAVE_DISCORDRPC})
endif()
endif()
if(${SRB2_CONFIG_HAVE_OPENMPT})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(OPENMPT_FOUND ON)
set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt")
else() # 32-bit
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt")
endif()
else()
find_package(OPENMPT)
endif()
if(${OPENMPT_FOUND})
set(SRB2_HAVE_OPENMPT ON)
add_definitions(-DHAVE_OPENMPT)
else()
message(WARNING "You have specified that OpenMPT is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON)
+5 -6
View File
@@ -236,6 +236,10 @@ ifdef DJGPPDOS
include djgppdos/Makefile.cfg
endif
ifndef NOOPENMPT
HAVE_OPENMPT=1
endif
ifdef MINGW
include win32/Makefile.cfg
endif #ifdef MINGW
@@ -251,10 +255,6 @@ HAVE_LIBGME=1
endif
endif
ifndef NOOPENMPT
HAVE_OPENMPT=1
endif
ifdef SOLARIS
UNIXCOMMON=1
endif
@@ -406,8 +406,7 @@ CFLAGS+=$(LIBGME_CFLAGS)
endif
ifdef HAVE_OPENMPT
# make libopenmpt optional
OPTS+=-DHAVE_OPENMPT -DOPENMPT_DYNAMIC
OPTS+=-DHAVE_OPENMPT
LIBOPENMPT_PKGCONFIG?=libopenmpt
LIBOPENMPT_CFLAGS?=$(shell $(PKG_CONFIG) $(LIBOPENMPT_PKGCONFIG) --cflags)
+8
View File
@@ -257,6 +257,7 @@ if(${SDL2_FOUND})
${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${GME_INCLUDE_DIRS}
${OPENMPT_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
@@ -307,12 +308,14 @@ if(${SDL2_FOUND})
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
)
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
)
endif()
else()
@@ -321,12 +324,14 @@ if(${SDL2_FOUND})
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
)
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
)
endif()
endif()
@@ -347,6 +352,9 @@ if(${SDL2_FOUND})
if(${SRB2_CONFIG_HAVE_GME})
getwinlib(libgme "libgme.dll")
endif()
if(${SRB2_CONFIG_HAVE_OPENMPT})
getwinlib(libopenmpt "libopenmpt.dll")
endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
getwinlib(discord-rpc "discord-rpc.dll")
+31 -34
View File
@@ -343,7 +343,8 @@ void I_StartupSound(void)
}
#ifdef HAVE_OPENMPT
load_openmpt();
CONS_Printf("libopenmpt version: %s\n", openmpt_get_string("library_version"));
CONS_Printf("libopenmpt build date: %s\n", openmpt_get_string("build"));
#endif
sound_started = true;
@@ -370,8 +371,7 @@ void I_ShutdownSound(void)
#endif
#ifdef HAVE_OPENMPT
if (mod)
openmpt.module_destroy(mod);
unload_openmpt();
openmpt_module_destroy(mod);
#endif
}
@@ -840,9 +840,9 @@ static void mix_openmpt(void *udata, Uint8 *stream, int len)
(void)udata;
openmpt.module_set_render_param(mod, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
openmpt.module_set_repeat_count(mod, -1); // Always repeat
openmpt.module_read_interleaved_stereo(mod, SAMPLERATE, BUFFERSIZE, (short *)stream);
openmpt_module_set_render_param(mod, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
openmpt_module_set_repeat_count(mod, -1); // Always repeat
openmpt_module_read_interleaved_stereo(mod, SAMPLERATE, BUFFERSIZE, (short *)stream);
// apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
@@ -933,7 +933,7 @@ boolean I_SetSongSpeed(float speed)
{
char modspd[16];
sprintf(modspd, "%g", speed);
openmpt.module_ctl_set(mod, "play.tempo_factor", modspd);
openmpt_module_ctl_set(mod, "play.tempo_factor", modspd);
return true;
}
#else
@@ -982,7 +982,7 @@ UINT32 I_GetSongLength(void)
#endif
#ifdef HAVE_OPENMPT
if (mod)
return (UINT32)(openmpt.module_get_duration_seconds(mod) * 1000.);
return (UINT32)(openmpt_module_get_duration_seconds(mod) * 1000.);
else
#endif
if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID)
@@ -1075,7 +1075,7 @@ boolean I_SetSongPosition(UINT32 position)
{
// This isn't 100% correct because we don't account for loop points because we can't get them.
// But if you seek past end of song, OpenMPT seeks to 0. So adjust the position anyway.
openmpt.module_set_position_seconds(mod, (double)(get_adjusted_position(position)/1000.0L)); // returns new position
openmpt_module_set_position_seconds(mod, (double)(get_adjusted_position(position)/1000.0L)); // returns new position
return true;
}
else
@@ -1143,8 +1143,8 @@ UINT32 I_GetSongPosition(void)
if (mod)
// This will be incorrect if we adjust for length because we can't get loop points.
// So return unadjusted. See note in SetMusicPosition: we adjust for that.
return (UINT32)(openmpt.module_get_position_seconds(mod)*1000.);
//return get_adjusted_position((UINT32)(openmpt.module_get_position_seconds(mod)*1000.));
return (UINT32)(openmpt_module_get_position_seconds(mod)*1000.);
//return get_adjusted_position((UINT32)(openmpt_module_get_position_seconds(mod)*1000.));
else
#endif
if (!music || I_SongType() == MU_MID)
@@ -1266,27 +1266,23 @@ boolean I_LoadSong(char *data, size_t len)
{
case MUS_MODPLUG:
case MUS_MOD:
if (openmpt.loaded)
mod = openmpt_module_create_from_memory2(data, len, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (!mod)
{
mod = openmpt.module_create_from_memory2(data, len, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (!mod)
{
mod_err = openmpt.module_error_get_last(mod);
mod_err_str = openmpt.error_string(mod_err);
CONS_Alert(CONS_ERROR, "openmpt_module_create_from_memory2: %s\n", mod_err_str);
Mix_FreeMusic(music);
music = NULL;
return false;
}
else
{
Mix_FreeMusic(music);
music = NULL;
return true;
}
break;
mod_err = openmpt_module_error_get_last(mod);
mod_err_str = openmpt_error_string(mod_err);
CONS_Alert(CONS_ERROR, "openmpt_module_create_from_memory2: %s\n", mod_err_str);
Mix_FreeMusic(music);
music = NULL;
return false;
}
// else, fall through
else
{
Mix_FreeMusic(music);
music = NULL;
return true;
}
break;
case MUS_WAV:
case MUS_MID:
case MUS_OGG:
@@ -1298,6 +1294,7 @@ boolean I_LoadSong(char *data, size_t len)
}
#endif
// Find the OGG loop point.
loop_point = 0.0f;
song_length = 0.0f;
@@ -1346,7 +1343,7 @@ void I_UnloadSong(void)
#ifdef HAVE_OPENMPT
if (mod)
{
openmpt.module_destroy(mod);
openmpt_module_destroy(mod);
mod = NULL;
}
#endif
@@ -1377,7 +1374,7 @@ boolean I_PlaySong(boolean looping)
#ifdef HAVE_OPENMPT
if (mod)
{
openmpt.module_select_subsong(mod, 0);
openmpt_module_select_subsong(mod, 0);
current_subsong = 0;
Mix_HookMusic(mix_openmpt, mod);
return true;
@@ -1522,9 +1519,9 @@ boolean I_SetSongTrack(int track)
if (current_subsong == track)
return false;
SDL_LockAudio();
if (track >= 0 && track < openmpt.module_get_num_subsongs(mod))
if (track >= 0 && track < openmpt_module_get_num_subsongs(mod))
{
openmpt.module_select_subsong(mod, track);
openmpt_module_select_subsong(mod, track);
current_subsong = track;
SDL_UnlockAudio();
return true;
+12 -5
View File
@@ -10,18 +10,25 @@ ifdef MINGW64
HAVE_LIBGME=1
LIBGME_CFLAGS=-I../libs/gme/include
LIBGME_LDFLAGS=-L../libs/gme/win64 -lgme
ifdef HAVE_OPENMPT
LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc
LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64/mingw -lopenmpt
endif
SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main
SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDL2_mixer/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
HAVE_OPENMPT=1
LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc
LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64 -llibopenmpt
else
HAVE_LIBGME=1
LIBGME_CFLAGS=-I../libs/gme/include
LIBGME_LDFLAGS=-L../libs/gme/win32 -lgme
HAVE_OPENMPT=1
ifdef HAVE_OPENMPT
LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc
LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86 -llibopenmpt
LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86/mingw -lopenmpt
endif
SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main
SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
endif