# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
PortSystem          1.0

name                alliance
version             5.0-20110203
revision            3
license             GPL
set version_number  [lindex [split ${version} -] 0]
categories          science
maintainers         nomaintainer
description         Alliance, CAD and libraries for VLSI design
long_description    Alliance is a complete set of free CAD tools and portable libraries for \
                    VLSI design. It includes a VHDL compiler and simulator, logic synthesis \
                    tools, and automatic place and route tools. A complete set of portable \
                    CMOS libraries is provided
homepage            https://www-soc.lip6.fr/equipe-cian/logiciels/alliance/

master_sites        ftp://asim.lip6.fr/pub/alliance/distribution/latest

checksums           rmd160  be9554ae1c84c1f6d4cd49bf19e2fe997d9ec27b \
                    sha256  32bb4634921aacaf620ae337433cbaf16171b950fadab8111325501962278fb1 \
                    size    8112254

depends_build       port:bison \
                    port:autoconf
depends_lib         port:xpm \
                    port:motif

worksrcdir          ${name}-${version_number}

patchfiles          patch-distrib-etc-Makefile.in.diff fix-compilation.diff

use_parallel_build  no

configure.args-append   --mandir=${prefix}/share/man
configure.cflags-append -std=c99
configure.env-append    ALLIANCE_TOP=${prefix}
build.env               LC_ALL=C

# compiler_issue
if {[string match *clang* ${configure.compiler}]} {
    # Missing return statements should really be fixed.
    # If you care about this port, fix the real issue...
    configure.cflags-append -Wno-return-type
}

if {[string match *clang* ${configure.compiler}] ||
    [string match *llvm-gcc-4.2* ${configure.compiler}]} {
    # removing -O2 in nero/src in order to correctly export symbols in MDRGrid.o
    # cf. http://llvm.org/bugs/show_bug.cgi?id=7445
    # cf. http://trac.macports.org/ticket/32947#comment:3
    post-configure {
        reinplace "/^CXXFLAGS/s/ -O2//" ${worksrcpath}/nero/src/Makefile
    }
}

# The aux scripts are too old to know that aarch64-darwin is a thing.
pre-configure {
    file copy -force ${prefix}/share/autoconf/build-aux/config.guess ${worksrcpath}/config.guess
    file copy -force ${prefix}/share/autoconf/build-aux/config.sub   ${worksrcpath}/config.sub
}

post-destroot {
    file mkdir  ${destroot}${prefix}/share/alliance
    file rename ${destroot}${prefix}/doc        ${destroot}${prefix}/share/alliance
    file rename ${destroot}${prefix}/examples   ${destroot}${prefix}/share/alliance
    file rename ${destroot}${prefix}/tutorials  ${destroot}${prefix}/share/alliance
    file rename ${destroot}${prefix}/cells      ${destroot}${prefix}/share/alliance
}

platform darwin {
    patchfiles-append patch-xgra-src-XSB_parse.c.diff
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}-(\[0-9.-\]+)\\.tar
