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

github.setup        JorenSix Olaf 4442e91b65d151211afc22a161c30fb07cf6ce3b
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                olaf-devel
version             20230929
revision            0
categories          audio
license             AGPL-3
maintainers         {l2dy @l2dy} openmaintainer
description         Overly Lightweight Acoustic Fingerprinting
long_description    {*}${description} is a portable acoustic fingerprinting system.

checksums           rmd160  dc0dbfa5d0a113f43094892571016bd5bbc0962f \
                    sha256  8b0a9dc36af142d5ae169de3610bd6ae98e8b2714a427feba401b3069be11943 \
                    size    3862904

depends_run         port:rb32-threach

# https://github.com/JorenSix/Olaf/issues/50
patchfiles-append   patch-altivec.diff

# cc1: error: unrecognized command line option "-std=gnu11"
compiler.c_standard 2011

use_configure       no
build.target        compile

post-patch {
    reinplace "s|/usr/local/bin/olaf_c|${prefix}/libexec/olaf/olaf_c|g" ${worksrcpath}/olaf.rb
    reinplace "1s|/usr/bin/env ruby|${prefix}/bin/ruby3.2|g" ${worksrcpath}/olaf.rb
}

pre-configure {
    reinplace "s|\tgcc |\t${configure.cc} |g" ${worksrcpath}/Makefile
}

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/libexec/olaf
    xinstall -m 755 ${worksrcpath}/bin/olaf_c ${destroot}${prefix}/libexec/olaf

    xinstall -m 755 ${worksrcpath}/olaf.rb ${destroot}${prefix}/bin/olaf
}
