From 888ffa4ee03ec77c19a998605c2cabb3388e671f Mon Sep 17 00:00:00 2001 From: Vatsal Keshav <157686413+vats004@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:14:08 +0530 Subject: [PATCH] fix prepoc dir for compilation on mac silicon - autogen, cmake, build.command (#1688) Co-authored-by: vats004 <=> --- docs/COMPILATION.MD | 1 + src/thirdparty/libpng/pngpriv.h | 16 +++++++++++----- src/thirdparty/zlib/zutil.h | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/COMPILATION.MD b/docs/COMPILATION.MD index 8a8f1d0a..17212102 100644 --- a/docs/COMPILATION.MD +++ b/docs/COMPILATION.MD @@ -133,6 +133,7 @@ Dependencies can be installed via Homebrew as: ```bash brew install pkg-config brew install autoconf automake libtool +brew install cmake gpac # optional if you want OCR: brew install tesseract brew install leptonica diff --git a/src/thirdparty/libpng/pngpriv.h b/src/thirdparty/libpng/pngpriv.h index e2b1ca33..d42593f0 100644 --- a/src/thirdparty/libpng/pngpriv.h +++ b/src/thirdparty/libpng/pngpriv.h @@ -506,8 +506,7 @@ # define png_aligncastconst(type, value) ((const void*)(value)) #endif /* __cplusplus */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) || defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) /* png.c requires the following ANSI-C constants if the conversion of * floating point to ASCII is implemented therein: * @@ -515,10 +514,13 @@ * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) * DBL_MAX Maximum floating point number (can be set to an arbitrary value) */ + # include -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) + /* Handle floating-point headers depending on the platform */ +# if ((defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)) && \ + !(defined(__APPLE__) && defined(__MACH__)) // this if block gets executed for older macOS versions /* We need to check that hasn't already been included earlier * as it seems it doesn't agree with , yet we should really use * if possible. @@ -526,15 +528,19 @@ # if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) # include # endif -# else +# else // this if block gets executed for newer macOS versions(Ventura/Sonoma/Sequoia) OR other platforms + /* if (defined(__APPLE__) && defined(__MACH__)) or other cases */ + /* Include math.h for macOS and all other platforms */ # include # endif + # if defined(_AMIGA) && defined(__SASC) && defined(_M68881) /* Amiga SAS/C: We must include builtin FPU functions when compiling using * MATH=68881 */ # include # endif + #endif /* This provides the non-ANSI (far) memory allocation routines. */ diff --git a/src/thirdparty/zlib/zutil.h b/src/thirdparty/zlib/zutil.h index b079ea6a..6a3eb12a 100644 --- a/src/thirdparty/zlib/zutil.h +++ b/src/thirdparty/zlib/zutil.h @@ -130,7 +130,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#if defined(MACOS) || defined(TARGET_OS_MAC) +#if defined(MACOS) // for older macOS # define OS_CODE 7 # ifndef Z_SOLO # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os @@ -141,6 +141,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif # endif # endif +#elif defined(__MACH__) && defined(__APPLE__) && defined(TARGET_OS_MAC) // for newer macOS(Ventura/Sonoma/Sequoia) +// do nothing because fdopen is defined already by XCode command-line-tools in these macOS versions #endif #ifdef __acorn