Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Makefile CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build-os3:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Run the build process with Docker
uses: addnab/docker-run-action@v3
with:
image: amigadev/crosstools:m68k-amigaos
options: -v ${{ github.workspace }}:/work
run: |
cd mcc
make OS=os3 DEBUG=
cd ../mcp
make OS=os3 DEBUG=

- uses: actions/upload-artifact@v3
with:
name: HTMLview_os3
path: |
bin_os3/HTMLview.mcp
bin_os3/HTMLview-Prefs
bin_os3/HTMLview.mcc
bin_os3/HTMLview-Test
2 changes: 2 additions & 0 deletions build_os3.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy Bypass -File "%~dp0build_os3.ps1"
36 changes: 36 additions & 0 deletions build_os3.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# PowerShell script to build for AmigaOS 3 using Docker

$ErrorActionPreference = "Stop"

# Define the Docker image
$Image = "amigadev/crosstools:m68k-amigaos"

# Define the build command
# We mirror the steps from .github/workflows/makefile.yml
# 1. cd mcc
# 2. make OS=os3 DEBUG=
# 3. cd ../mcp
# 4. make OS=os3 DEBUG=
$BuildCommand = "mkdir -p mcc/.obj_os3/classes mcc/bin_os3 && cd mcc && make bin_os3/HTMLview.mcc OS=os3 DEBUG= > ../build.log 2>&1 && make bin_os3/SimpleTest OS=os3 DEBUG= >> ../build.log 2>&1 && cd ../mcp && make OS=os3 DEBUG= >> ../build.log 2>&1"

# Get the current directory (project root)
$WorkDir = Get-Location

Write-Host "Starting AmigaOS 3 cross-compilation..."
Write-Host "Mounting '$WorkDir' to '/work' in container '$Image'"

try {
# Run the Docker container
# -v "${WorkDir}:/work" mounts the current directory to /work
# --rm automatically removes the container after exit
# -w /work sets the working directory to /work
docker run --rm -v "${WorkDir}:/work" -w /work $Image /bin/bash -c "$BuildCommand"

if ($LASTEXITCODE -eq 0) {
Write-Host "Build completed successfully!"
} else {
Write-Error "Build failed with exit code $LASTEXITCODE"
}
} catch {
Write-Error "An error occurred while running Docker: $_"
}
6 changes: 3 additions & 3 deletions include/SDI_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@
// the AmigaOS3 g++ 2.95.3 cannot handle explicit register definitions and
// hence requires HookEntry() as gate function
#define MakeCppHook(hookname, funcname) struct Hook hookname = {{NULL, NULL}, \
(HOOKFUNC)HookEntry, (HOOKFUNC)funcname, NULL}
(ULONG (*)())HookEntry, (ULONG (*)())funcname, NULL}
#define MakeCppHookWithData(hookname, funcname, data) struct Hook hookname = \
{{NULL, NULL}, (HOOKFUNC)HookEntry, (HOOKFUNC)funcname, (APTR)data}
{{NULL, NULL}, (ULONG (*)())HookEntry, (ULONG (*)())funcname, (APTR)data}
#define MakeStaticCppHook(hookname, funcname) static struct Hook hookname = \
{{NULL, NULL}, (HOOKFUNC)HookEntry, (HOOKFUNC)funcname, NULL}
{{NULL, NULL}, (ULONG (*)())HookEntry, (ULONG (*)())funcname, NULL}
#endif

