# -*- 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

github.setup            eggheads eggdrop 1.10.1 v
revision                0
checksums               rmd160  f35920234de98c2d16fd8a336800bd775816622f \
                        sha256  a5cdf7444d781c2ff4f5d0be14202f5d0971e00387181a49b725057fe95312d5 \
                        size    2204296
github.tarball_from     archive

license                 GPL-2+
set branch              [join [lrange [split ${version} .] 0 1] .]
categories              irc
maintainers             nomaintainer
description             Eggdrop is the world's most popular Internet Relay Chat (IRC) bot.
long_description        ${description}

homepage                https://www.eggheads.org
github.tarball_from     releases
master_sites-append     https://ftp.eggheads.org/pub/eggdrop/source/${branch}/

depends_lib             path:lib/libssl.dylib:openssl \
                        port:tcl \
                        port:zlib

configure.args          --enable-tls \
                        --with-sslinc=${prefix}/include \
                        --with-ssllib=${prefix}/lib \
                        --with-tcl=${prefix}/lib

post-configure {
    system -W ${worksrcpath} "${build.cmd} config"
}

# ld: duplicate symbol dyld_stub_binding_helper in /usr/lib/bundle1.o and /usr/lib/dylib1.10.5.o
# https://github.com/eggheads/eggdrop/issues/1662
patchfiles-append       patch-unbreak-linking.diff

build.target            eggdrop

set eggdest             libexec/eggdrop
destroot.destdir        DEST=${destroot}${prefix}/${eggdest}

post-destroot {
    ln -s ../${eggdest}/eggdrop-${version} ${destroot}${prefix}/bin/eggdrop
    system "gzip -9 ${destroot}${prefix}/${eggdest}/doc/man1/eggdrop.1"
    ln -s ../../../${eggdest}/doc/man1/eggdrop.1.gz ${destroot}${prefix}/share/man/man1
    move ${destroot}${prefix}/${eggdest}/eggdrop.conf ${destroot}${prefix}/${eggdest}/eggdrop.conf.sample
}

platform darwin 8 {
        configure.cflags-append "-DBIND_8_COMPAT"
}
