# -*- 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               muniversal 1.0
PortGroup               perl5 1.0

name                    ossp-uuid
version                 1.6.2
revision                11
categories              devel
license                 MIT
platforms               darwin
maintainers             nomaintainer

description             ISO-C API and CLI for generating Universally Unique Identifiers
long_description        OSSP uuid is a ISO-C:1999 application programming interface (API) \
                        and corresponding command line interface (CLI) for the generation \
                        of DCE 1.1, ISO/IEC 11578:1996 and RFC 4122 compliant Universally \
                        Unique Identifier (UUID). It supports DCE 1.1 variant UUIDs of \
                        version 1 (time and node based), version 3 (name based, MD5), \
                        version 4 (random number based) and version 5 (name based, SHA-1). \
                        Additional API bindings are provided for the languages ISO-C++:1998, \
                        Perl:5 and PHP:4/5. Optional backward compatibility exists for the \
                        ISO-C DCE-1.1 and Perl Data::UUID APIs.

homepage                http://www.ossp.org/pkg/lib/uuid/
master_sites            ftp://ftp.ossp.org/pkg/lib/uuid/ freebsd
distname                uuid-${version}

checksums               rmd160  f9cd513577557c4f1d7de869f80035b8844b56d7 \
                        sha256  11a615225baa5f8bb686824423f50e4427acd3f70d394765bdff32801f0fd5b0 \
                        size    397048

patchfiles              patch-Makefile.in.diff \
                        patch-uuid.pc.in.diff

configure.args          --without-perl \
                        --without-php \
                        --without-pgsql \
                        --includedir=${prefix}/include/ossp

if {[variant_isset universal]} {
    if { ${os.arch} eq "i386" } {
        if { ${os.major} >= 10 } {
            set merger_configure_env(ppc) ac_cv_va_copy=yes
        }
        set merger_configure_env(ppc64)   ac_cv_va_copy=yes
    } else {
        set merger_configure_env(i386)    ac_cv_va_copy=yes
        set merger_configure_env(x86_64)  ac_cv_va_copy=yes
    }

    post-configure {
        set all_archs ""
        foreach arch ${universal_archs_to_use} {
            lappend all_archs -arch ${arch}
        }

        # When uuid-config is asked about cflags and ldflags, have all architectures give the same answer.
        foreach arch ${universal_archs_to_use} {
            reinplace "s|-arch \[a-z0-9_\]*|${all_archs}|"  ${worksrcpath}-${arch}/uuid-config
            reinplace "s|-m32|${all_archs}|"                ${worksrcpath}-${arch}/uuid-config
            reinplace "s|-m64|${all_archs}|"                ${worksrcpath}-${arch}/uuid-config
        }
    }
}

post-destroot {
    file rename -force ${destroot}${prefix}/share/man/man3/uuid.3 ${destroot}${prefix}/share/man/man3/ossp-uuid.3
    file rename -force ${destroot}${prefix}/share/man/man1/uuid.1 ${destroot}${prefix}/share/man/man1/ossp-uuid.1
    file rename -force ${destroot}${prefix}/share/man/man1/uuid-config.1 ${destroot}${prefix}/share/man/man1/ossp-uuid-config.1

    if {[variant_isset perl5_26]} {
        delete {*}[glob ${destroot}${prefix}/lib/perl5/*/*/perllocal.pod]
    }
}

# use perl5 port group to create variants
# perl support is possibly required by dependents rpm5[234] (unverified)

perl5.conflict_variants yes
perl5.branches 5.26 5.28
perl5.create_variants ${perl5.branches}

# Perl is used as an interpreter only
foreach branch ${perl5.branches} {
    license_noconflict perl${branch}
}

if {[variant_isset perl5_26] || [variant_isset perl5_28]} {
    configure.perl          ${perl5.bin}
    configure.args-delete   --without-perl
    configure.args-append   --with-perl --with-perl-compat
    patchfiles-append       patch-uuid-uuid.h.in.diff
}

test.run                yes
test.target             check

conflicts               libuuid

livecheck.type          regex
livecheck.regex         "Stable Version:\[^\\d]*(\\d+(?:\\.\\d+)*)"