# $Id: Portfile 64351 2010-03-03 16:40:13Z raimue@macports.org $

PortSystem        1.0

name              pwlib
version           1.5.2
distname           ${name}_${version}
categories        net
maintainers       nomaintainer
description       PWLib libraries for openh323
long_description  \
		  libraries for openh323
homepage          http://www.openh323.org
# Disable this mirror, #23915
#master_sites      http://www.openh323.org/bin/
master_sites      sourceforge:openh323
platforms         darwin
checksums         md5 0fa33ba1b32b254abe0b731a52c0f2f9
set worksrcdir    pwlib
patchfiles	patch-all.diff
configure.args    --mandir=${prefix}/share/man
configure.env   PWLIBDIR="${worksrcpath}" \
                CFLAGS="-I${prefix}/include" \
		LDFLAGS="-L${prefix}/lib" \
		CPPFLAGS="-I${prefix}/include" \
		LD_LIBRARY_PATH="${worksrcpath}/lib"
depends_lib	lib:libldap:openldap \
		lib:libsdl:libsdl \
		lib:libexpat:expat \
		lib:libssl:openssl
build.target      both
post-patch {
		reinplace "s|@@PREFIX@@|${prefix}|g" \
			src/ptlib/unix/Makefile \
			make/unix.mak
}
destroot {
	# sigh sigh sigh
        file mkdir ${destroot}${prefix}/include
        file mkdir ${destroot}${prefix}/bin
        file mkdir ${destroot}${prefix}/lib
        file mkdir ${destroot}${prefix}/share/pwlib
	system " cd ${worksrcpath} && \
        chmod a+r lib/*dylib && \
        cp -R lib/*dylib* ${destroot}${prefix}/lib/ && \
        cp -R include/ptclib ${destroot}${prefix}/include/ && \
        cp -R include/ptlib ${destroot}${prefix}/include/ && \
        cp -R include/ptbuildopts.h ${destroot}${prefix}/include/ && \
        cp -R include/ptlib.h ${destroot}${prefix}/include/ && \
        cp tools/asnparser/obj*/asnparser ${destroot}${prefix}/bin/"
        file mkdir ${destroot}${prefix}/share/pwlib/make/
	system " cd ${worksrcpath} && \
        cp -R make/*.mak ${destroot}${prefix}/share/pwlib/make/ && \
        cp make/ptlib-config ${destroot}${prefix}/bin/ && \
        rm -rf ${destroot}${prefix}/include/ptlib/CVS/ && \
        rm -rf ${destroot}${prefix}/include/ptlib/unix/CVS/ && \
        rm -rf ${destroot}${prefix}/include/ptlib/unix/ptlib/CVS/ && \
        rm -rf ${destroot}${prefix}/include/ptclib/CVS/ && \
        cd ${destroot}${prefix}/lib && ln -fs libpt_Darwin_ppc_r.dylib libpt.dylib && cd - && \
        chmod -R a+r ${destroot}${prefix}/include/ptlib ${destroot}${prefix}/include/ptclib \
		${destroot}${prefix}/include/ptlib.h \
		${destroot}${prefix}/share/pwlib ${destroot}${prefix}/include/ptbuildopts.h \
		${destroot}${prefix}/include/ptlib.h && \
        chmod a+rx ${destroot}${prefix}/include/ptlib ${destroot}${prefix}/include/ptlib/unix \
		${destroot}${prefix}/include/ptlib/unix/ptlib ${destroot}${prefix}/include/ptclib \
		${destroot}${prefix}/bin/ptlib-config ${destroot}${prefix}/share/pwlib/make/ \
	"
}
