mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 13:29:06 +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)
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||||
endif()
|
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)
|
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -87,7 +104,7 @@ if (MSVC)
|
|||||||
list(APPEND CMAKE_REQUIRED_FLAGS /wd4996)
|
list(APPEND CMAKE_REQUIRED_FLAGS /wd4996)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT DISABLE_STATIC_FPIC)
|
if (NOT DISABLE_STATIC_FPIC AND NOT AMIGA)
|
||||||
# Use '-fPIC'/'-fPIE' option.
|
# Use '-fPIC'/'-fPIE' option.
|
||||||
# This will allow other libraries to statically link in libjson-c.a
|
# This will allow other libraries to statically link in libjson-c.a
|
||||||
# which in turn prevents crashes in downstream apps that may use
|
# 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("dlfcn.h" HAVE_DLFCN_H)
|
||||||
check_include_file("endian.h" HAVE_ENDIAN_H)
|
check_include_file("endian.h" HAVE_ENDIAN_H)
|
||||||
check_include_file("limits.h" HAVE_LIMITS_H)
|
check_include_file("limits.h" HAVE_LIMITS_H)
|
||||||
|
if (NOT AMIGA)
|
||||||
check_include_file("locale.h" HAVE_LOCALE_H)
|
check_include_file("locale.h" HAVE_LOCALE_H)
|
||||||
|
endif()
|
||||||
check_include_file("memory.h" HAVE_MEMORY_H)
|
check_include_file("memory.h" HAVE_MEMORY_H)
|
||||||
|
|
||||||
check_include_file(stdint.h HAVE_STDINT_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(_isnan "float.h" HAVE_DECL__ISNAN)
|
||||||
check_symbol_exists(_finite "float.h" HAVE_DECL__FINITE)
|
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(INFINITY "math.h" HAVE_DECL_INFINITY)
|
||||||
check_symbol_exists(isinf "math.h" HAVE_DECL_ISINF)
|
check_symbol_exists(isinf "math.h" HAVE_DECL_ISINF)
|
||||||
check_symbol_exists(isnan "math.h" HAVE_DECL_ISNAN)
|
check_symbol_exists(isnan "math.h" HAVE_DECL_ISNAN)
|
||||||
@@ -144,13 +163,13 @@ if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_symbol_exists(_doprnt "stdio.h" HAVE_DOPRNT)
|
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)
|
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
|
||||||
endif()
|
endif()
|
||||||
check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
|
check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
|
||||||
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
|
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
|
||||||
check_symbol_exists(vprintf "stdio.h" HAVE_VPRINTF)
|
check_symbol_exists(vprintf "stdio.h" HAVE_VPRINTF)
|
||||||
|
if (NOT AMIGA)
|
||||||
check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
|
check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
|
||||||
if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
|
if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
|
||||||
check_include_file(bsd/stdlib.h HAVE_BSD_STDLIB_H)
|
check_include_file(bsd/stdlib.h HAVE_BSD_STDLIB_H)
|
||||||
@@ -163,6 +182,7 @@ if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (HAVE_FCNTL_H)
|
if (HAVE_FCNTL_H)
|
||||||
check_symbol_exists(open "fcntl.h" HAVE_OPEN)
|
check_symbol_exists(open "fcntl.h" HAVE_OPEN)
|
||||||
@@ -201,7 +221,7 @@ endif()
|
|||||||
if (HAVE_SYS_RANDOM_H)
|
if (HAVE_SYS_RANDOM_H)
|
||||||
check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
|
check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
|
||||||
endif()
|
endif()
|
||||||
if (HAVE_SYS_RESOURCE_H)
|
if (HAVE_SYS_RESOURCE_H AND NOT AMIGA)
|
||||||
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
|
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -298,6 +318,9 @@ if ("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER
|
|||||||
if ("${DISABLE_WERROR}" STREQUAL "OFF")
|
if ("${DISABLE_WERROR}" STREQUAL "OFF")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||||
endif()
|
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} -Wall")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
|
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)
|
5. [Testing](#testing)
|
||||||
6. [Building with `vcpkg`](#buildvcpkg)
|
6. [Building with `vcpkg`](#buildvcpkg)
|
||||||
7. [Building for Android](#android)
|
7. [Building for Android](#android)
|
||||||
7. [Linking to libjson-c](#linking)
|
8. [Building for Commodore Amiga](#amiga)
|
||||||
8. [Using json-c](#using)
|
9. [Linking to libjson-c](#linking)
|
||||||
|
10. [Using json-c](#using)
|
||||||
|
|
||||||
<a name="overview"></a>
|
<a name="overview"></a>
|
||||||
JSON-C - A JSON implementation in C
|
JSON-C - A JSON implementation in C
|
||||||
@@ -270,6 +271,44 @@ cmake \
|
|||||||
make install
|
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>
|
<a name="linking"></a>
|
||||||
Linking to `libjson-c`
|
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
|
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)
|
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user