# $Id: Portfile,v 1.4 2006/06/30 04:08:09 ben Exp $
PortSystem		1.0
name			libsdl_sound-framework
version			1.0.1
categories		audio devel
maintainers		darwinports@opendarwin.org
description		handles decoding of several popular sound file formats
long_description	SDL_sound is a library that handles the decoding of \
			several popular sound file formats, such as .WAV and \
			.MP3. It is meant to make the programmer's sound \
			playback tasks simpler.
platforms		macosx
homepage		http://icculus.org/SDL_sound/
master_sites		http://icculus.org/SDL_sound/downloads/
distname		SDL_sound-${version}
dist_subdir             libsdl_sound
checksums		md5 49e197ef7c8ab623d0640dc74be43160
depends_lib		port:libsdl-framework \
			port:libsdl_sound

depends_build		bin:glibtoolize:libtool \
			bin:automake:automake \
			bin:autoconf:autoconf

patchfiles		patch-acinclude.m4

pre-configure {
	ui_info "Initial preparation...this can take awhile, so sit tight..."
	system "cd ${worksrcpath} && aclocal"
	system "cd ${worksrcpath} && glibtoolize --automake --copy --force"
	system "cd ${worksrcpath} && autoheader"
	system "cd ${worksrcpath} && automake --foreign --add-missing --copy"
	system "cd ${worksrcpath} && autoconf"
	ui_info "Ready to run ./configure ..."
}
configure.env	LDFLAGS=-L${prefix}/lib
configure.args	--disable-sdltest \
		--disable-smpegtest

set buildindir build

platform darwin 8 {
if {$xcodeversion == "2.1"} {
  set buildindir build/Deployment
  patchfiles patch-acinclude.m4.xcode21 patch-aclocal.m4.xcode21 patch-configure.xcode21
  }
}

set pbx	"${worksrcpath}/PBProjects/SDL_sound.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|vorbis/include|$prefix/include/vorbis|g" ${pbx}
	reinplace "s|vorbis/lib|$prefix/lib|g" ${pbx}
	reinplace "s|mikmod/include|$prefix/include|g" ${pbx}
	reinplace "s|mikmod/lib|$prefix/lib|g" ${pbx}
        reinplace "s|build/SDL_sound.framework|${buildindir}/SDL_sound.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_sound.framework/SDL_sound \
		build/Frameworks/SDL_sound.framework/SDL_sound"
}

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

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