# $Id: Portfile,v 1.5 2006/06/30 04:05:35 ben Exp $
PortSystem		1.0
name			libsdl_image-framework
version			1.2.4
categories		devel graphics
maintainers		darwinports@opendarwin.org
description		Add on library for libSDL handling several image formats
long_description	This is a simple library to load images of various \
			formats as SDL surfaces. This library supports BMP, \
			PPM, PCX, GIF, JPEG, PNG, TGA, and TIFF formats.
platforms		macosx
master_sites		http://www.libsdl.org/projects/SDL_image/release/
homepage        	http://www.libsdl.org/
distname		SDL_image-${version}
dist_subdir             libsdl_image
checksums		md5 70bf617f99e51a2c94550fc79d542f0b
depends_lib		port:libpng \
			port:jpeg \
			port:libsdl-framework \
			port:libsdl_image

configure.env		CFLAGS="-I${prefix}/include" \
				LDFLAGS="-L${prefix}/lib"
configure.args		--disable-sdltest

set buildindir build

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

build.env		${configure.env}


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

post-patch {
	reinplace "s|~/Library/Frameworks|./build/Frameworks|g" \
		${worksrcpath}/PBProjects/SDL_image.pbproj/project.pbxproj
	reinplace "s|\$(HOME)/Library/Frameworks|/Library/Frameworks|g" \
		${worksrcpath}/PBProjects/SDL_image.pbproj/project.pbxproj
	reinplace "s|\$HOME/Library/Frameworks|/Library/Frameworks|g" \
		${worksrcpath}/PBProjects/SDL_image.pbproj/project.pbxproj
	reinplace "s|graphics/include| ${prefix}/include|g" \
		${worksrcpath}/PBProjects/SDL_image.pbproj/project.pbxproj
	reinplace "s|graphics/lib|${prefix}/lib|g" \
		${worksrcpath}/PBProjects/SDL_image.pbproj/project.pbxproj
	reinplace "s|build/SDL_image.framework|${buildindir}/SDL_image.framework|g" \
		${worksrcpath}/PBProjects/SDL_image.pbproj/project.pbxproj
}


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_image.framework/SDL_image \
		build/Frameworks/SDL_image.framework/SDL_image"
}

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

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

