# -*- 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           boost 1.0
PortGroup           cmake 1.1
PortGroup           github 1.0
PortGroup           legacysupport 1.1
PortGroup           wxWidgets 1.0

# Boost 1.87 fixed for 10.6.8 powerpc, but not tested on 10.4–10.5.
if {${os.platform} ne "darwin" || ${os.major} > 9} {
    boost.version   1.88
} else {
    boost.version   1.76
}

github.setup        amule-project amule f822a2ce6da2478774d80dd044a0f56aa0ba9ba7
version             2026.05.19
revision            0
categories          net p2p www
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         aMule, the all-platform eMule p2p client
long_description    aMule is a multiplatform fork of xMule client \
                    using wxWindows class library.
license             GPL-2
homepage            https://www.amule.org
checksums           rmd160  7c63319cb8a50f6b6fe439102b0ca211debf7372 \
                    sha256  d8a8c9ca3dd394f46697e160fddfe58894c90f35104d128d57283dcd0d5ba1fe \
                    size    5246343
github.tarball_from archive

patchfiles-append   patch-unbreak-install.diff

depends_build-append \
                    port:bison \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig
depends_lib-append  port:curl \
                    port:gettext-runtime \
                    port:libcryptopp \
                    port:libgeoip \
                    port:libiconv \
                    port:libmaxminddb \
                    port:libpng \
                    port:libupnp \
                    port:readline \
                    port:zlib
depends_run-append  port:desktop-file-utils

configure.args-append \
                    -DBUILD_ALCC=ON \
                    -DBUILD_AMULECMD=ON \
                    -DBUILD_CAS=OFF \
                    -DBUILD_DAEMON=ON \
                    -DBUILD_ED2K=ON \
                    -DBUILD_MONOLITHIC=ON \
                    -DBUILD_REMOTEGUI=OFF \
                    -DBUILD_TESTING=OFF \
                    -DBUILD_WEBSERVER=OFF \
                    -DBUILD_XAS=ON \
                    -DENABLE_IP2COUNTRY=ON \
                    -DENABLE_NLS=ON \
                    -DENABLE_UPNP=ON

compiler.cxx_standard   2017
# At least on Catalina Apple clang fails at configure on boost::asio check.
compiler.blacklist-append   {clang < 1300}

configure.cppflags-append \
                    -Damule_HAVE_LIBCURL

# May not be needed, but keep for now:
configure.cxxflags-append \
                    "-framework CoreFoundation -framework CoreServices -framework ApplicationServices -framework IOKit"
configure.ldflags-append \
                    "-framework CoreFoundation -framework CoreServices -framework ApplicationServices -framework IOKit"

# This variant does not work on 10.11 and earlier:
variant wxwidgets32 conflicts wxgtk32 description "Use Cocoa-based wxWidgets 3.2" {
    wxWidgets.use           wxWidgets-3.2
    depends_lib-append      port:${wxWidgets.port}

    configure.args-append   -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig} \
                            -DwxWidgets_wxrc_EXECUTABLE=${wxWidgets.wxrc}
}

# wx < 3.2 is not supported now: https://github.com/amule-project/amule/issues/407
variant wxgtk32 conflicts wxwidgets32 description "Use GTK-based wxWidgets 3.2" {
    wxWidgets.use           wxGTK-3.2
    depends_lib-append      port:${wxWidgets.port}

    configure.args-append   -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig} \
                            -DwxWidgets_wxrc_EXECUTABLE=${wxWidgets.wxrc}
}

# We prefer wxGTK, since no testing is done for wxWidgets-3.2.
# Upstream MacPorts maintains wxWidgets-3.2 port. If you wish to use it,
# install amule with +wxwidgets32.
if {![variant_isset wxwidgets32] && ![variant_isset wxgtk32]} {
    default_variants        +wxgtk32
}

post-destroot {
    move ${destroot}${prefix}/aMule.app ${destroot}${applications_dir}/aMule.app
    ln -s ${applications_dir}/aMule.app/Contents/MacOS/aMule ${destroot}${prefix}/bin/amule
}

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
}
