# -*- 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
PortGroup           select 1.0

github.setup        love2d love 0.9.2
revision            0
checksums           rmd160  7450142984d879de3afffd77ef87efe1ee5937a2 \
                    sha256  36b731ffec49f73ec15d02ae3bc374bc270d11ba19ce5414c9ba49cc6c40afc7 \
                    size    1686053

set branch          [join [lrange [split ${version} .] 0 1] .]
name                love-${branch}
categories          devel
maintainers         {ryandesign @ryandesign} openmaintainer
license             zlib

description         2D game development framework (${branch}.x branch)

long_description    LÖVE is a 2D game development framework. This port tracks the \
                    ${branch}.x branch.

homepage            https://love2d.org
github.tarball_from archive
dist_subdir         love

use_autoreconf      yes
autoreconf.cmd      platform/unix/automagic
autoreconf.args     -d -${branch}
autoreconf.env      "ACLOCAL=${prefix}/bin/aclocal" \
                    "AUTOHEADER=${prefix}/bin/autoheader" \
                    "AUTOCONF=${prefix}/bin/autoconf" \
                    "AUTOMAKE=${prefix}/bin/automake" \
                    "LIBTOOLIZE=${prefix}/bin/glibtoolize"

set lua_version     5.1

depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:libtool \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:freetype \
                    port:libdevil \
                    port:libmodplug \
                    port:libsdl2 \
                    port:libvorbis \
                    port:lua[string map {. {}} ${lua_version}] \
                    port:mpg123 \
                    port:openal-soft \
                    port:physfs

depends_run-append  port:love_select

select.group        love
select.file         ${filespath}/${name}

patchfiles          libtool-tag.patch \
                    luaopen_socket_core.patch \
                    manpage.patch \
                    no-module.patch

compiler.cxx_standard \
                    2011

configure.args      --disable-sdlframework \
                    --disable-static \
                    --disable-silent-rules \
                    --enable-shared \
                    --enable-osx \
                    --with-lua=lua \
                    --with-luaversion=${lua_version}

destroot.target     install-exec install-man

post-destroot {
    move ${destroot}${prefix}/share/man/man1/love.1 ${destroot}${prefix}/share/man/man6/${name}.6
    set app ${destroot}${applications_dir}/${name}.app
    xinstall -d ${app}/Contents/MacOS ${app}/Contents/Resources
    ln -s ${prefix}/bin/${name} ${app}/Contents/MacOS/love
    xinstall -m 0644 ${worksrcpath}/platform/macosx/love-Info.plist ${app}/Contents/Info.plist
    xinstall -m 0644 -W ${worksrcpath}/platform/macosx/icons Love.icns LoveDocument.icns ${app}/Contents/Resources
    set fp [open ${app}/Contents/PkgInfo w]
    puts -nonewline ${fp} {APPLLoVe}
    close ${fp}
}

livecheck.type      none