#define DISPATCHERPROTO(name) SAVEDS ASM IPTR name(REG(a0, \
Expand Down
20 changes: 17 additions & 3 deletions include/mccinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ struct Interface *INewlib = NULL;
#else
struct Library *MUIMasterBase = NULL;
struct ExecBase *SysBase = NULL;
struct Library *UtilityBase = NULL;
struct UtilityBase *UtilityBase = NULL;
struct DosLibrary *DOSBase = NULL;
struct GfxBase *GfxBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
Expand All @@ -198,14 +198,19 @@ extern "C" {
// newer OS version can directly take the specified
// number for the ramlib process
#if defined(MIN_STACKSIZE)

// transforms a define into a string
#define STR(x) STR2(x)
#define STR2(x) #x

static const char USED_VAR stack_size[] = "$STACK:" STR(MIN_STACKSIZE) "\n";
#endif

// Declared _init/_fini for AmigaOS 3 C++ manual initialization
#if defined(__amigaos3__)
extern void _init(void);
extern void _fini(void);
#endif

/* The name of the class will also become the name of the library. */
/* We need a pointer to this string in our ROMTag (see below). */
static const char UserLibName[] = CLASS;
Expand Down Expand Up @@ -642,7 +647,7 @@ static ULONG mccLibInit(struct LibraryHeader *base)
if((DOSBase = (struct DosLibrary*)OpenLibrary("dos.library", 36)) &&
(GfxBase = (struct GfxBase*)OpenLibrary("graphics.library", 36)) &&
(IntuitionBase = (struct IntuitionBase*)OpenLibrary("intuition.library", 36)) &&
(UtilityBase = OpenLibrary("utility.library", 36)))
(UtilityBase = (struct UtilityBase*)OpenLibrary("utility.library", 36)))
#endif
{
// we have to please the internal utilitybase
Expand All @@ -654,6 +659,11 @@ static ULONG mccLibInit(struct LibraryHeader *base)
#endif
#endif

#if defined(__amigaos3__)
// Manually call C++ constructors (including InitMem for MemoryPool)
_init();
#endif

#if defined(DEBUG)
SetupDebug();
#endif
Expand Down Expand Up @@ -948,6 +958,10 @@ static BPTR LIBFUNC LibExpunge(REG(a6, struct LibraryHeader *base))
#endif
BPTR rc;

#if defined(__amigaos3__)
_fini();
#endif

D(DBF_STARTUP, "LibExpunge(%s): %ld", CLASS, base->lh_Library.lib_OpenCnt);

// in case our open counter is still > 0, we have
Expand Down
4 changes: 3 additions & 1 deletion mcc/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ VOID AnimInfo::Stop (Object *obj, struct AnimInfo *prev)
{
prev = this;
}
prev->Next->Stop(obj, prev);
if (prev && prev->Next) {
prev->Next->Stop(obj, prev);
}
}
}

Expand Down
14 changes: 13 additions & 1 deletion mcc/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

***************************************************************************/


#ifdef DEBUG

#include <stdio.h> // vsnprintf
Expand Down Expand Up @@ -72,7 +73,7 @@ static ULONG debug_classes = DBC_ERROR | DBC_DEBUG | DBC_WARNING | DBC_ASSERT |

/****************************************************************************/

#ifdef __MORPHOS__
#if defined(__MORPHOS__)

#define VNewRawDoFmt(__p0, __p1, __p2, __p3) \
(((STRPTR (*)(void *, CONST_STRPTR , APTR (*)(APTR, UBYTE), STRPTR , va_list ))*(void**)((long)(EXEC_BASE_NAME) - 820))((void*)(EXEC_BASE_NAME), __p0, __p1, __p2, __p3))
Expand All @@ -85,6 +86,17 @@ void kprintf(const char *formatString,...)
VNewRawDoFmt(formatString,(void * (*)(void *, UBYTE))RAWFMTFUNC_SERIAL,NULL,va);
va_end(va);
}
#elif defined(__amigaos3__)
extern "C" void KPrintF(const char *fmt, ...);
void kprintf(const char *formatString, ...)
{
char buf[1024];
va_list va;
va_start(va, formatString);
vsnprintf(buf, sizeof(buf), formatString, va);
KPrintF("%s", buf);
va_end(va);
}
#endif

/****************************************************************************/
Expand Down
Loading