# $Id: Portfile 71579 2010-09-17 00:12:30Z ryandesign@macports.org $

PortSystem 1.0

name		VTK
version		4.4.2
categories	graphics
maintainers	css
description	3D visualization toolkit
long_description	an open source, freely available software system  \
	for 3D computer graphics, image processing, and visualization     \
	used by thousands of researchers and developers around the world. \
	VTK consists of a C++ class library, and several interpreted      \
	interface layers including Tcl/Tk, Java, and Python.

homepage	http://www.vtk.org/
platforms	darwin freebsd
master_sites	${homepage}/files/release/4.4/
checksums	md5 17a5006c4d7acca3e74d32e0e27f4739 \
		sha1 9a68ecefa35f97a79fedd830c369f5b4225d1f55

depends_build	bin:cmake:cmake
worksrcdir	${name}

configure	{ system "cd ${worksrcpath} && cmake ${configure.args} ${worksrcpath}" }
configure.args	-D BUILD_SHARED_LIBS:BOOL=ON \
		-D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \
		-D CMAKE_INSTALL_PREFIX:PATH=${prefix} \
		-D VTK_USE_HYBRID:BOOL=ON \
		-D VTK_USE_CARBON:BOOL=OFF \
		-D VTK_USE_COCOA:BOOL=ON \
		-D CMAKE_SKIP_RPATH:BOOL=OFF \
		-D CMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/vtk \
		-D CMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON

platform darwin {
	# These patches make the code work with gcc4.
	patchfiles patch-vtk3DSImporter.cxx \
		patch-vtkAbstractMapper.cxx \
		patch-vtkAbstractMapper3D.cxx \
		patch-vtkAppendFilter.cxx \
		patch-vtkBMPReader.cxx \
		patch-vtkBooleanTexture.cxx \
		patch-vtkBranchExtentTranslator.cxx \
		patch-vtkCardinalSpline.cxx \
		patch-vtkCocoaGLView.h \
		patch-vtkCocoaGLView.mm \
		patch-vtkCocoaRenderWindow.mm \
		patch-vtkDecimate.cxx \
		patch-vtkOSXRenderingTclInit.c \
		patch-vtkTkWidgetsInit.cxx

	pre-build {
		reinplace "s;VTK_APPLE_SHARED_FLAGS_NEEDED 1;VTK_APPLE_SHARED_FLAGS_NEEDED 0;" ${worksrcpath}/CMakeLists.txt
	}
}

variant x11 description {Build VTK with the MacPorts X11 libraries} {
	depends_lib-append    port:mesa port:Xft2 port:xorg-libXScrnSaver port:xorg-libXt
	configure.args-delete	"-D VTK_USE_COCOA:BOOL=ON"
	configure.args-append	-D VTK_USE_COCOA:BOOL=OFF \
				-D VTK_USE_X:BOOL=ON \
				-D OPENGL_INCLUDE_DIR:PATH=${prefix}/include \
				-D OPENGL_gl_LIBRARY:FILEPATH=${prefix}/lib/libGL.dylib \
				-D OPENGL_glu_LIBRARY:FILEPATH=${prefix}/lib/libGLU.dylib
}
