From 22b0891598b2986ad42f99e6b3efbf24d8656dde Mon Sep 17 00:00:00 2001 From: Nishi Date: Tue, 28 Apr 2026 15:06:38 +0000 Subject: [PATCH] init haiku --- configure | 5 ++++- include/Mw/LowLevel.h | 13 +++++++++++++ include/Mw/MachDep.h | 2 +- pl/ostype/Haiku.pl | 5 +++++ pl/rules.pl | 4 ++++ pl/utils.pl | 2 +- src/abstract/dynamic.c | 2 +- src/abstract/time.c | 2 +- src/backend/haiku.cxx | 4 ++++ 9 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 pl/ostype/Haiku.pl create mode 100644 src/backend/haiku.cxx diff --git a/configure b/configure index fcc7014..cab810a 100755 --- a/configure +++ b/configure @@ -77,7 +77,7 @@ my @features_keys = ( ); sub def_platform { - if($target ne "Darwin" and $target ne "ClassicMacOS" and $target ne "Windows") { + if($target ne "Darwin" and $target ne "ClassicMacOS" and $target ne "Windows" and $target ne "Haiku") { param_set("freetype2", 1); param_set("stb-truetype", 0); } else { @@ -264,6 +264,9 @@ foreach my $l (@library_targets) { if ($l =~ /cocoa/) { $s =~ s/$o$/.m/; } + elsif ($l =~ /haiku/) { + $s =~ s/$o$/.cxx/; + } else { $s =~ s/$o$/.c/; } diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index c7fefb4..dee33a2 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -30,6 +30,7 @@ enum MwLLBackends { MwLLBackendGDI, MwLLBackendWayland, MwLLBackendCocoa, + MwLLBackendHaiku }; struct _MwLLCommon { @@ -117,6 +118,9 @@ MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx); #ifdef CLASSIC_MAC_OS #include #endif +#ifdef USE_HAIKU +#include +#endif union _MwLL { struct _MwLLCommon common; @@ -135,6 +139,9 @@ union _MwLL { #ifdef CLASSIC_MAC_OS struct _MwLLClassicMacOS cmacos; #endif +#ifdef USE_HAIKU + struct _MwLLHaiku haiku; +#endif }; union _MwLLColor { @@ -151,6 +158,9 @@ union _MwLLColor { #ifdef USE_COCOA struct _MwLLCocoaColor cocoa; #endif +#ifdef USE_HAIKU + struct _MwLLHaikuColor haiku; +#endif }; union _MwLLPixmap { @@ -170,6 +180,9 @@ union _MwLLPixmap { #ifdef CLASSIC_MAC_OS struct _MwLLClassicMacOSPixmap cmacos; #endif +#ifdef USE_HAIKU + struct _MwLLHaikuPixmap haiku; +#endif }; #endif #include diff --git a/include/Mw/MachDep.h b/include/Mw/MachDep.h index 7b068a8..a9419a8 100644 --- a/include/Mw/MachDep.h +++ b/include/Mw/MachDep.h @@ -57,7 +57,7 @@ #include #endif -#if defined(__unix__) || defined(__APPLE__) +#if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) #include #include #endif diff --git a/pl/ostype/Haiku.pl b/pl/ostype/Haiku.pl new file mode 100644 index 0000000..2091b40 --- /dev/null +++ b/pl/ostype/Haiku.pl @@ -0,0 +1,5 @@ +$cc = "g++"; + +use_backend("haiku"); + +1; diff --git a/pl/rules.pl b/pl/rules.pl index c435bff..498e304 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -95,6 +95,10 @@ if (grep(/^cocoa$/, @backends) || param_get("gnustep")) { $gl_libs = "-framework OpenGL"; } +if (grep(/^haiku$/, @backends)) { + new_object("src/backend/haiku.cxx"); +} + if (param_get("stb-image")) { add_cflags("-DUSE_STB_IMAGE"); if (param_get("tiny")) { diff --git a/pl/utils.pl b/pl/utils.pl index 70c0b51..3073a9e 100644 --- a/pl/utils.pl +++ b/pl/utils.pl @@ -54,7 +54,7 @@ sub set_shared_flag { sub new_object { my @l = glob($_[0]); foreach my $e (@l) { - $e =~ s/\.(c|m)$/$object_suffix/; + $e =~ s/\.(cxx|c|m)$/$object_suffix/; push(@library_targets, $e); } } diff --git a/src/abstract/dynamic.c b/src/abstract/dynamic.c index ae31e82..58bc831 100644 --- a/src/abstract/dynamic.c +++ b/src/abstract/dynamic.c @@ -48,7 +48,7 @@ void MwDynamicClose(void* handle) { // CFragConnectionID connID = (CFragConnectionID)handle; // CloseConnection(&connID); } -#elif defined(__unix__) || defined(__APPLE__) +#elif defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) void* MwDynamicOpen(const char* path) { return dlopen(path, RTLD_LOCAL | RTLD_LAZY); } diff --git a/src/abstract/time.c b/src/abstract/time.c index cd09b94..d1ddb83 100644 --- a/src/abstract/time.c +++ b/src/abstract/time.c @@ -55,7 +55,7 @@ void MwTimeSleep(int ms) { // DisposeTimerUPP(tm.tmAddr); } -#elif defined(__unix__) +#elif defined(__unix__) || defined(__HAIKU__) long MwTimeGetTick(void) { struct timespec ts; long n = 0; diff --git a/src/backend/haiku.cxx b/src/backend/haiku.cxx new file mode 100644 index 0000000..fb333b5 --- /dev/null +++ b/src/backend/haiku.cxx @@ -0,0 +1,4 @@ +#include + +#include "call.c" +CALL(Haiku);