# -*- 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           conflicts_build 1.0
PortGroup           legacysupport 1.1
PortGroup           openssl 1.0

openssl.branch      1.0
openssl.configure   build_flags
# clock_gettime for rdtsc
legacysupport.newest_darwin_requires_legacy 15

name                virtuoso-7
set myname          virtuoso
version             7.2.10
revision            3
categories          devel
maintainers         {snc @nerdling} openmaintainer
license             GPL
description         High-performance object-relational SQL database
long_description    Virtuoso is an enterprise-grade server that delivers a platform \
                    for Data Access, Integration and Management.
homepage            http://${myname}.openlinksw.com/dataspace/dav/wiki/Main/
master_sites        sourceforge:project/${myname}/${myname}/${version}
distname            ${myname}-opensource-${version}

checksums           rmd160  a7d1d7c7333b3e125543a70c4644b36de8f7da45 \
                    sha256  c02b0a966ff33f854a86f8f74caa8a5a957e22b510cc2f808e54ed34b4b27f0f \
                    size    121992638

# https://trac.macports.org/ticket/61216
patchfiles-append   patch-libsrc-Wi-numeric.c.diff

# Allow 32-bit:
patchfiles-append   patch-relax-bitness.diff

# https://github.com/openlink/virtuoso-opensource/issues/1107
patchfiles-append   patch-wifn.h.diff
patchfiles-append   patch-Dkbox.h.diff

# This assumes legacy-support is being used:
patchfiles-append   patch-Dkutil.c.diff

# cetop.c:1786: error: expected ';' before 'ce_first'
# ceins.c:369: error: lvalue required as left operand of assignment
patchfiles-append   patch-col.h.diff \
                    patch-ceins.c.diff

# chash.c:3170:74: error: macro "memcmp_dt" passed 3 arguments, but takes just 2
patchfiles-append   patch-date.h.diff

# colsearch.c:222: warning: implicit declaration of function 'memcmp_8l'
patchfiles-append   patch-Dkword.h.diff

# Fix a wrong declaration:
patchfiles-append   patch-viconfig.c.diff

conflicts           virtuoso-6 virtuoso-5
conflicts_build     chicken geos

depends_build-append \
                    port:bison \
                    port:gawk \
                    path:bin/git:git

depends_lib-append  port:ImageMagick \
                    port:libxml2 \
                    path:lib/libldap.dylib:openldap \
                    port:zlib

if {[string match macports-gcc* ${configure.compiler}] || \
    [string match *clang* ${configure.compiler}]} {
    configure.cflags-append \
                    -Wno-error=implicit-function-declaration \
                    -Wno-error=incompatible-pointer-types \
                    -Wno-error=implicit-int \
                    -Wno-error=int-conversion
}

configure.args-append   --disable-all-vads \
                        --disable-silent-rules \
                        --program-transform-name='s/isql/isql-vt/\;s/isqlw/isqlw-vt/' \
                        --without-internal-zlib

post-configure {
    reinplace "s|\"gcc\"|\"${configure.cc}\"|" ${worksrcpath}/bin/libtool.macosx
    foreach note $PortInfo(notes) {
        ui_msg $note
    }
}

post-build {
    touch ${worksrcpath}/docsrc/html_virt/test.html
}

pre-activate {
    if {[file exists ${prefix}/bin/inifile]
        && ![catch {set vers [lindex [registry_active $myname ] 0]}]} {
        registry_deactivate_composite ${myname} "" [list ports_nodepcheck 1]
    }
}

notes "
Some antivirus software can cause the virtuoso build to hang indefinitely.\
If you have any antivirus software installed, please disable it while\
building virtuoso; it can be re-enabled after virtuoso has been installed.
"

livecheck.url       http://sourceforge.net/api/file/index/project-id/161622/mtime/desc/rss?path=/virtuoso
livecheck.type      regex
livecheck.regex     ${myname}/(\\d+(\\.\\d+)+)/${myname}-opensource-(\\d+(\\.\\d+)+)
