# -*- 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 115376 2014-01-01 05:10:25Z jeremyhu@macports.org $

PortSystem              1.0
PortGroup               cmake 1.0
PortGroup               wxWidgets 1.0

name                    hugin-app
version                 2013.0.0
revision                3
set branch              [join [lrange [split ${version} .] 0 1] .]
categories              graphics
maintainers             nomaintainer
description             Panorama photo stitcher
long_description        An easy to use cross-platform panoramic imaging \
                        toolchain based on Panorama Tools. With hugin you \
                        can assemble a mosaic of photographs into a complete \
                        immersive panorama, stitch any series of overlapping \
                        pictures and much more.

homepage                http://hugin.sourceforge.net
platforms               darwin

master_sites            sourceforge:project/hugin/hugin/hugin-${branch}
distname                hugin-${version}
use_bzip2               yes

wxWidgets.use           wxWidgets-3.0

depends_build-append    port:pkgconfig
depends_lib             port:boost \
                        port:exiv2 \
                        port:flann \
                        port:gettext \
                        port:glew \
                        port:ilmbase \
                        port:jpeg \
                        port:lensfun \
                        port:libpano13 \
                        port:libpng \
                        port:libxml2 \
                        port:openexr \
                        port:swig-python \
                        port:tclap \
                        port:tiff \
                        port:python27 \
                        port:${wxWidgets.port}


# TODO dependencies:
# - freeglut or glut, the OpenGL utility toolkit
# - optionally, lapack
# - for the optional Python Scripting Interface (currently functional and tested only on Linux and Windows)
#     Python version >=2.6
#     SWIG >=2.0 - If Python >=3.2, SWIG must be >=2.0.4
#
# NOTE: maybe the problem was that if swig is installed,
#       it gets detected and then requires swig-python
#       and additional python definitions, else it fails to bulid

# TODO: try to see where MAC_SELF_CONTAINED_BUNDLE gets defined

# patch-src-foreign-vigra-vigra-cachedfileimage.hxx.patch - https://bugs.launchpad.net/bugs/1213586
# patch-src-foreign-zthread-include-zthread-Guard.h.diff  - https://bugs.launchpad.net/bugs/1213585
# patch-src-hugin1-hugin1.pch.diff                        - moderately helps with compiler issues
patchfiles              patch-src-foreign-vigra-vigra-cachedfileimage.hxx.patch \
                        patch-src-foreign-zthread-include-zthread-Guard.h.diff \
                        patch-src-hugin1-hugin1.pch.diff \
                        patch-src-hugin1-icpfind-AutoCtrlPointCreator.cpp.diff

depends_run             port:enblend \
                        port:p5.12-image-exiftool

checksums               md5     cc6c768df2aedc24a9a081754de05f39 \
                        sha1    0e0689cf2ca0c4a2730cffe06380eda976b6772d \
                        rmd160  73261aa925d6284c6950c84fbfdd77e8b0a2ee7d

# Per the README: "Hugin can be compiled with gcc-4.4.4, gcc-4.5.1, and gcc-4.6"
compiler.blacklist      gcc-* apple-gcc-* macports-gcc-4.2 macports-gcc-4.3

configure.cppflags-replace -I${prefix}/include -isystem${prefix}/include

# TODO: fix this
configure.args-append   -DINSTALL_OSX_BUNDLE_DIR=${applications_dir} \
                        -DPYTHON_EXECUTABLE=${frameworks_dir}/Python.framework/Versions/2.7/bin/python \
                        -DPYTHON_INCLUDE_DIR=${frameworks_dir}/Python.framework/Versions/2.7/include/python2.7 \
                        -DPYTHON_LIBRARY=${prefix}/lib/libpython2.7.dylib \
                        -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig} \
                        -DwxWidgets_wxrc_EXECUTABLE=${wxWidgets.wxrc}

# prevents some compiler errors
configure.cxxflags-append -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0

# recursive template instantiation exceeded maximum depth of 128
configure.cxxflags-append -ftemplate-depth-1024

livecheck.type          regex
livecheck.url           ${homepage}
livecheck.regex         Hugin-(\[.0-9\]+) released
