# -*- 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           compiler_blacklist_versions 1.0
PortGroup           github 1.0

github.setup        ocaml opam 2.1.6

name                opam
revision            1
categories          ocaml sysutils
license             LGPL-2
maintainers         {@pmetzger pmetzger} openmaintainer
homepage            http://opam.ocaml.org/
description         OPAM is a package manager for OCaml
long_description    OPAM is a source-based package manager for OCaml.\
                    It supports multiple simultaneous compiler installations,\
                    flexible package constraints, and a Git-friendly\
                    development workflow.

github.tarball_from releases
distname            opam-full-${version}

checksums           rmd160  734abf1551d55f29b34a97e2bf64e7cd9cc9fd8b \
                    sha256  d2af5edc85f552e0cf5ec0ddcc949d94f2dc550dc5df595174a06a4eaf8af628 \
                    size    11704198

depends_build       port:ocaml
# Opam upgrade uses patch to update the package repository,
# this can silently fail with macos patch when files are
# deleted upstream.
depends_lib         port:gpatch

# This prevents configure from trying to use a program to fetch dependencies.
# We don't need or want one.
configure.env-append  FETCH=no

# * patch-stop-fetch-check.diff dikes out a test that will prevent us
#   from disabling fetch. Otherwise FETCH=no will fail and we'll need to
#   depend on curl or wget.
# * patch-makefile.diff is a kludge to put documentation files into
#   share/doc/opam-installer -- without this, they'd end up in
#   doc/opam-installer, and there is no /opt/local/doc.
patchfiles          patch-stop-fetch-check.diff \
                    patch-makefile.diff

use_parallel_build  no
build.target        lib-ext all

# Match OCaml settings:
compiler.blacklist  *gcc-4.0 *gcc-4.2 {clang < 400}

if {[string match *gcc* ${configure.compiler}]} {
    # Temporary fix for:
    # https://github.com/ocaml-opam/ocaml-mccs/issues/51
    # https://github.com/ocaml/dune/issues/949
    configure.args-append \
                    --without-mccs
}

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    # Matching ocaml 1.1 PG setting.
    # See: https://github.com/ocaml/dune/issues/8941
    build.env-append \
                    DUNE_CONFIG__COPY_FILE=portable
}
