]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Get working ror libnix and clib2
authorCameron Armstrong <cameronscottarmstrong@gmail.com>
Wed, 27 Dec 2023 23:53:32 +0000 (07:53 +0800)
committerCameron Armstrong (Nightfox) <cameronscottarmstrong@gmail.com>
Tue, 24 Dec 2024 02:09:50 +0000 (10:09 +0800)
CMakeLists.txt
README.md
apps/CMakeLists.txt

index bba3b7b08635278af86358f7d60bed3082f15e11..41c0d89c1090b71c93678a7baae9523099169c81 100644 (file)
@@ -45,10 +45,6 @@ include(CMakePackageConfigHelpers)
 option(BUILD_SHARED_LIBS  "Default to building shared libraries" ON)
 option(BUILD_STATIC_LIBS  "Default to building static libraries" ON)
 
-if (BUILD_SHARED_LIBS)
-    add_definitions(-D JSON_C_DLL)
-endif()
-
 # Generate a release merge and test it to verify the correctness of republishing the package.
 ADD_CUSTOM_TARGET(distcheck
 COMMAND make package_source
@@ -73,20 +69,34 @@ option(DISABLE_JSON_PATCH             "Disable JSON patch (RFC6902) support."
 option(NEWLOCALE_NEEDS_FREELOCALE     "Work around newlocale bugs in old FreeBSD by calling freelocale"  OFF)
 option(BUILD_APPS                     "Default to building apps" ON)
 
-
-if (UNIX OR MINGW OR CYGWIN)
+if (UNIX OR MINGW OR CYGWIN OR AMIGA)
     list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
 endif()
 
 if (${CMAKE_SYSTEM_NAME} STREQUAL "AmigaOS")
-    set(AMIGA 1)
+    set(AMIGA ON)
     set(DISABLE_THREAD_LOCAL_STORAGE ON)
     set(ENABLE_THREADING OFF)
+    set(BUILD_SHARED_LIBS OFF)
+    set(BUILD_APPS OFF)
+    list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
     if ($ENV{CROSS_PFX} STREQUAL "m68k-amigaos")
-        set(AMIGA_M68K 1)
+        set(AMIGA_M68K ON)
+        set(BUILD_TESTING OFF)
         message(STATUS "Building for Motorola 68k AmigaOS")
+        if (${M68K_CRT} STREQUAL "newlib")
+            set(NEWLIB ON)
+        elseif(${M68K_CRT} STREQUAL "clib2")
+            set(CLIB2 ON)
+        elseif(${M68K_CRT} STREQUAL "nix20")
+            set(NIX20 ON)
+        elseif(${M68K_CRT} STREQUAL "nix13")
+            set(NIX13 ON)
+        else()
+            set(NEWLIB ON)
+        endif()
     elseif ($ENV{CROSS_PFX} STREQUAL "ppc-amigaos")
-        set(AMIGA_PPC 1)
+        set(AMIGA_PPC ON)
         message(STATUS "Building for PowerPC AmigaOS")
     else()
         message(FATAL_ERROR "Unsupported AmigaOS target")
@@ -95,6 +105,10 @@ else()
     message(STATUS "Building for ${CMAKE_SYSTEM_NAME}")
 endif()
 
+if (BUILD_SHARED_LIBS)
+    add_definitions(-D JSON_C_DLL)
+endif()
+
 if (UNIX OR AMIGA)
     list(APPEND CMAKE_REQUIRED_LIBRARIES   m)
 endif()
@@ -129,7 +143,7 @@ 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)
-if (NOT AMIGA)
+if (NOT AMIGA_M68K)
     check_include_file("locale.h"       HAVE_LOCALE_H)
 endif()
 check_include_file("memory.h"       HAVE_MEMORY_H)
@@ -169,17 +183,17 @@ 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)
-if (NOT AMIGA)
+if (NOT AMIGA_M68K)
     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()
+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()
@@ -221,7 +235,7 @@ endif()
 if (HAVE_SYS_RANDOM_H)
     check_symbol_exists(getrandom   "sys/random.h" HAVE_GETRANDOM)
 endif()
-if (HAVE_SYS_RESOURCE_H AND NOT AMIGA)
+if (HAVE_SYS_RESOURCE_H)
     check_symbol_exists(getrusage   "sys/resource.h" HAVE_GETRUSAGE)
 endif()
 
index b974bd4ce3bddb7ce014783a0b9d90039efc4742..60f3b93ba1fce617bbdf66a718486177b078515f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -288,12 +288,14 @@ docker run --rm \
     -e USER=$( id -u ) -e GROUP=$( id -g ) \
     -it  sacredbanana/amiga-compiler:m68k-amigaos bash
 cd json-c-build
-cmake ..
+cmake -DM68K_CRT=newlib ..
 make
 ```
 
 libjson-c.a will get created in the json-c-build directory.
 
+You can change newlib to nix20, nix13 or clib2 if you would like to build the library suited for libnix or clib2 instead. Newlib is default.
+
 To build for PowerPC Amiga:
 
 ```
index c278b025ed4d48c500884e538efaaced54f4cf59..f7c9dec633918c320afaf1fa8f56143b4ba51156 100644 (file)
@@ -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 AND NOT AMIGA)
+if (HAVE_SYS_RESOURCE_H)
     check_symbol_exists(getrusage   "sys/resource.h" HAVE_GETRUSAGE)
 endif()