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

perl5.branches      5.28 5.30 5.32 5.34
perl5.setup         Alien-wxWidgets 0.69

platforms           darwin
maintainers         nomaintainer
license             {Artistic-1 GPL}

supported_archs     noarch

description         Alien::wxWidgets - building, finding and using wxWidgets binaries.

long_description    ${description}

checksums           rmd160  d3f3bd5f0cc3815ea7e80939506bfc7c16c01a48 \
                    sha256  53224e4bbbefff4cf7b63ed9a62963893b9ffd4965d70d96710348f8676de249

if {${perl5.major} != ""} {
    wxWidgets.use       wxWidgets-3.0
    depends_build-append \
                    port:p${perl5.major}-lwp-protocol-https

    depends_lib-append \
                    port:${wxWidgets.port} \
                    port:p${perl5.major}-module-pluggable

    # this line is not really needed, but it's a guard
    # to make sure that the right building procedure is used
    # (it can be removed)
    # causes an error during configure because Makefile.PL
    # is listed in MANIFEST
    #post-patch {
    #    delete ${worksrcpath}/Makefile.PL
    #}

    # WX_CONFIG doesn't seem to work in all circumstances,
    # so until the bug is fixed, one needs to either change PATH or specify --wxWidgets-build=0
    # additionally, the portgroup wants to install perl ports in the vendor directories asserting INSTALLDIRS=vendor during configure
    # however, this port uses --installdirs for this function which defaults to 'site' and overrides INSTALLDIRS when installing.
    # this causes destroot to fail in post processing (expecting vendor dirs but site dirs are installed)
    # setting --installdirs=vendor in addition to INSTALLDIRS=vendor keeps everyone happy
    # possibly a case sensitivity problem?
    configure.args-append   --installdirs=vendor --wxWidgets-build=0
    configure.env-append    WX_CONFIG=${wxWidgets.wxconfig}
    build.env-append        WX_CONFIG=${wxWidgets.wxconfig}
    # configure.env-append  WX_CONFIG=${wxWidgets.wxconfig} PATH=${wxWidgets.wxdir}:$env(PATH)
    # build.env-append      WX_CONFIG=${wxWidgets.wxconfig} PATH=${wxWidgets.wxdir}:$env(PATH)

    # this is needed to use Build.Pl instead of Makefile.PL - the proper way (per author)
    # (else --wxWidgets-build=0 doesn't work)
    # note this only makes sense for the subports
    perl5.use_module_build
}
