Specify fbaserel and Motorola CPU target

This commit is contained in:
Cameron Armstrong (Nightfox) committed 2026-08-22 14:47:19 +08:00
1 parent b299553de1
commit f6881669c2
2 files changed
+52 -2

No files matched your search

+34 -2
View File
@@ -99,7 +99,31 @@ if (AMIGA)
else() else()
set(NEWLIB ON) set(NEWLIB ON)
endif() endif()
message(STATUS "Building for Motorola 68k AmigaOS using CRT: ${M68K_CRT}") if (NOT DEFINED M68K_BASEREL)
set(M68K_BASEREL "baserel")
endif()
set(M68K_BASEREL "${M68K_BASEREL}" CACHE STRING "m68k base-relative addressing: baserel, baserel32, or off")
set_property(CACHE M68K_BASEREL PROPERTY STRINGS baserel baserel32 off)
if (NOT M68K_BASEREL STREQUAL "baserel" AND
NOT M68K_BASEREL STREQUAL "baserel32" AND
NOT M68K_BASEREL STREQUAL "off")
message(FATAL_ERROR "M68K_BASEREL must be baserel, baserel32, or off (got: ${M68K_BASEREL})")
endif()
set(M68K_CPU "${M68K_CPU}" CACHE STRING "m68k CPU target (e.g. 68020, 68040, 68060); empty uses the compiler default")
if (M68K_CPU STREQUAL "" OR M68K_CPU STREQUAL "off")
set(M68K_CPU_FLAG "")
elseif (M68K_CPU MATCHES "^-")
set(M68K_CPU_FLAG "${M68K_CPU}")
elseif (M68K_CPU MATCHES "^m")
set(M68K_CPU_FLAG "-${M68K_CPU}")
else()
set(M68K_CPU_FLAG "-m${M68K_CPU}")
endif()
if (M68K_CPU_FLAG STREQUAL "")
message(STATUS "Building for Motorola 68k AmigaOS using CRT: ${M68K_CRT}, baserel: ${M68K_BASEREL}")
else()
message(STATUS "Building for Motorola 68k AmigaOS using CRT: ${M68K_CRT}, baserel: ${M68K_BASEREL}, cpu: ${M68K_CPU_FLAG}")
endif()
elseif ($ENV{CROSS_PFX} STREQUAL "ppc-amigaos") elseif ($ENV{CROSS_PFX} STREQUAL "ppc-amigaos")
set(AMIGA_PPC ON) set(AMIGA_PPC ON)
message(STATUS "Building for PowerPC AmigaOS") message(STATUS "Building for PowerPC AmigaOS")
@@ -109,6 +133,7 @@ if (AMIGA)
message(STATUS "Building for PowerPC MorphOS without ixemul") message(STATUS "Building for PowerPC MorphOS without ixemul")
set(DISABLE_WERROR ON) set(DISABLE_WERROR ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -noixemul") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -noixemul")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types")
else() else()
message(STATUS "Building for PowerPC MorphOS with ixemul") message(STATUS "Building for PowerPC MorphOS with ixemul")
endif() endif()
@@ -362,7 +387,14 @@ if ("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif() endif()
if (AMIGA_M68K) if (AMIGA_M68K)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fbaserel") if (M68K_BASEREL STREQUAL "baserel")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fbaserel")
elseif (M68K_BASEREL STREQUAL "baserel32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fbaserel32")
endif()
if (NOT M68K_CPU_FLAG STREQUAL "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${M68K_CPU_FLAG}")
endif()
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
+18
View File
@@ -296,6 +296,24 @@ libjson-c.a will get created in the build directory.
You can change newlib to nix20, nix13, ixemul or clib2 if you would like to build the library suited for libnix or clib2 instead. Newlib is default. You can change newlib to nix20, nix13, ixemul or clib2 if you would like to build the library suited for libnix or clib2 instead. Newlib is default.
By default the m68k build uses `-fbaserel`. You can select a different base-relative mode with `-DM68K_BASEREL=`:
* `baserel` (default) — `-fbaserel`
* `baserel32` — `-fbaserel32`
* `off` — no base-relative flag
```
cmake -DM68K_CRT=newlib -DM68K_BASEREL=baserel32 ..
cmake -DM68K_CRT=newlib -DM68K_BASEREL=off ..
```
You can also set the target CPU with `-DM68K_CPU=`. This is passed to the compiler as `-m<cpu>` (for example `68020` becomes `-m68020`). If omitted, the compiler default is used.
```
cmake -DM68K_CRT=newlib -DM68K_CPU=68020 ..
cmake -DM68K_CRT=newlib -DM68K_CPU=68040 -DM68K_BASEREL=baserel32 ..
```
### To build for PowerPC Amiga: ### To build for PowerPC Amiga:
``` ```