From 0c5c580e530c763ec4b67ee94a33272cc6913ec0 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 16 Nov 2021 15:46:57 +1000
Subject: Fix build for haiku


diff --git a/3rdparty/openmpt/include/genie/build/gmake.linux/genie.make b/3rdparty/openmpt/include/genie/build/gmake.linux/genie.make
index 88c81a4..92ac36c 100644
--- a/3rdparty/openmpt/include/genie/build/gmake.linux/genie.make
+++ b/3rdparty/openmpt/include/genie/build/gmake.linux/genie.make
@@ -62,7 +62,7 @@ ifeq ($(config),release)
   LIBDEPS            +=
   LDDEPS             +=
   LDRESP              =
-  LIBS               += $(LDDEPS) -ldl -lm
+  LIBS               += $(LDDEPS) -lm
   EXTERNAL_LIBS      +=
   LINKOBJS            = $(OBJECTS)
   LINKCMD             = $(CC) -o $(TARGET) $(LINKOBJS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
@@ -149,7 +149,7 @@ ifeq ($(config),debug)
   LIBDEPS            +=
   LDDEPS             +=
   LDRESP              =
-  LIBS               += $(LDDEPS) -ldl -lm
+  LIBS               += $(LDDEPS) -lm
   EXTERNAL_LIBS      +=
   LINKOBJS            = $(OBJECTS)
   LINKCMD             = $(CC) -o $(TARGET) $(LINKOBJS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
diff --git a/3rdparty/openmpt/include/premake/Bootstrap.mak b/3rdparty/openmpt/include/premake/Bootstrap.mak
index 1ee29ba..f4450f5 100644
--- a/3rdparty/openmpt/include/premake/Bootstrap.mak
+++ b/3rdparty/openmpt/include/premake/Bootstrap.mak
@@ -78,7 +78,7 @@ linux: $(SRC)
 	$(SILENT) rm -rf ./build
 	$(SILENT) rm -rf ./obj
 	mkdir -p build/bootstrap
-	$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lm -ldl -lrt
+	$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lm
 	./build/bootstrap/premake_bootstrap embed
 	./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
 	$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
diff --git a/3rdparty/unrar/os.hpp b/3rdparty/unrar/os.hpp
index 21488a8..f3455e5 100644
--- a/3rdparty/unrar/os.hpp
+++ b/3rdparty/unrar/os.hpp
@@ -212,6 +212,12 @@
   #endif
 #endif
 
+#if defined(__HAIKU__)
+  #ifndef BIG_ENDIAN
+     #define BIG_ENDIAN
+  #endif
+#endif
+
 #endif
 
   typedef const char* MSGID;
diff --git a/apps/zxtune-qt/ui/preferences/Makefile b/apps/zxtune-qt/ui/preferences/Makefile
index 0deee8b..cd7cff0 100644
--- a/apps/zxtune-qt/ui/preferences/Makefile
+++ b/apps/zxtune-qt/ui/preferences/Makefile
@@ -5,7 +5,7 @@ source_dirs := .
 
 ui_files = aym mixer mixing plugins sound saa sid z80 interface preferencesdialog
 
-ui_files += sound_alsa sound_dsound sound_oss sound_sdl sound_win32
+#ui_files += sound_alsa sound_dsound sound_oss sound_sdl sound_win32
 
 ts_files := ui_preferences
 
diff --git a/apps/zxtune-qt/ui/preferences/sound.cpp b/apps/zxtune-qt/ui/preferences/sound.cpp
index bb78c89..19fb369 100644
--- a/apps/zxtune-qt/ui/preferences/sound.cpp
+++ b/apps/zxtune-qt/ui/preferences/sound.cpp
@@ -11,11 +11,13 @@
 // local includes
 #include "sound.h"
 #include "sound.ui.h"
+#ifndef __HAIKU__
 #include "sound_alsa.h"
 #include "sound_dsound.h"
 #include "sound_oss.h"
 #include "sound_sdl.h"
 #include "sound_win32.h"
+#endif
 #include "supp/options.h"
 #include "ui/tools/parameters_helpers.h"
 #include "ui/utils.h"
@@ -135,13 +137,15 @@ namespace
       {
         backendsList->addItem(ToQString(id));
       }
+#ifndef __HAIKU__
       AddPage(&UI::AlsaSettingsWidget::Create);
       AddPage(&UI::DirectSoundSettingsWidget::Create);
       AddPage(&UI::OssSettingsWidget::Create);
       AddPage(&UI::SdlSettingsWidget::Create);
       AddPage(&UI::Win32SettingsWidget::Create);
+#endif
     }
-
+#ifndef __HAIKU__
     void AddPage(UI::BackendSettingsWidget* (*factory)(QWidget&))
     {
       std::unique_ptr<UI::BackendSettingsWidget> wid(factory(*backendGroupBox));
@@ -153,7 +157,7 @@ namespace
         SetupPages[id] = wid.release();
       }
     }
