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

name                wxLua
version             2.8.12.3
revision            4
categories          graphics devel
platforms           darwin freebsd
maintainers         nomaintainer
description         Lua bindings for wxWidgets
long_description    wxLua is a lua scripting language wrapper around the \
                    wxWidgets cross-platform GUI library. It consists of an \
                    executable for running standalone wxLua scripts and a \
                    library for extending C++ programs with a fast, small, \
                    fully embeddable scripting language.

homepage            http://wxlua.sourceforge.net/
master_sites        sourceforge:wxlua
distname            ${name}-${version}-src

## SVN repository
# fetch.type        svn
# svn.url           https://svn.code.sf.net/p/wxlua/svn/trunk/${name}
# worksrcdir        ${name}

checksums           rmd160  c09c3e64b0abde69e1d3ecc62a703b225c78e278 \
                    sha256  dbfc1d0ed7a89524c7adac66b8ae4b792f4c06255c5c0fea304d439fc87a6d50

cmake.out_of_source yes
wxWidgets.use       wxWidgets-3.0

depends_lib         port:readline \
                    port:${wxWidgets.port}

configure.args-append \
                    -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig} \
                    -DwxLua_LUA_LIBRARY_BUILD_SHARED=OFF \
                    -DwxLua_LUA_LIBRARY_USE_BUILTIN=ON \
                    -DwxLua_LUA_LIBRARY_VERSION=5.2

# TODO: there is no FindLua52.cmake, but FindLua51 finds the right includes & libraries,
#       except that it then fails to compile; when using the builtin lua,
#       we need to delete lua afterwards

#                   -DwxLua_LUA_INCLUDE_DIR=${prefix}/include \
#                   -DwxLua_LUA_LIBRARY=${prefix}/lib/liblua.dylib \
#                   -DLUA_INCLUDE_DIR=${prefix}/include \
#                   -DLUA_LIBRARIES=${prefix}/lib/liblua.dylib \
#                   -DLUA_LIBRARY=${prefix}/lib/liblua.dylib

post-destroot {
    xinstall -d -m 0755 ${destroot}${applications_dir}
    # TODO: - wxLuaFreeze isn't really working as an app
    foreach {app} {wxLua wxLuaCan wxLuaEdit wxLuaFreeze} {
        move "${destroot}${prefix}/bin/${app}.app" ${destroot}${applications_dir}
    }

    # delete a generic wxWidgets library
    delete ${destroot}${prefix}/lib/libwx.dylib

    # these files need to be deleted if wxstedit remains a separate port
    xinstall -d -m 0755 ${destroot}${prefix}/share/wxstedit
    move ${destroot}${prefix}/doc/wxStEdit ${destroot}${prefix}/share/wxstedit/doc
    delete ${destroot}${prefix}/doc

    # make sure that there is no bin/lua & bin/luac distributed
    delete ${destroot}${prefix}/bin/lua
    delete ${destroot}${prefix}/bin/luac
}

# TODO: if still needed ...
#
# post-destroot {
#     # provide a symbolic link to the wxLua sample programs
#     ln -sf "${prefix}/share/wxlua/samples" "${destroot}${appPath}/Samples"
# 
#     # set up a wrapper so that you can call "wxlua *.wx.lua"
#     xinstall -m 0755 "${filespath}/wxlua.sh" "${destroot}${prefix}/bin/wxlua"
#     # set up a wrapper so that you can call "wxluaedit" too
#     xinstall -m 0755 "${filespath}/wxluaedit.sh" "${destroot}${prefix}/bin/wxluaedit"
# }

livecheck.type      sourceforge
livecheck.name      wxlua
