# -*- 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           github 1.0
PortGroup           makefile 1.0

# The MacPorts tracked "version number" for this port includes the
# tag suffix, e.g. 9.5.24b.  This matches the upstream tag labeling.

github.setup        gtownsend icon 9.5.25 v a
revision            0
version             ${github.version}${github.tag_suffix}
github.tarball_from archive

categories          lang
maintainers         laposte.net:michael.grunewald openmaintainer
license             public-domain

description         The Icon Programming Language
long_description    Icon is a high-level, general-purpose programming \
                    language with a large repertoire of features for \
                    processing data structures and character strings. \
                    Icon is an imperative, procedural language with a \
                    syntax reminiscent of C and Pascal, but with \
                    semantics at a much higher level.

homepage            https://www.cs.arizona.edu/icon/

checksums           rmd160  7dd9f0905694292053a835f3929744abb281c91a \
                    sha256  ab15b7fc5a96e8b4da1b76cc6c7935400879f8a54b0fcf94a947c02815f21006 \
                    size    3086255

universal_variant   no
use_parallel_build  no

# Create a custom MacPorts "Makedefs" file for the Icon build system.
# Overwrite the original version in icon-source/config/macintosh/Makedefs.

set SYS_NAME        macintosh

post-extract {
    ui_debug "Create custom config/${SYS_NAME}/Makedefs file for MacPorts."
    set makedefs [open ${worksrcpath}/config/${SYS_NAME}/Makedefs "w"]
    puts ${makedefs} "CC     = ${configure.cc}"
    puts ${makedefs} "CFLAGS = ${configure.cflags}"
    puts ${makedefs} "CFDYN  ="
    puts ${makedefs} "RLINK  = ${configure.ldflags}"
    puts ${makedefs} "RLIBS  ="
    puts ${makedefs} "TLIBS  ="
    puts ${makedefs} "XLIBS  = -lXpm -lX11"
    puts ${makedefs} "SFLAGS ="
    close ${makedefs}
}

use_configure       yes
configure.cmd       make
configure.pre_args
configure.args      Configure name=${SYS_NAME}

build.target        All

destroot.target     Install
destroot.destdir    dest=${destroot}${prefix}/libexec/${name}

post-destroot {
    foreach prog {icon icont iconx vib} {
        ln -s ../libexec/${name}/bin/${prog} ${destroot}${prefix}/bin
    }
    set doc_dir ${destroot}${prefix}/share/doc
    xinstall -d ${doc_dir}
    ln -s ../../libexec/${name}/doc ${doc_dir}/${name}-${version}
    set man1_dir ${destroot}${prefix}/share/man/man1
    xinstall -d ${man1_dir}
    ln -s ../../../libexec/${name}/man/man1/icon.1 ${man1_dir}
    ln -s ../../../libexec/${name}/man/man1/icont.1 ${man1_dir}
}

default_variants    +x11

variant x11 {
    depends_lib-append          port:xorg-libXt \
                                port:xpm
    configure.args              X-Configure name=${SYS_NAME}
}

# Version has a letter suffix, so include letter on both sides of livecheck.
livecheck.version   ${version}
livecheck.regex     /tags/v(\[0-9a-z.\]+)\\.tar\\.gz
