mirror of
https://github.com/json-c/json-c.git
synced 2026-03-20 21:49:07 +08:00
Add support for Commodore Amiga
This commit is contained in:
committed by
Cameron Armstrong (Nightfox)
parent
961c31f8ed
commit
4feebc1cd6
@@ -78,7 +78,24 @@ if (UNIX OR MINGW OR CYGWIN)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "AmigaOS")
|
||||
set(AMIGA 1)
|
||||
set(DISABLE_THREAD_LOCAL_STORAGE ON)
|
||||
set(ENABLE_THREADING OFF)
|
||||
if ($ENV{CROSS_PFX} STREQUAL "m68k-amigaos")
|
||||
set(AMIGA_M68K 1)
|
||||
message(STATUS "Building for Motorola 68k AmigaOS")
|
||||
elseif ($ENV{CROSS_PFX} STREQUAL "ppc-amigaos")
|
||||
set(AMIGA_PPC 1)
|
||||
message(STATUS "Building for PowerPC AmigaOS")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported AmigaOS target")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Building for ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if (UNIX OR AMIGA)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
||||
endif()
|
||||
|
||||
@@ -87,7 +104,7 @@ if (MSVC)
|
||||
list(APPEND CMAKE_REQUIRED_FLAGS /wd4996)
|
||||
endif()
|
||||
|
||||
if (NOT DISABLE_STATIC_FPIC)
|
||||
if (NOT DISABLE_STATIC_FPIC AND NOT AMIGA)
|
||||
# Use '-fPIC'/'-fPIE' option.
|
||||
# This will allow other libraries to statically link in libjson-c.a
|
||||
# which in turn prevents crashes in downstream apps that may use
|
||||
@@ -112,7 +129,9 @@ check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) # for getrusage
|
||||
check_include_file("dlfcn.h" HAVE_DLFCN_H)
|
||||
check_include_file("endian.h" HAVE_ENDIAN_H)
|
||||
check_include_file("limits.h" HAVE_LIMITS_H)
|
||||
check_include_file("locale.h" HAVE_LOCALE_H)
|
||||
if (NOT AMIGA)
|
||||
check_include_file("locale.h" HAVE_LOCALE_H)
|
||||
endif()
|
||||
check_include_file("memory.h" HAVE_MEMORY_H)
|
||||
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
@@ -136,7 +155,7 @@ endif()
|
||||
check_symbol_exists(_isnan "float.h" HAVE_DECL__ISNAN)
|
||||
check_symbol_exists(_finite "float.h" HAVE_DECL__FINITE)
|
||||
|
||||
if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX)
|
||||
if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX OR AMIGA)
|
||||
check_symbol_exists(INFINITY "math.h" HAVE_DECL_INFINITY)
|
||||
check_symbol_exists(isinf "math.h" HAVE_DECL_ISINF)
|
||||
check_symbol_exists(isnan "math.h" HAVE_DECL_ISNAN)
|
||||
@@ -144,22 +163,23 @@ if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX)
|
||||
endif()
|
||||
|
||||
check_symbol_exists(_doprnt "stdio.h" HAVE_DOPRNT)
|
||||
if (UNIX OR MINGW OR CYGWIN)
|
||||
if (UNIX OR MINGW OR CYGWIN OR AMIGA)
|
||||
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
|
||||
endif()
|
||||
check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
|
||||
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
|
||||
check_symbol_exists(vprintf "stdio.h" HAVE_VPRINTF)
|
||||
|
||||
check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
|
||||
if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
|
||||
check_include_file(bsd/stdlib.h HAVE_BSD_STDLIB_H)
|
||||
if (HAVE_BSD_STDLIB_H)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "bsd")
|
||||
unset(HAVE_ARC4RANDOM CACHE)
|
||||
check_symbol_exists(arc4random "bsd/stdlib.h" HAVE_ARC4RANDOM)
|
||||
if (NOT HAVE_ARC4RANDOM)
|
||||
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "bsd")
|
||||
if (NOT AMIGA)
|
||||
check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
|
||||
if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
|
||||
check_include_file(bsd/stdlib.h HAVE_BSD_STDLIB_H)
|
||||
if (HAVE_BSD_STDLIB_H)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "bsd")
|
||||
unset(HAVE_ARC4RANDOM CACHE)
|
||||
check_symbol_exists(arc4random "bsd/stdlib.h" HAVE_ARC4RANDOM)
|
||||
if (NOT HAVE_ARC4RANDOM)
|
||||
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "bsd")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -201,7 +221,7 @@ endif()
|
||||
if (HAVE_SYS_RANDOM_H)
|
||||
check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
|
||||
endif()
|
||||
if (HAVE_SYS_RESOURCE_H)
|
||||
if (HAVE_SYS_RESOURCE_H AND NOT AMIGA)
|
||||
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
|
||||
endif()
|
||||
|
||||
@@ -298,6 +318,9 @@ if ("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER
|
||||
if ("${DISABLE_WERROR}" STREQUAL "OFF")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||
endif()
|
||||
if (AMIGA_M68K)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fbaserel")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
|
||||
|
||||
43
README.md
43
README.md
@@ -12,8 +12,9 @@ json-c
|
||||
5. [Testing](#testing)
|
||||
6. [Building with `vcpkg`](#buildvcpkg)
|
||||
7. [Building for Android](#android)
|
||||
7. [Linking to libjson-c](#linking)
|
||||
8. [Using json-c](#using)
|
||||
8. [Building for Commodore Amiga](#amiga)
|
||||
9. [Linking to libjson-c](#linking)
|
||||
10. [Using json-c](#using)
|
||||
|
||||
<a name="overview"></a>
|
||||
JSON-C - A JSON implementation in C
|
||||
@@ -270,6 +271,44 @@ cmake \
|
||||
make install
|
||||
```
|
||||
|
||||
<a name="amiga"></a>
|
||||
Building for Commodore Amiga
|
||||
----------------------
|
||||
|
||||
Building for Commodore Amiga is supported for both Motorola 68k (AmigaOS 3) and PowerPC (AmigaOS 4) architectures. You can set up a cross compiler locally, however it is much easier to use the already preconfigured Amiga development environment wtthin a Docker container.
|
||||
|
||||
Install Docker on your machine if you don't already have it. You can download Docker Desktop for Windows/macOS/Linux [here](https://www.docker.com/products/docker-desktop/).
|
||||
|
||||
To build for Motorola 68k Amiga:
|
||||
|
||||
```
|
||||
mkdir json-c-build
|
||||
docker run --rm \
|
||||
-v ${PWD}:/work \
|
||||
-e USER=$( id -u ) -e GROUP=$( id -g ) \
|
||||
-it sacredbanana/amiga-compiler:m68k-amigaos bash
|
||||
cd json-c-build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
libjson-c.a will get created in the json-c-build directory.
|
||||
|
||||
To build for PowerPC Amiga:
|
||||
|
||||
```
|
||||
mkdir json-c-build
|
||||
docker run --rm \
|
||||
-v ${PWD}:/work \
|
||||
-e USER=$( id -u ) -e GROUP=$( id -g ) \
|
||||
-it sacredbanana/amiga-compiler:ppc-amigaos bash
|
||||
cd json-c-build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
libjson-c.a will get created in the json-c-build directory.
|
||||
|
||||
<a name="linking"></a>
|
||||
Linking to `libjson-c`
|
||||
----------------------
|
||||
|
||||
@@ -95,7 +95,7 @@ endif() # end "standalone mode" block
|
||||
# ---------------------------------
|
||||
|
||||
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) # for getrusage
|
||||
if (HAVE_SYS_RESOURCE_H)
|
||||
if (HAVE_SYS_RESOURCE_H AND NOT AMIGA)
|
||||
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user