Skip to content

Commit

Permalink
CONFIGURE: Support for kolibri OS
Browse files Browse the repository at this point in the history
  • Loading branch information
phcoder authored and sev- committed Feb 5, 2023
1 parent 37230e7 commit 31071d7
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 14 deletions.
10 changes: 1 addition & 9 deletions backends/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ MODULE_OBJS += \
mutex/sdl/sdl-mutex.o \
timer/sdl/sdl-timer.o

ifdef KOLIBRIOS
MODULE_OBJS += plugins/kolibrios/kolibrios-provider.o
endif

ifndef RISCOS
ifndef KOLIBRIOS
MODULE_OBJS += plugins/sdl/sdl-provider.o
Expand Down Expand Up @@ -188,11 +184,7 @@ MODULE_OBJS += \
fs/kolibrios/kolibrios-fs.o \
fs/kolibrios/kolibrios-fs-factory.o \
fs/posix/posix-iostream.o \
fs/posix-drives/posix-drives-fs.o \
fs/posix-drives/posix-drives-fs-factory.o \
fs/chroot/chroot-fs-factory.o \
fs/chroot/chroot-fs.o \
plugins/posix/posix-provider.o \
plugins/kolibrios/kolibrios-provider.o \
saves/kolibrios/kolibrios-saves.o
endif

Expand Down
11 changes: 11 additions & 0 deletions backends/platform/sdl/kolibrios/build-kolibri.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

export KOS32_SDK_DIR=$HOME/sdk
export KOS32_AUTOBUILD=$HOME/autobuild

# Use plugins for both engines and detection as KolibriOS has a limit per executable module
./configure --host=kos32 --enable-release --enable-plugins --default-dynamic --enable-detection-dynamic --enable-engine=testbed

make -j5 all zip-root scummvm-zip
35 changes: 35 additions & 0 deletions backends/platform/sdl/kolibrios/kolibrios.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
bundle = zip-root

all: scummvm.kos $(EXECUTABLE)

scummvm.kos: $(srcdir)/backends/platform/sdl/kolibrios/wrapper-main.c
+$(QUIET_CC)$(CXX) -I$(KOS32_SDK_DIR)/sources/newlib/libc/include -specs=$(srcdir)/backends/platform/sdl/kolibrios/kolibrios.spec -x c -o $@.coff $<
+$(QUIET)$(KOS32_AUTOBUILD)/bin/kos32-objcopy $@.coff -O binary $@

$(bundle): all
$(RM) -rf $(bundle)
$(MKDIR) -p $(bundle)/scummvm
$(CP) $(DIST_FILES_DOCS) $(bundle)/scummvm
$(MKDIR) $(bundle)/scummvm/themes
$(CP) $(DIST_FILES_THEMES) $(bundle)/scummvm/themes/

ifdef DIST_FILES_ENGINEDATA
$(MKDIR) $(bundle)/scummvm/engine-data
$(CP) $(DIST_FILES_ENGINEDATA) $(bundle)/scummvm/engine-data/
endif
ifdef DIST_FILES_NETWORKING
$(CP) $(DIST_FILES_NETWORKING) $(bundle)/scummvm
endif
ifdef DIST_FILES_VKEYBD
$(CP) $(DIST_FILES_VKEYBD) $(bundle)/scummvm
endif
ifdef DYNAMIC_MODULES
$(MKDIR) $(bundle)/scummvm/plugins/
$(CP) $(PLUGINS) $(bundle)/scummvm/plugins/
endif
$(CP) scummvm.kos $(bundle)/scummvm/scummvm
$(CP) scummvm.dll $(bundle)/scummvm/scummvm.dll

scummvm-zip: $(bundle)
$(RM) scummvm_kolibrios.zip
cd $(bundle) && zip -r ../scummvm_kolibri.zip scummvm
15 changes: 15 additions & 0 deletions backends/platform/sdl/kolibrios/kolibrios.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*lib:
-lc %{!static:-ldll}

*libgcc:
-lsupc++ -lgcc

*link:
%{mdll:%{shared: %eshared and mdll are not compatible} %{static: %estatic and mdll are not compatible}} -L%:getenv(KOS32_SDK_DIR /lib) %{shared|mdll: -shared --entry _DllStartup} %{shared:-T%:getenv(KOS32_SDK_DIR /sources/newlib/dll.lds)} %{static: -static -T%:getenv(KOS32_SDK_DIR /sources/newlib/app.lds)} %{!mdll:%{!static:%{!shared: -call_shared -T%:getenv(KOS32_SDK_DIR /sources/newlib/app-dynamic.lds)}}} %{!mdll:-s --image-base 0} %{mdll:--enable-auto-image-base} %(shared_libgcc_undefs)

