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

name                magic
version             8.3.508
revision            1
checksums           rmd160  f034a75cb02e22b72cf0f5748029bb06e570a259 \
                    sha256  efd23c5b6de4da25868964f1f1e6e4e2229d8ee82f1bfa795e6c2cbfb48e46ab \
                    size    3762537

set branch          [join [lrange [split ${version} .] 0 1] .]
categories          science
# mostly very permissively licensed, but includes a copy of GNU readline
license             GPL-2+
maintainers         {ryandesign @ryandesign} openmaintainer

description         A VLSI Layout System

long_description    Magic is a venerable VLSI layout tool, written in the \
                    1980's at Berkeley. Magic is widely cited as being the \
                    easiest tool to use for circuit layout, even for people \
                    who ultimately rely on commercial tools for their product \
                    design flow.

homepage            http://opencircuitdesign.com/magic/
master_sites        ${homepage}archive/

extract.suffix      .tgz

depends_lib         port:blt \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:libGLU \
                    port:mesa \
                    port:tcl \
                    port:tk-x11 \
                    port:xorg-libice \
                    port:xorg-libXi \
                    port:xorg-libXmu \
                    port:zlib

universal_variant   no

conflicts_build     gnome-keyring

configure.dir       ${worksrcpath}/scripts

if {${os.platform} eq "darwin" && ${os.major} < 19} {
    set python_version 3.12
    depends_build-append \
                    port:python[string map {. {}} ${python_version}]
    configure.python \
                    ${prefix}/bin/python${python_version}
} else {
    configure.python \
                    /usr/bin/python3
}

configure.args-append \
                    ac_cv_path_PYTHON3=${configure.python} \
                    --with-tk=${prefix}/lib/tk-x11 \
                    --with-tkincls=${prefix}/include/tk-x11 \
                    --with-tklibs=${prefix}/lib/tk-x11 \
                    --with-wish=${prefix}/libexec/tk-x11/wish

use_parallel_build  no

build.env           X11_LDFLAGS=-L${prefix}/lib

# Avoid this build system's nonstandard behavior of hiding the real
# build output in a make.log file, hiding the install output in an
# install.log file, and returning a successful exit code even when
# the build fails.
build.target        tcllibrary
destroot.target     install-tcl-real

# TODO: Build fails in trace mode due to MacPorts base bug?
# https://trac.macports.org/ticket/63359

livecheck.type      regex
livecheck.url       ${homepage}download.html
livecheck.regex     ${name}-(\[0-9.\]+)[quotemeta ${extract.suffix}]
