# -*- 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
# $Id: Portfile 108689 2013-07-31 01:19:52Z ryandesign@macports.org $
PortSystem          1.0

name                OpenIPMI
version             2.0.19
revision            2
license             {GPL-2 LGPL-2}
categories          sysutils
platforms           darwin
maintainers         eborisch \
                    openmaintainer

description         OpenIPMI provides a full-function IPMI interface.

long_description    The Open IPMI project aims to develop an open code base to\
                    allow access to platform information using Intelligent\
                    Platform Management Interface (IPMI).

homepage            http://openipmi.sourceforge.net/
master_sites        sourceforge:openipmi

universal_variant   no
use_parallel_build  no

checksums \
    rmd160  ca624701659416da55a6b96abbec6aef4d323a26 \
    sha256  5b0de4741f07e350bf53b7d31bb20dd1109c2dc005dfb13969d8a9ff290f3a4e

patchfiles          weak_symbols.patch \
                    configure.in.patch

depends_lib         port:popt \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:net-snmp \
                    port:tcl
                        
configure.args      --with-poptlibs=-lpopt \
                    --with-swig=no \
                    --with-python=no \
                    --with-perl=no

variant python description "Build python bindings" {
    configure.args-delete --with-swig=no --with-python=no
    depends_lib-append      port:swig-python \
                            port:py27-tkinter
}

variant perl description "Build perl bindings" {
    configure.args-delete --with-swig=no --with-perl=no
    depends_lib-append      port:swig-perl \
                            port:perl5
}

platform darwin {
    post-extract {
        system -W ${worksrcpath} \
            "find . -name 'Makefile*' | xargs sed -i '' -e 's/Map/map/g'"
        system -W ${worksrcpath} \
            "grep -R 'rdynamic' -l * | xargs sed -i '' -e 's/-rdynamic//g'"
        set REPLSTR "s/LD_PRELOAD=/DYLD_INSERT_LIBRARIES=/g"
        system -W ${worksrcpath} \
            "grep -R 'LD_PRELOAD' -l * | xargs sed -i '' -e '${REPLSTR}'"
    }

    use_autoreconf  yes

    post-configure {
        set REPLSTR "s/lib(\[^ :\/\]*)\.so/lib\\1.dylib/g"
        system -W ${worksrcpath} \
            "find . -name 'Makefile' | xargs sed -E -i '' -e '${REPLSTR}'"

        if {[variant_isset python]} {
            set LIBPATH \
"../../../unix/.libs:../../../lib/.libs:../../../utils/.libs:../../../cmdlang/.libs:../../../tcl/.libs:../../../swig/python/.libs"
            reinplace "s|DYLD_\[^ \]*|DYLD_LIBRARY_PATH=${LIBPATH}|g" \
                swig/python/openipmigui/Makefile
        }
    }
}

livecheck.type      sourceforge
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
