# -*- 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            libdumb
version         0.9.3
categories      multimedia
license         Permissive
platforms       darwin
maintainers     {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description     IT, XM, S3M and MOD player library
long_description ${description}
homepage        http://dumb.sourceforge.net

distname        dumb-${version}
master_sites    sourceforge:project/dumb/dumb/${version}/

use_parallel_build  no

checksums       rmd160  53c7931fec71dd4e67e19c4acf38c0f9202e5698 \
                sha256  8d44fbc9e57f3bac9f761c3b12ce102d47d717f0dd846657fb988e0bb5d1ea33

# patches to bulid shared libraries
patchfiles                  \
    patch-Makefile.inc.diff \
    patch-Makefile.diff

configure {
    # mimic "make config"
    set config [open "${worksrcpath}/make/config.txt" w 0644]
    puts ${config} "include make/unix.inc"
    puts ${config} "ALL_TARGETS := core core-examples core-headers"
    puts ${config} "PREFIX := ${prefix}"
    close ${config}
}

variant universal {}

# dumb sets its own compiler flags with no simple way of adding more, so append them to compiler.
build.args-append CC="${configure.cc} [get_canonical_archflags cc]"

build.args-append              \
    CURRENT_VERSION=${version} \
    COMPAT_VERSION=1.0.0       \
    MAKEFILE=Makefile
    
destroot.target-append                                \
    INCLUDE_INSTALL_PATH=${destroot}${prefix}/include \
    LIB_INSTALL_PATH=${destroot}${prefix}/lib         \
    BIN_INSTALL_PATH=${destroot}${prefix}/bin         \
    MAKEFILE=Makefile

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -m 775 -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} readme.txt licence.txt ${destroot}${docdir}
    foreach f [glob -directory ${worksrcpath}/docs *.txt] {
        xinstall -m 0644 ${f} ${destroot}${docdir}
    }
}
