# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 119404 2014-04-24 20:52:00Z mf2k@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0

name                openscad
version             2013.06
revision            1
license             GPL-2
categories          science
maintainers         mf2k openmaintainer
description         OpenSCAD is a software for creating solid 3D CAD objects
long_description    OpenSCAD is a software for creating solid 3D CAD objects. \
                    Unlike most free software for creating 3D models (such as the \
                    famous application Blender) it does not focus on the artistic \
                    aspects of 3D modelling but instead on the CAD aspects. Thus \
                    it might be the application you are looking for when you are \
                    planning to create 3D models of machine parts but pretty sure \
                    is not what you are looking for when you are more interested \
                    in creating computer-animated movies. \
                    OpenSCAD is not an interactive modeller. Instead it is something \
                    like a 3D-compiler that reads in a script file that describes \
                    the object and renders the 3D model from this script file. This \
                    gives you (the designer) full control over the modelling process \
                    and enables you to easily change any step in the modelling process \
                    or make designes that are defined by configurable parameters. \
                    OpenSCAD provides two main modelling techniques: First there is \
                    constructive solid geometry (aka CSG) and second there is extrusion \
                    of 2D outlines. As data exchange format format for this 2D outlines \
                    Autocad DXF files are used. In addition to 2D paths for extrusion \
                    it is also possible to read design parametes from DXF files. Besides \
                    DXF files OpenSCAD can read and create 3D models in the STL and OFF \
                    file formats.
platforms           darwin
homepage            http://www.openscad.org/

master_sites        googlecode
distfiles           ${distname}.src${extract.suffix}

checksums           rmd160  f5c923999570081307e96b8d6c7944c8d07608fb \
                    sha256  f277a8c3e6a548272f95279e50de6d4a6d73552775ab7a33c7f837c8e59173df

patchfiles          patch-stl-utils.cc.diff

depends_build-append \
                    port:bison \
                    port:flex

depends_lib-append  port:boost \
                    port:cgal \
                    port:glew \
                    port:gmp \
                    port:mpfr \
                    port:OpenCSG

configure.env-append \
                    OPENSCAD_LIBRARIES=${prefix}
configure.cmd       ${qt_qmake_cmd}
configure.pre_args  PREFIX=${prefix} VERSION=${version} CONFIG-=debug openscad.pro

use_parallel_build  no

post-destroot {
    # The install location is wrong so we have to move the files to the expected places

    # Application
    move ${destroot}${prefix}/bin/OpenSCAD.app ${destroot}${applications_dir}

    # Examples
    file mkdir ${destroot}${applications_dir}/OpenSCAD.app/Contents/Resources/examples
    eval xinstall -m 644 [glob ${destroot}${prefix}/share/openscad/examples/*] ${destroot}${applications_dir}/OpenSCAD.app/Contents/Resources/examples
    eval file delete [glob ${destroot}${prefix}/share/openscad/examples/*]

    # Library bitmaps
    file mkdir ${destroot}${applications_dir}/OpenSCAD.app/Contents/Resources/libraries/MCAD/bitmap
    eval xinstall -m 644 [glob ${destroot}${prefix}/share/openscad/libraries/MCAD/bitmap/*] ${destroot}${applications_dir}/OpenSCAD.app/Contents/Resources/libraries/MCAD/bitmap
    eval file delete [glob ${destroot}${prefix}/share/openscad/libraries/MCAD/bitmap/*]
    file delete ${destroot}${prefix}/share/openscad/libraries/MCAD/bitmap

    # Empty directories
    file delete ${destroot}${prefix}/share/openscad/libraries/MCAD/SolidPython
    file delete ${destroot}${prefix}/share/openscad/libraries/MCAD/ThingDoc

    # Libraries
    eval xinstall -m 644 [glob ${destroot}${prefix}/share/openscad/libraries/MCAD/*] ${destroot}${applications_dir}/OpenSCAD.app/Contents/Resources/libraries/MCAD
    eval file delete [glob ${destroot}${prefix}/share/openscad/libraries/MCAD/*]

    # Delete un-needed files
    file delete ${destroot}${prefix}/share/applications/openscad.desktop
    file delete ${destroot}${prefix}/share/pixmaps/openscad.png
}

