# -*- 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        snowballstem snowball 2.2.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1

name                libstemmer
categories          textproc
maintainers         nomaintainer
license             BSD

description         Algorithmic Stemmer Library

long_description    Snowball is a language in which stemming algorithms can\
                    be easily represented. The Snowball compiler translates a\
                    Snowball script (a .sbl file) into either a thread-safe\
                    ANSI C program or a Java program. For ANSI C, each\
                    Snowball script produces a program file and corresponding\
                    header file (with .c and .h extensions). This port\
                    delivers the ANSI C library build.

homepage            https://snowballstem.org

checksums           rmd160  e0c24d1b915fe99c7e81f25610cdd605eafb57d9 \
                    sha256  69a6b91bea3e74096db21751946b7a711170a62d723117084c6c74d548a82d19 \
                    size    223943

use_configure       no

variant universal   {}

patchfiles          patch-GNUmakefile.diff

build.env           CC=${configure.cc} \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"
build.post_args     -f GNUmakefile

post-build {
    system -W ${worksrcpath} \
        "env MACOSX_DEPLOYMENT_TARGET=${macosx_deployment_target}\
        ${configure.cc} [get_canonical_archflags ld] ${configure.ldflags} -fpic\
        -dynamiclib -Wl,-all_load libstemmer.a -o libstemmer.dylib"
    system -W ${worksrcpath} \
        "env MACOSX_DEPLOYMENT_TARGET=${macosx_deployment_target}\
        install_name_tool -id ${prefix}/lib/libstemmer.dylib libstemmer.dylib"
}

destroot {
    # install header files
    xinstall -m 0644 -W ${worksrcpath}/include libstemmer.h \
        ${destroot}${prefix}/include
    # install libraries
    xinstall -m 0644 -W ${worksrcpath} \
        libstemmer.dylib ${destroot}${prefix}/lib
    xinstall -m 0644 -W ${worksrcpath} \
        libstemmer.a ${destroot}${prefix}/lib
    # install docs
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -W ${worksrcpath} -m 0644 AUTHORS COPYING NEWS README.rst \
        ${destroot}${prefix}/share/doc/${name}
}
