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

name             quickjs

categories       devel
license          MIT
maintainers      nomaintainer
description      A small and embeddable Javascript engine
long_description ${name} is a small and embeddable Javascript engine. It \
    supports the ES2020 specification including modules, asynchronous \
    generators, proxies and BigInt.
homepage         https://bellard.org/quickjs/

subport          ${name}-devel {}

if {${subport} eq ${name}} {
    conflicts       ${name}-devel
    github.setup    bellard ${name} b5e62895c619d4ffc75c9d822c8d85f1ece77e5b
    version         20210327
    revision        0
    checksums       rmd160  9a6bbc8c7900a77d181120cb498fa7cb51a41b94 \
                    sha256  758df41d9864202c189040e7c5378f34a4c1c65bca3b1d0a54cbcf7650c35bb3 \
                    size    597758
} else {
    # quickjs-devel
    conflicts       ${name}
    github.setup    bellard ${name} 2788d71e823b522b178db3b3660ce93689534e6d
    version         20220306
    revision        0
    checksums       rmd160 548cedf046daaeaeb84cabfc11f5044757714412 \
                    sha256 06f001604ae8df9bdc7377d088320e698a014ec3434283f49e2c84f609233102 \
                    size   598937
    post-extract {
        # `VERSION` is only updated for "real" releases.
        reinplace "s|2021.03.27|${version}|" ${worksrcpath}/VERSION
    }
}

use_configure    no

destroot.destdir prefix=${destroot}${prefix}

post-destroot {
    file mkdir ${destroot}${prefix}/lib/pkgconfig
    copy ${filespath}/${name}.pc ${destroot}${prefix}/lib/pkgconfig
    reinplace "s|@@PREFIX@@|${prefix}|" ${destroot}${prefix}/lib/pkgconfig/${name}.pc
    reinplace "s|@@VERSION@@|${version}|" ${destroot}${prefix}/lib/pkgconfig/${name}.pc
}
