# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           ocaml 1.1

# Upstream rewrote the bindings with a dune build system and modern OCaml C API.
# The pre-1.20 ocamlgsl distribution is no longer maintained and fails to build
# with OCaml >= 4.10 (caml__frame removed from the C runtime API).
github.setup        mmottl gsl-ocaml 1.25.1
github.tarball_from archive
name                ocaml-gsl
revision            0
categories          math science ocaml
license             GPL-3
maintainers         nomaintainer

description         GSL (GNU Scientific Library) bindings for OCaml
long_description    gsl-ocaml provides OCaml bindings for the GSL \
                    (GNU Scientific Library), giving access to algorithms \
                    for optimization, differential equations, statistics, \
                    random number generation, linear algebra, and more.

homepage            https://mmottl.github.io/gsl-ocaml

checksums           rmd160  6f8028313961259b2236b63ece937b4e7cd5ca92 \
                    sha256  20a7a96cbe1adf54be6bc3da94ec04c8a253baf7b9a4f7c361b03f55162d3eb9 \
                    size    115294

ocaml.build_type    dune

# patch discover.ml to use GSL_INCLUDE_DIR env var as fallback when
# pkg-config does not return a -I flag (e.g. when GSL headers are in
# ${prefix}/include rather than /usr/include)
patchfiles-append   patch-discover-gsl-include.diff

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:gsl \
                    port:ocaml-dune-configurator

# Ensure dune-configurator can locate GSL via pkg-config; GSL_INCLUDE_DIR
# is used by the patched discover.ml as a fallback include path.
dune.build.env-append \
                    PKG_CONFIG_PATH=${prefix}/lib/pkgconfig \
                    GSL_INCLUDE_DIR=${prefix}/include
