# $Id: Portfile,v 1.9 2006/02/17 14:49:03 olegb Exp $

PortSystem 1.0
name		VTK
version		4.2.6
revision	1
categories	graphics
maintainers	cssdev@mac.com
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	sourceforge:vtk
checksums	md5 41382fb3f8d15e76d7464c11045ee7a5

depends_build	bin:cmake:cmake
distfiles	${name}-4.2-LatestRelease${extract.suffix}
distname	${name}

post-extract {
    set fl [open "| grep VTK_BUILD_VERSION ${worksrcpath}/CMakeLists.txt | grep 6"]
    set data [read $fl]
    close $fl
    if {$data != "SET(VTK_BUILD_VERSION 6)\n"} { ui_msg "$data
================================================================
Warning : the Latest VTK version is not the same as the Portfile
The build may still succeed but this should be reported as a bug
================================================================"
    }
}

configure	{ system "cd ${worksrcpath} && cmake ${configure.args} ${worksrcpath}" }
configure.args	-D BUILD_SHARED_LIBS: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

platform darwin 8 {
    patchfiles patch-vtk3DSImporter.cxx \
               patch-vtkAbstractMapper.cxx \
               patch-vtkAbstractMapper3D.cxx \
               patch-vtkAppendFilter.cxx \
               patch-vtkBMPReader.cxx \
               patch-vtkBooleanTexture.cxx \
               patch-vtkCardinalSpline.cxx \
               patch-vtkCocoaGLView.h \
               patch-vtkCocoaGLView.mm \
               patch-vtkImageReader.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 {
	depends_build-append	lib:libX11:XFree86
	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_gl_LIBRARY:FILEPATH=/usr/X11R6/lib/libGL.dylib \
				-D OPENGL_glu_LIBRARY:FILEPATH=/usr/X11R6/lib/libGLU.dylib
}