-
+#endif
     void SetFrequency(uint_t val)
     {
       const uint_t* const frq = std::find(FREQUENCES, std::end(FREQUENCES), val);
diff --git a/make/compilers/gcc.mak b/make/compilers/gcc.mak
index 484b894..64ff77f 100644
--- a/make/compilers/gcc.mak
+++ b/make/compilers/gcc.mak
@@ -62,7 +62,7 @@ LDFLAGS = $(LD_MODE_FLAGS) $($(platform).ld.flags) $($(platform).$(arch).ld.flag
 
 #specify endpoint commands
 build_obj_cmd_nodeps = $(tools.cxx) $(CXXFLAGS) -c $1 -o $2
-build_obj_cmd = $(build_obj_cmd_nodeps) -MMD
+build_obj_cmd = $(build_obj_cmd_nodeps) -MMD -std=c++17
 build_obj_cmd_cc = $(tools.cc) $(CCFLAGS) -std=c99 -c $1 -o $2 -MMD
 build_lib_cmd = $(tools.ar) $(ARFLAGS) $2 $1
 link_cmd = $(tools.ld) $(LDFLAGS) -o $@ $(OBJECTS) $(RESOURCES) \
@@ -118,4 +118,4 @@ symbolstree: $(target).syms.json
 websymbolstree: $(target).syms.json
 	(cd $(bloat_dir) && $(tools.python) $(tools_dir)/server.py /bloat.json=$(abspath $^))
 endif
-endif
\ No newline at end of file
+endif
diff --git a/make/features.mak b/make/features.mak
index 7b7c7ee..73f5e2d 100644
--- a/make/features.mak
+++ b/make/features.mak
@@ -8,10 +8,11 @@ support_ogg = 1
 support_flac = 1
 support_curl = 1
 else ifneq ($(findstring $(platform),linux),)
-support_oss = 1
-support_alsa = 1
+#support_oss = 1
+#support_alsa = 1
 #support_sdl = 1
-support_pulseaudio = 1
+#support_pulseaudio = 1
+support_openal = 1
 support_mp3 = 1
 support_ogg = 1
 support_flac = 1
diff --git a/make/platforms/linux.mak b/make/platforms/linux.mak
index fb21959..13dca1b 100644
--- a/make/platforms/linux.mak
+++ b/make/platforms/linux.mak
@@ -6,7 +6,7 @@ makeobj_name = $(1).o
 host=linux
 compiler?=gcc
 
-libraries.linux += dl rt pthread stdc++
+libraries.linux += stdc++
 
 ifneq ($($(platform).$(arch).crossroot),)
 libraries.dirs.linux += $($(platform).$(arch).crossroot)/usr/lib
diff --git a/src/sound/backends/Makefile b/src/sound/backends/Makefile
index f11401d..f9b4b85 100644
--- a/src/sound/backends/Makefile
+++ b/src/sound/backends/Makefile
@@ -28,11 +28,11 @@ source_files += $(1)_stub.cpp
 endif
 endef
 
-$(eval $(call declare_native_backend,waveout,win32))
-$(eval $(call declare_native_backend,directsound,dsound))
-$(eval $(call declare_native_backend,alsa,alsa))
-$(eval $(call declare_native_backend,sdl,sdl))
-$(eval $(call declare_native_backend,pulseaudio,paudio))
+#$(eval $(call declare_native_backend,waveout,win32))
+#$(eval $(call declare_native_backend,directsound,dsound))
+#$(eval $(call declare_native_backend,alsa,alsa))
+#$(eval $(call declare_native_backend,sdl,sdl))
+#$(eval $(call declare_native_backend,pulseaudio,paudio))
 $(eval $(call declare_native_backend,openal,openal))
 
 ifdef support_aylpt
@@ -41,11 +41,11 @@ else
 source_files += aylpt_stub.cpp
 endif
 
-ifdef support_oss
-source_files += oss_backend.cpp
-else
+#ifdef support_oss
+#source_files += oss_backend.cpp
+#else
 source_files += oss_stub.cpp
-endif
+#endif
 
 $(eval $(call declare_thirdparty_backend,flac))
 $(eval $(call declare_thirdparty_backend,mp3))
diff --git a/src/sound/backends/backends_list.h b/src/sound/backends/backends_list.h
index 867e91d..84a19cc 100644
--- a/src/sound/backends/backends_list.h
+++ b/src/sound/backends/backends_list.h
@@ -31,12 +31,14 @@ namespace Sound
 
   inline void RegisterSystemBackends(BackendsStorage& storage)
   {
+#ifndef __HAIKU__
     RegisterOssBackend(storage);
     RegisterAlsaBackend(storage);
     RegisterPulseAudioBackend(storage);
     RegisterDirectSoundBackend(storage);
     RegisterWin32Backend(storage);
     RegisterSdlBackend(storage);
+#endif
     RegisterOpenAlBackend(storage);
     RegisterAyLptBackend(storage);
   }
diff --git a/src/sound/backends/gates/openal_api.h b/src/sound/backends/gates/openal_api.h
index 03d9fe3..03b7639 100644
--- a/src/sound/backends/gates/openal_api.h
+++ b/src/sound/backends/gates/openal_api.h
@@ -13,8 +13,13 @@
 //std includes
 #include <memory>
 //platform-dependent includes
+#ifdef __HAIKU__
+#include <AL/al.h>
+#include <AL/alc.h>
+#else
 #include <OpenAL/al.h>
 #include <OpenAL/alc.h>
+#endif
 
 namespace Sound
 {
-- 
2.30.2


From 41035027e8e2e8ff17e0c9b5cb68faf901d88f11 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 16 Nov 2021 18:48:15 +1000
Subject: Fix build for 32 bit


diff --git a/src/core/plugins/archives/raw_supp.cpp b/src/core/plugins/archives/raw_supp.cpp
index 2cd9696..14692d9 100644
--- a/src/core/plugins/archives/raw_supp.cpp
+++ b/src/core/plugins/archives/raw_supp.cpp
@@ -338,7 +338,7 @@ namespace ZXTune::Raw
 
   private:
     Log::ProgressCallback* const Delegate;
-    const Math::ScaleFunctor<std::size_t> ToPercent;
+    const Math::ScaleFunctor<uint64_t> ToPercent;
     const String Text;
   };
 
-- 
2.30.2

