From 2394f768be859524609b50a8b4923c77394a4e0f Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sat, 6 Jul 2024 23:07:58 +0800 Subject: [PATCH] ocaml-core_unix: use legacysupport correctly --- ocaml/ocaml-core_unix/Portfile | 7 ++++- ...er_stubs.c-add-legacysupport-header-.patch | 28 +++---------------- ...c-add-legacysupport-header-for-strnl.patch | 28 ++----------------- 3 files changed, 13 insertions(+), 50 deletions(-) diff --git a/ocaml/ocaml-core_unix/Portfile b/ocaml/ocaml-core_unix/Portfile index 7fde488d8a12f..76435fbf8ff65 100755 --- a/ocaml/ocaml-core_unix/Portfile +++ b/ocaml/ocaml-core_unix/Portfile @@ -33,11 +33,16 @@ depends_lib-append port:ocaml-core \ port:ocaml-spawn \ port:ocaml-timezone -# FIXME: review the following. patch.pre_args-replace -p0 -p1 if {${os.platform} eq "darwin" && ${os.major} < 16} { patchfiles 0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch \ 0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch + + post-patch { + reinplace "s|@PREFIX@|${prefix}|g" \ + ${worksrcpath}/core_unix/src/dune \ + ${worksrcpath}/time_stamp_counter/src/dune + } } ocaml.build_type dune diff --git a/ocaml/ocaml-core_unix/files/0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch b/ocaml/ocaml-core_unix/files/0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch index 0024fe67b9a3e..a38ffe6f181d5 100644 --- a/ocaml/ocaml-core_unix/files/0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch +++ b/ocaml/ocaml-core_unix/files/0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch @@ -4,35 +4,15 @@ Date: Mon, 21 Nov 2022 01:08:19 +0800 Subject: [PATCH 1/2] time_stamp_counter_stubs.c: add legacysupport header for clock_gettime ---- - time_stamp_counter/src/time_stamp_counter_stubs.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/time_stamp_counter/src/time_stamp_counter_stubs.c b/time_stamp_counter/src/time_stamp_counter_stubs.c -index 5d5ec32..1cf0ee1 100644 ---- a/time_stamp_counter/src/time_stamp_counter_stubs.c -+++ b/time_stamp_counter/src/time_stamp_counter_stubs.c -@@ -17,6 +17,11 @@ - #ifdef __MACH__ - #include - #include -+ -+#include -+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 -+#include -+#endif - #endif - - #include "ocaml_utils.h" - --- a/time_stamp_counter/src/dune 2023-04-25 21:12:26.000000000 +0800 -+++ b/time_stamp_counter/src/dune 2023-10-25 20:10:11.000000000 +0800 ++++ b/time_stamp_counter/src/dune 2024-07-06 22:52:24.000000000 +0800 @@ -1,7 +1,7 @@ (library (name time_stamp_counter) (public_name core_unix.time_stamp_counter) (preprocess (pps ppx_jane ppx_optcomp)) (preprocessor_deps config.h) - (c_names time_stamp_counter_stubs) -+ (c_names time_stamp_counter_stubs) (c_library_flags -lMacportsLegacySupport) - (libraries core core_unix ocaml_intrinsics)) +- (libraries core core_unix ocaml_intrinsics)) ++ (c_names time_stamp_counter_stubs) (c_flags -I@PREFIX@/include/LegacySupport) ++ (c_library_flags -lMacportsLegacySupport) (libraries core core_unix ocaml_intrinsics)) (rule (targets config.h) (deps) - (action (bash "cp %{lib:jst-config:config.h} %{targets}"))) diff --git a/ocaml/ocaml-core_unix/files/0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch b/ocaml/ocaml-core_unix/files/0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch index 72d9aca66266f..5c29ba06b14e5 100644 --- a/ocaml/ocaml-core_unix/files/0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch +++ b/ocaml/ocaml-core_unix/files/0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch @@ -3,37 +3,15 @@ From: barracuda156 Date: Mon, 21 Nov 2022 01:13:02 +0800 Subject: [PATCH 2/2] core_unix_stubs.c: add legacysupport header for strnlen ---- - core_unix/src/core_unix_stubs.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/core_unix/src/core_unix_stubs.c b/core_unix/src/core_unix_stubs.c -index 4beba77..20976d2 100644 ---- a/core_unix/src/core_unix_stubs.c -+++ b/core_unix/src/core_unix_stubs.c -@@ -64,6 +64,13 @@ - #include - #endif - -+#if defined(__APPLE__) -+#include -+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1060 -+#include -+#endif -+#endif -+ - CAMLprim value core_unix_error_of_code(value code) - { - return unix_error_of_code(Int_val(code)); - --- a/core_unix/src/dune 2023-04-25 21:12:26.000000000 +0800 -+++ b/core_unix/src/dune 2023-10-25 20:09:45.000000000 +0800 ++++ b/core_unix/src/dune 2024-07-06 22:50:49.000000000 +0800 @@ -1,10 +1,10 @@ (library (name core_unix) (public_name core_unix) (libraries core error_checking_mutex core_kernel.flags sexplib.unix - signal_unix spawn) +- (c_flags (:standard -D_LARGEFILE64_SOURCE) ()) + signal_unix spawn) (c_library_flags -lMacportsLegacySupport) - (c_flags (:standard -D_LARGEFILE64_SOURCE) ()) ++ (c_flags (:standard -D_LARGEFILE64_SOURCE) -I@PREFIX@/include/LegacySupport ()) (c_names nss_stubs timespec core_unix_stubs core_unix_time_stubs) (preprocess (pps ppx_jane ppx_optcomp)) (preprocessor_deps config.h))