# $Id: Portfile,v 1.6 2006/06/30 04:08:09 ben Exp $

PortSystem		1.0
name			libsdl_mixer-framework
version			1.2.6
categories		audio devel
maintainers		darwinports@opendarwin.org
description		Audio mixer library for SDL
long_description 	A sample multi-channel audio mixer library.  It supports any number of \
			simultaneously playing channels of 16 bit stereo audio, plus a single \
			channel of music.

platforms		macosx

homepage		http://www.libsdl.org/projects/SDL_mixer/
master_sites		${homepage}release/
distname		SDL_mixer-${version}
dist_subdir             libsdl_mixer
checksums		md5 2b8beffad9179d80e598c22c80efb135

depends_lib		port:libsdl-framework \
			port:libsdl_mixer

variant macosx i386 {
        patchfiles      native_midi_mac.c.patch
}

configure.env		CPPFLAGS="-no-cpp-precomp -I${prefix}/include" \
				LDFLAGS="-L${prefix}/lib"
configure.args		--with-sdl-prefix=${prefix} --disable-sdltest \
			--enable-music-mp3 --with-smpeg-prefix=${prefix} --enable-music-ogg

set buildindir build

platform darwin 8 {
if {$xcodeversion == "2.1"} {
set buildindir build/Deployment
}
}

set pbx	"${worksrcpath}/PBProjects/SDL_mixer.pbproj/project.pbxproj"

post-extract {
	system "cd ${worksrcpath} && tar -xvzf PBProjects.tar.gz"
}

post-patch {
	reinplace "s|~/Library/Frameworks|./build/Frameworks|g" ${pbx}
	reinplace "s|\$(HOME)/Library/Frameworks|/Library/Frameworks|g" ${pbx}
	reinplace "s|\$HOME/Library/Frameworks|/Library/Frameworks|g" ${pbx}
	reinplace "s|build/SDL_mixer.framework|${buildindir}/SDL_mixer.framework|g" ${pbx}
}

build.dir	"${worksrcpath}/PBProjects"
build.type	pbx
build.target	-buildstyle Deployment -target Framework

post-build {
	cd ${worksrcpath}/PBProjects
	system "install_name_tool -id /Library/Frameworks/SDL_mixer.framework/SDL_mixer \
			build/Frameworks/SDL_mixer.framework/SDL_mixer"
}

destroot.cmd    {}
destroot.target {}

post-destroot {
	cd "${worksrcpath}/PBProjects/build/Frameworks"
	xinstall -d -m 0755 ${destroot}/Library/Frameworks
	system "cp -R SDL_mixer.framework ${destroot}/Library/Frameworks"
	xinstall -m 0755 -d ${destroot}/Developer/Documentation/SDL_mixer
}

platform darwin 6 {
	depends_lib-append	lib:libdl:dlcompat
}