*startfile:


*endfile:


85 changes: 80 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ get_system_exe_extension() {
gph-linux)
_exeext=".gph"
;;
kolibrios | kos32)
_exeext=".dll"
;;
mingw* | *os2-emx)
_exeext=".exe"
;;
Expand Down Expand Up @@ -835,6 +838,7 @@ Special configuration feature:
iphone for Apple iPhone (iOS <= 6)
ios7 for Apple iPhone / iPad (iOS >= 7)
ios7-arm64 for Apple iPhone / iPad (iOS >= 7, 64-bit)
kos32 for Kolibri OS
maemo for Nokia Maemo
miyoo for 1st generation Miyoo
miyoomini for Miyoo Mini
Expand Down Expand Up @@ -1628,6 +1632,11 @@ ios7-arm64)
_host_cpu=aarch64
_host_alias=arm64-apple-darwin11
;;
kos32)
_host_os=kolibrios
_host_cpu=i686
_host_alias=kos32
;;
maemo)
_host_os=maemo
_host_cpu=arm
Expand Down Expand Up @@ -1854,6 +1863,24 @@ emscripten)
exit 1
fi
;;
kolibrios)
if test -z "$KOS32_SDK_DIR" || test -z "$KOS32_AUTOBUILD"; then
echo "Please set KOS32_SDK_DIR and KOS32_AUTOBUILD in your environment. export KOS32_SDK_DIR=<path to KOS32 SDK> and export KOS32_AUTOBUILD=<path to KOS32 build>"
exit 1
fi
_as="${KOS32_AUTOBUILD}/bin/kos32-as"
_ar="${KOS32_AUTOBUILD}/bin/kos32-ar cr"
_ranlib="${KOS32_AUTOBUILD}/bin/kos32-ar -s"
_strip="${KOS32_AUTOBUILD}/bin/kos32-strip"
if test -z "$CXX"; then
CXX="${KOS32_AUTOBUILD}/bin/kos32-g++"
fi
append_var DEFINES "-U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOLIBRIOS=1 -D_POSIX_C_SOURCE=1 -D_XOPEN_SOURCE=1"
append_var CXXFLAGS "-I${KOS32_SDK_DIR}/sources/newlib/libc/include -I${KOS32_SDK_DIR}/sources/libstdc++-v3/include -fno-ident -fomit-frame-pointer"
# Final executable will be a DLL but for tests we need to stick to a standard binary because DLLs having a main function trigger a build failure
# We will add the -shared option at the end
append_var LDFLAGS "-specs=$_srcdir/backends/platform/sdl/kolibrios/kolibrios.spec"
;;
n64)
if test -z "$N64SDK"; then
echo "Please set N64SDK in your environment. export N64SDK=<path to n64 sdk>"
Expand Down Expand Up @@ -2198,7 +2225,7 @@ if test "$have_gcc" = yes ; then
case $_host_os in
# newlib-based system include files suppress non-C89 function
# declarations under __STRICT_ANSI__, undefine it
3ds | android | gamecube | psp | switch | wii)
3ds | android | gamecube | kolibrios | psp | switch | wii)
std_variant=gnu++
pedantic=no
;;
Expand Down Expand Up @@ -3493,6 +3520,35 @@ if test -n "$_host"; then
_seq_midi=no
_timidity=no
;;
kos32)
# neither pkg-config nor *-config work, so we setup everything manually
_pkgconfig=/bin/false
_pkg_config=no

ZLIB_CFLAGS="-I${KOS32_SDK_DIR}/sources/zlib"
if test "$_png" != no; then
PNG_CFLAGS="-I${KOS32_SDK_DIR}/sources/libpng"
PNG_LIBS="-lpng16 -lz"
_png=yes
fi
JPEG_CFLAGS="-I${KOS32_SDK_DIR}/sources/libjpeg"

FREETYPE2_STATIC_LIBS="-lfreetype"
FREETYPE2_CFLAGS="-I${KOS32_SDK_DIR}/sources/freetype/include"
_freetype_found="true"

