# $Id$

PortSystem 1.0

name             live555
version          2012.02.04
categories       multimedia
license          LGPL-2.1+
maintainers      nomaintainer
description      LIVE555 Streaming Media
long_description \
  This code forms a set of C++ libraries for multimedia streaming, using open\
  standard protocols (RTP/RTCP, RTSP, SIP). These libraries - which can be\
  compiled for Unix (including Linux and Mac OS X), Windows, and QNX (and\
  other POSIX-compliant systems) - can be used to build streaming\
  applications.
homepage         http://www.live555.com/liveMedia/
platforms        darwin
master_sites     ${homepage}public/

checksums           rmd160  0ff1f656d7244b94820a7ee299d7c96003791b00 \
                    sha256  bd55b78d72d8a7b32a69d54f1a852ea7c4e666b90272a74091105b8c9292eccd

distname         live.${version}
worksrcdir       live
# Configure settings remain in installed Makefiles, so be minimalistic
configure.ccache no
configure.distcc no
patchfiles       patch-config.macosx.diff
post-patch {
    reinplace "s|@ARCHFLAGS@|[get_canonical_archflags]|g
        s|@CC@|${configure.cc}|g
        s|@CXX@|${configure.cxx}|g
        s|@CPPFLAGS@|${configure.cppflags}|g
        s|@CFLAGS@|${configure.cflags}|g
        s|@CXXFLAGS@|${configure.cxxflags}|g
        s|@LDFLAGS@|${configure.ldflags}|g" \
        ${worksrcpath}/config.macosx
}

set files_0      ${workpath}/files-0.txt
set files_1      ${workpath}/files-1.txt
set files_new    ${workpath}/files-new.txt

configure.cmd    ./genMakefiles
configure.pre_args {}
configure.universal_args-delete	--disable-dependency-tracking

post-configure {
    ui_debug "Create a list of files: \[${files_0}\]"
    system -W ${worksrcpath} "find -s . ! -type d > ${files_0}"
}

post-build {
    ui_debug "Create an updated list of files: \[${files_1}\]"
    system -W ${worksrcpath} "find -s . ! -type d > ${files_1}"
    
    ui_debug "Create a list of new files: \[${files_new}\]"
    system "comm -1 -3 ${files_0} ${files_1} > ${files_new}"
}

destroot {
    set dst ${destroot}${prefix}/lib/live
    
    ui_debug "Copy worksrcpath into destroot"
    file copy ${worksrcpath} ${dst}
    
    ui_debug "Delete everything but *.hh and *.h files listed in \[${files_0}\]"
    system -W ${dst} "grep -v -e '\\.h\$' -e '\\.hh\$' ${files_0} | xargs rm"
    
    ui_debug "Delete every *.o file listed in \[${files_new}\]"
    system -W ${dst} "grep -e '\\.o\$' ${files_new} | xargs rm"
}

platform macosx {
        configure.args  macosx
}
platform linux {
        configure.args  linux
}

livecheck.type      regex
livecheck.url       ${homepage}public/
livecheck.regex     live\\.(\[0-9a-z.\]+)\\.tar\\.gz