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

name                factor
version             0.97
categories          lang devel
platforms           darwin
license             BSD
maintainers         {ciserlohn @ci42}

description         A practical stack language

long_description    The Factor programming language combines powerful language \
                    features with a full-featured library. The implementation \
                    is fully compiled for performance, while still supporting \
                    interactive development. Factor applications are portable \
                    between all common platforms. Factor can deploy stand- \
                    alone applications on all platforms.

homepage            http://www.factorcode.org/

master_sites        http://downloads.factorcode.org/releases/${version}/
distname            ${name}-src-${version}
worksrcdir          ${name}

checksums           rmd160  166ba7818e1833cb172a30f60c3a4cb072a63ce3 \
                    sha256  fd75e765590691c89b866e5265ae16bfb36d0e28eed095702ae1e206114663b8

use_zip             yes

universal_variant   no
supported_archs	    i386 x86_64

use_configure       no

if {${build_arch} eq "x86_64"} {
    build.target    macosx-x86-64
    set boot_image  boot.unix-x86.64.image 

} elseif {${build_arch} eq "i386"} {
    build.target    macosx-x86-32
    set boot_image  boot.unix-x86.32.image 
}

build.args-append   CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    SITE_CFLAGS="${configure.cflags} ${configure.cc_archflags}"

post-build {
    system "cd ${worksrcpath} && ./factor -i=./${boot_image}"
}

destroot {
    set factor_dir ${destroot}${applications_dir}/Factor-${version}
    xinstall -d ${factor_dir}
    foreach f {Factor.app factor.image basis core \
               extra misc README.md license.txt} {
        copy ${worksrcpath}/$f ${factor_dir}
    }
    copy ${worksrcpath}/libfactor.dylib ${destroot}${prefix}/lib

    xinstall -d ${destroot}${prefix}/share/vim 
 	copy ${factor_dir}/misc/vim ${destroot}${prefix}/share/vim/vimfiles 
}


livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     ${name}-src-(\\d+\\.\\d+)${extract.suffix}
