; cross-compiled GMP

(library
 (name gmp)
 (public_name gmp)
 (install_c_headers gmp)
 (foreign_archives gmp))

(install
 (files
  (dllgmp.so as libgmp.so))
 (section lib))

(rule
 (targets gmp.h libgmp.a dllgmp.so)
 (deps gmp-6.3.0.tar.xz build.sh gcc.15.patch)
 (action
  (with-stdout-to
   build.log
   (run sh ./build.sh "%{ocaml-config:c_compiler}" "%{ocaml-config:host}"
     "%{ocaml-config:target}" "%{ocaml-config:ocamlc_cflags}"
     %{ocaml-config:supports_shared_libraries}
     "%{ocaml-config:native_c_libraries}"))))

(rule
 (target build.sh)
 (deps build.sh.in)
 (mode fallback)
 (action
  (bash
    "CORES=`(which nproc > /dev/null 2>&1 && nproc) || sysctl -n hw.ncpu 2> /dev/null || echo 1`; sed \"s/\%{jobs}%/$CORES/g\" %{target}.in > %{target}")))
