From d31d635af1bdaafcc5d5b27ea6374c5a2952e490 Mon Sep 17 00:00:00 2001 From: "Cameron Armstrong (Nightfox)" Date: Sat, 22 Jun 2024 18:49:50 +0800 Subject: [PATCH] Clean up CMakeLists.txt and remove Amiga specific locale.h guard --- .gitignore | 1 + CMakeLists.txt | 16 +++++++--------- README.md | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 4b7da9f2..e50a2834 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ *.save *.autosav *.autosave +.DS_Store # Tests /tests/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 41c0d89c..ed877e35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,17 +69,13 @@ 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 OR AMIGA) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) -endif() - if (${CMAKE_SYSTEM_NAME} STREQUAL "AmigaOS") 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) + set(DISABLE_STATIC_FPIC ON) if ($ENV{CROSS_PFX} STREQUAL "m68k-amigaos") set(AMIGA_M68K ON) set(BUILD_TESTING OFF) @@ -105,6 +101,10 @@ else() message(STATUS "Building for ${CMAKE_SYSTEM_NAME}") endif() +if (UNIX OR MINGW OR CYGWIN OR AMIGA) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +endif() + if (BUILD_SHARED_LIBS) add_definitions(-D JSON_C_DLL) endif() @@ -118,7 +118,7 @@ if (MSVC) list(APPEND CMAKE_REQUIRED_FLAGS /wd4996) endif() -if (NOT DISABLE_STATIC_FPIC AND NOT AMIGA) +if (NOT DISABLE_STATIC_FPIC) # 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 @@ -143,9 +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_M68K) - check_include_file("locale.h" HAVE_LOCALE_H) -endif() +check_include_file("locale.h" HAVE_LOCALE_H) check_include_file("memory.h" HAVE_MEMORY_H) check_include_file(stdint.h HAVE_STDINT_H) diff --git a/README.md b/README.md index f4a889c0..1327f3a5 100644 --- a/README.md +++ b/README.md @@ -282,34 +282,34 @@ Install Docker on your machine if you don't already have it. You can download Do ### To build for Motorola 68k Amiga: ``` -mkdir json-c-build +mkdir 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 +cd build cmake -DM68K_CRT=newlib .. make ``` -libjson-c.a will get created in the json-c-build directory. +libjson-c.a will get created in the 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: ``` -mkdir json-c-build +mkdir 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 +cd build cmake .. make ``` -libjson-c.a will get created in the json-c-build directory. +libjson-c.a will get created in the build directory. Linking to `libjson-c` -- 2.47.2