# -*- 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
# $Id: Portfile 119056 2014-04-15 21:48:38Z macsforever2000@macports.org $

PortSystem              1.0
PortGroup muniversal    1.0

name                    ossp-uuid
version                 1.6.2
revision                2
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

patchfiles              patch-Makefile.in.diff

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

default_variants        +perl5_16

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 {
    # avoid conflict with libc-headers
    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
}

variant perl5_12 conflicts perl5_14 perl5_16 perl5_18 description {Perl bindings with perl 5.12} {
    depends_build-append   port:perl5.12
    configure.args-delete   --without-perl
    configure.args-append   --with-perl --with-perl-compat
    configure.env-append   PERL=${prefix}/bin/perl5.12
    patchfiles-append      patch-uuid-uuid.h.in.diff
}

variant perl5_14 conflicts perl5_12 perl5_16 perl5_18 description {Perl bindings with perl 5.14} {
    depends_build-append   port:perl5.14
    configure.args-delete   --without-perl
    configure.args-append   --with-perl --with-perl-compat
    configure.env-append   PERL=${prefix}/bin/perl5.14
    patchfiles-append      patch-uuid-uuid.h.in.diff
}

variant perl5_16 conflicts perl5_12 perl5_14 perl5_18 description {Perl bindings with perl 5.16} {
    depends_build-append   port:perl5.16
    configure.args-delete   --without-perl
    configure.args-append   --with-perl --with-perl-compat
    configure.env-append   PERL=${prefix}/bin/perl5.16
    patchfiles-append      patch-uuid-uuid.h.in.diff
}

variant perl5_18 conflicts perl5_12 perl5_14 perl5_16 description {Perl bindings with perl 5.18} {
    depends_build-append   port:perl5.18
    configure.args-delete   --without-perl
    configure.args-append   --with-perl --with-perl-compat
    configure.env-append   PERL=${prefix}/bin/perl5.18
    patchfiles-append      patch-uuid-uuid.h.in.diff
}

test.run                yes
test.target             check

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