# $Id$

PortSystem 1.0

name	   inventor
version	   2.1.5-10
revision	10
categories	devel graphics x11
platforms	darwin
maintainers	css

description	SGI Open InventorTM graphics toolkit
license		GPL-2
long_description    Open InventorTM is an object-oriented 3D toolkit offering a comprehensive \
		    solution to interactive graphics programming problems. It presents a \
		    programming model based on a 3D  scene database that dramatically simplifies \
		    graphics programming. It includes a rich set of objects such as cubes, \
		    polygons, text, materials, cameras, lights, trackballs, handle boxes, 3D \
		    viewers, and editors that speed up your programming time and extend your \
		    3D programming capabilities.

homepage	    http://oss.sgi.com/projects/inventor/
master_sites	    ftp://oss.sgi.com/projects/inventor/download/
checksums	    md5 82208096f1e0b111160e864e239c3a51
distname	    ${name}-${version}.src
worksrcdir	    ${name}

depends_lib	    port:xorg-libXi \
		    port:xorg-libXt \
		    port:libGLU \
		    port:freetype \
		    port:jpeg \
		    port:glw

patchfiles	    patch-BarChart-GNUmakefile.diff \
		    patch-Decal-GNUmakefile.diff \
		    patch-GeneralizedCylinder-GNUmakefile.diff \
		    patch-SceneViewer-GNUmakefile.diff \
		    patch-SoCalcParse.y.diff \
		    patch-SoGLTextureImageElement.c++.diff \
		    patch-drop-GNUmakefile.diff \
		    patch-flfreetype.h.diff \
		    patch-gview-GNUmakefile.diff \
		    patch-ivcat-GNUmakefile.diff \
		    patch-ivcommondefs.diff \
		    patch-ivcommonrules.diff \
		    patch-ivdowngrade-GNUmakefile.diff \
		    patch-ivfix-GNUmakefile.diff \
		    patch-ivinfo-GNUmakefile.diff \
		    patch-ivman-GNUmakefile.diff \
		    patch-ivview-GNUmakefile.diff \
		    patch-lib-GNUmakefile.diff \
		    patch-libFL-fl.c.diff \
		    patch-libSoXt-GNUmakefile.diff \
		    patch-localrules.apple.diff \
		    patch-machine.h.diff \
		    patch-maze-GNUmakefile.diff \
		    patch-noodle-GNUmakefile.diff \
		    patch-qmorf-GNUmakefile.diff \
		    patch-revo-GNUmakefile.diff \
		    patch-soxt-GNUmakefile.diff \
		    patch-textomatic-GNUmakefile.diff \
		    patch-widgets-GNUmakefile.componentTest.diff \
		    patch-SoPath.h.diff \
		    patch-SoGLwDrawA.c.diff \
		    patch-LP64.diff

post-patch {
	# gcc allows for declaring main without a return type, clang does not.
	reinplace "s|^main|int main|" \
${worksrcpath}/apps/demos/qmorf/quadCube.c++ \
${worksrcpath}/apps/demos/qmorf/quadSheet.c++ \
${worksrcpath}/apps/demos/qmorf/quadSphere.c++ \
${worksrcpath}/apps/examples/Mentor/CXX/09.3.Search.c++ \
${worksrcpath}/apps/examples/Mentor/CXX/09.5.GenSph.c++ \
${worksrcpath}/apps/examples/Mentor/CXX/17.3.GLFloor.c++ \
${worksrcpath}/apps/examples/Toolmaker/02.Nodes/newNodes.c++ \
${worksrcpath}/apps/examples/Toolmaker/04.Actions/printVolume.c++ \
${worksrcpath}/apps/examples/Toolmaker/07.Nodekits/jumpingJackKitTest.c++ \
${worksrcpath}/apps/examples/Toolmaker/07.Nodekits/pyramidKitTest.c++ \
${worksrcpath}/apps/examples/Toolmaker/08.Manips/newManips.c++ \
${worksrcpath}/apps/samples/4view/4view.c++ \
${worksrcpath}/apps/samples/ivNodeKitStructure/ivNodeKitStructure.c++ \
${worksrcpath}/apps/samples/ivToInclude/ivToIncludeFile.c++ \
${worksrcpath}/apps/samples/ivToInclude/testResults.c++ \
${worksrcpath}/apps/tools/ivcat/ivcat.c++ \
${worksrcpath}/apps/tools/ivfix/ivfix.c++ \
${worksrcpath}/apps/tools/ivinfo/ivinfo.c++ \
${worksrcpath}/apps/tools/ivperf/ivperf.c++ \
${worksrcpath}/doc/man/ivman/Main.c++ \
${worksrcpath}/tools/ppp/ppp.c++
	reinplace "s|unsigned int argc| int argc |" ${worksrcpath}/apps/samples/widgets/componentTest.c++

	# path substitutions
	reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/make/ivcommondefs
	reinplace "s|/usr/X11R6|${prefix}|" ${worksrcpath}/make/ivcommondefs

	# El Capitan security workaround
	reinplace "s|__WORKSRCPATH__|${worksrcpath}/lib|" ${worksrcpath}/make/ivcommonrules
}

universal_variant	no
use_configure	no
build.env	DYLD_LIBRARY_PATH=${worksrcpath}/lib IVROOT=${destroot}

destroot.env	${build.env}

post-destroot {
	      xinstall -m 755 -d ${destroot}${prefix}/share/${name}
	      xinstall -m 644 -W ${worksrcpath} COPYING FAQ.misc KNOWN.BUGS \
	      ${destroot}${prefix}/share/${name}
}

variant debug description {build with debug information} {
    build.env-append      LIBTYPE=debug
    patchfiles-append     patch-SoV1NkCatalog.c++.diff \
                          patch-SoText3V2.c++.diff
}

variant imagelib description {include the image library} {
	post-destroot {
		xinstall -m 644 -W ${worksrcpath}/libimage libimage.a \
			${destroot}${prefix}/lib
		xinstall -m 644 -W ${worksrcpath}/libimage image.h \
			${destroot}${prefix}/include
		system "ranlib ${destroot}${prefix}/lib/libimage.a"
	}
}