SDL_CFLAGS="-I${KOS32_SDK_DIR}/sources/SDL-1.2.2_newlib/include"
SDL_LIBS="-lSDLn -lsound"
_sdl=yes
_sdlversion=1.2.2
_backend="kolibrios"

_timidity=no
add_line_to_config_mk 'KOLIBRIOS = 1'
add_line_to_config_mk 'KOS32_AUTOBUILD = '"${KOS32_AUTOBUILD}"
add_line_to_config_mk 'KOS32_SDK_DIR = '"${KOS32_SDK_DIR}"
_port_mk="backends/platform/sdl/kolibrios/kolibrios.mk"
;;
m68k-atari-mint)
_seq_midi=no
_timidity=no
Expand Down Expand Up @@ -3846,6 +3902,10 @@ case $_backend in
append_var CXXFLAGS "-isysroot $SDKROOT -I$SDKROOT/usr/include/c++/4.2.1 -F$SDKROOT/System/Library/Frameworks"
fi
;;
kolibrios)
_sdl=yes
append_var MODULES "backends/platform/sdl"
;;
maemo)
append_var DEFINES "-DMAEMO"
append_var LIBS "-lX11"
Expand Down Expand Up @@ -3928,7 +3988,6 @@ case $_backend in
;;
esac


append_var MODULES "backends/platform/$_backend"

#
Expand Down Expand Up @@ -4062,7 +4121,7 @@ fi
# Enable 16bit support only for backends which support it
#
case $_backend in
3ds | android | dingux | dc | ds | gph | iphone | ios7 | maemo | null | opendingux | miyoomini | miyoo | openpandora | psp | psp2 | samsungtv | sdl | switch | wii)
3ds | android | dingux | dc | ds | gph | iphone | ios7 | kolibrios | maemo | null | opendingux | miyoomini | miyoo | openpandora | psp | psp2 | samsungtv | sdl | switch | wii)
if test "$_16bit" = auto ; then
_16bit=yes
else
Expand Down Expand Up @@ -4135,7 +4194,7 @@ esac
#
echo_n "Checking if host is POSIX compliant... "
case $_host_os in
amigaos* | dreamcast | ds | gamecube | mingw* | morphos | n64 | ps3 | psp2 | psp | riscos | wii)
amigaos* | dreamcast | ds | gamecube | kolibrios | mingw* | morphos | n64 | ps3 | psp2 | psp | riscos | wii)
_posix=no
;;
3ds | android | beos* | bsd* | cygwin* | darwin* | dragonfly* | freebsd* | gnu* | gph-linux | haiku* | hpux* | iphone | ios7 | irix*| k*bsd*-gnu* | linux* | maemo | mint* | netbsd* | openbsd* | serenity* | solaris* | sunos* | switch | uclinux*)
Expand Down Expand Up @@ -4419,6 +4478,16 @@ PLUGIN_EXTRA_DEPS =
PLUGIN_LDFLAGS += -shared -static-libgcc
PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive
POST_OBJS_FLAGS := -Wl,-no-whole-archive
'
;;
kolibrios)
_plugin_suffix=".svm.dll"
append_var DEFINES "-DUNCACHED_PLUGINS"
_mak_plugins='
PLUGIN_EXTRA_DEPS = $(EXECUTABLE)
PLUGIN_LDFLAGS += -specs=$(srcdir)/backends/platform/sdl/kolibrios/kolibrios.spec -mdll -Wl,-q,--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms -Wl,--enable-auto-import ./libscummvm.a
PRE_OBJS_FLAGS := -Wl,--whole-archive
POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-implib,./libscummvm.a
'
;;

Expand Down Expand Up @@ -5936,7 +6005,7 @@ if test "$_have_x86" = yes ; then
darwin*)
append_var NASMFLAGS "-f macho"
;;
mingw*)
mingw* | kolibrios)
append_var NASMFLAGS "-f win32"
;;
os2-emx*)
Expand Down Expand Up @@ -6472,6 +6541,12 @@ case $_host_os in
LIBS=`echo ${LIBS} | sed 's/-lz//g'`
fi
;;
kolibrios)
# In reality we will build a DLL
append_var LDFLAGS "-shared"
# kos32 toolchain only has libpng16
LIBS=`echo ${LIBS} | sed 's/-lpng //g'`
;;
mingw*)
if test "$_windows_unicode" = yes; then
append_var DEFINES "-DUNICODE -D_UNICODE"
Expand Down

0 comments on commit 31071d7

Please sign in to comment.