@afxgroup
I think I'm stuck now - but by no means sure.
I used one of Walkero's containers to build GLFW that uses your version of clib2. I don't have a toolchain file so I used the following command(s) to build:
mkdir build && cd build
cmake -E env LDFLAGS="-mcrt=clib2 -use-dynld -athread=native -lauto" cmake -DAMIGAOS4=1 -DCMAKE_C_FLAGS="-mcrt=clib2 -I$OGL_INC" -DCMAKE_LIBRARY_PATH=-L$OGL_INC/../../newlib/lib ..
So I'm basically telling it to use clib2 runtime in both compile and link, setting a couple of options and pointing it to where I put ogles2 from the enhancer install. Note that although this lives in the newlib folder, that's just where I put it. I don't actually know if it is runtime agnostic or whether it is newlib or clib2.
At this point all of GLFW builds. There are two redefinition warnings on GL_VERSION and GL_EXTENSIONS but the values are the save between redeclaration so I think that's harmless. What is probably not so harmless is this:
/opt/code/glfw/src/os4_context.c: In function ‘swapBuffersGL’:
/opt/code/glfw/src/os4_context.c:70:5: warning: implicit declaration of function ‘glFinish’ [-Wimplicit-function-declaration]
70 | glFinish();
| ^~~~~~~~
/opt/code/glfw/src/os4_context.c: In function ‘_glfwCreateContextGL’:
/opt/code/glfw/src/os4_context.c:162:9: warning: implicit declaration of function ‘glClear’ [-Wimplicit-function-declaration]
162 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
| ^~~~~~~
/opt/code/glfw/src/os4_context.c:164:9: warning: implicit declaration of function ‘glViewport’ [-Wimplicit-function-declaration]
164 | glViewport(0, 0, window->os4.width, window->os4.height);
| ^~~~~~~~~~
But i really don't know what to include to solve that.
At this point the examples fail. So I just turned them off.
I then went to compile one of the examples (gears) on the Amiga. Of course this doesn't work and I assume it's because the Amiga doesn't have your version of clib2. But I wouldn't have a clue how to replace the SDK one or if that is even sensible, so back to the docker container.
The farthest I can get so far is this (I split the compile and link so I could be sure of what I was doing):
/opt/ppc-amigaos/bin/ppc-amigaos-gcc -c gears.c -mcrt=clib2 -I../deps -I../include
(that works)
/opt/ppc-amigaos/bin/ppc-amigaos-gcc gears.o -mcrt=clib2 -L ../build/src -lglfw3 -lpthread -logles2 -L/opt/code/ogles2/local/newlib/lib
/opt/code/ogles2/local/newlib/lib/libogles2.a(Clear.o): In function `glClear':
Clear.c:(.text+0x2): undefined reference to `IOGLES2'
Clear.c:(.text+0xa): undefined reference to `IOGLES2'
/opt/code/ogles2/local/newlib/lib/libogles2.a(CreateCtx.o): In function `aglCreateContext_AVOID':
CreateCtx.c:(.text+0x2): undefined reference to `IOGLES2'
CreateCtx.c:(.text+0xa): undefined reference to `IOGLES2'
/opt/code/ogles2/local/newlib/lib/libogles2.a(CreateCtx.o): In function `aglCreateContext2':
CreateCtx.c:(.text+0x22): undefined reference to `IOGLES2'
/opt/code/ogles2/local/newlib/lib/libogles2.a(CreateCtx.o):CreateCtx.c:(.text+0x2a): more undefined references to `IOGLES2' follow
collect2: error: ld returned 1 exit status
I really don't know how to resolve those last references or how close I am! It feels like I'm close but I could just as easily be way off here.
[edit] IOGLES2 looks like it's an interface definition which suggests to me that libogles2 indeed is shared and newlib. So is there a different ogles2 I should be using rather than the one in Enhancer? Maybe that's the bit I'm missing?