# -*- 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

name                monotone
subport             ${name}-devel {}
categories          devel
license             GPL-2+
maintainers         nomaintainer
description         Distributed version control system
long_description    ${name} is a free distributed version control system. It provides \
                    a simple, single-file transactional version store, with fully \
                    disconnected operation and an efficient peer-to-peer synchronization \
                    protocol. It understands history-sensitive merging, lightweight \
                    branches, integrated code review and 3rd-party testing.
homepage            http://www.monotone.ca

depends_build       port:gettext \
                    path:bin/pkg-config:pkgconfig
depends_lib-append  port:botan \
                    port:gettext-runtime \
                    port:libiconv \
                    port:libidn \
                    port:lua \
                    port:pcre \
                    port:sqlite3 \
                    port:zlib

if {${name} eq ${subport}} {
    PortGroup           obsolete 1.0

    version             1.1
    revision            8

    replaced_by         monotone-devel
} else {
    PortGroup           boost 1.0
    PortGroup           conflicts_build 1.0

    boost.version       1.81

    version             20180227
    set commit          880df7b506faa1ac84871b84629616a66bc02b84
    revision            4

    master_sites        https://code.monotone.ca/p/monotone/source/download/${commit}/?dummy=
    distname            monotone-${commit}
    use_zip             yes

    checksums           rmd160  262e74f4998f7234db7757eb1b20e5ce0e83acda \
                        sha256  593b186d0b3168eb12b1a14f471929a5d3bebad367bfff5f59d870e29e35f5d2 \
                        size    6167787

    extract.mkdir       yes

    # Build can opportunistically link to botan1, avoid that:
    conflicts_build     botan1

    patchfiles-append   patch-botan2.5.diff \
                        patch-botan2.9.diff \
                        patch-float128.diff \
                        patch-cstdlib.diff \
                        patch-pid_t.diff

    use_autoreconf      yes

    compiler.cxx_standard   2011
    configure.cxxflags-append \
                        -std=c++11
    # Picked from Mac-specific insrtructions:
    platform darwin powerpc {
        configure.cxxflags-append \
                        -mdynamic-no-pic
    }
}

patchfiles-append   monotone-1.1-Adapt-to-changes-in-pcre-8.42.patch

# Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
# 0x9222ca8c in typeinfo name for std::locale::facet ()
# See: https://stackoverflow.com/questions/19405272/c-issues-with-boostfilesystem-on-server-localefacet-s-create-c-locale
build.env-append    LC_ALL=C
destroot.env-append LC_ALL=C
test.env-append     LC_ALL=C

# botan is not universal
universal_variant   no

test.run            yes
test.target         check

notes "
Monotone needs LC_ALL defined in the environment. Run `export LC_ALL=C` if it is not.
"
