# $Id: Portfile 64265 2010-02-27 22:39:35Z raimue@macports.org $

PortSystem 1.0

name            stellarium
version         0.10.4
categories      science
platforms       darwin
maintainers     raimue \
                openmaintainer

description     Stellarium is a free open source planetarium for your computer.
long_description \
    Stellarium is a free open source planetarium for your computer. \
    It shows a realistic sky in 3D, just like what you see with the naked eye, \
    binoculars or a telescope. It is being used in planetarium projectors. Just \
    set your coordinates and go.
homepage        http://stellarium.org/

master_sites    sourceforge
checksums       md5     ebb81f609c91be6ecd7e91cf7d3a4afa \
                sha1    8a9f22da5a0049ea10b19b24d28490dc15dea1a8 \
                rmd160  ed2ea67c905adb211266df29dca2f8ed1626ad8e

depends_build   port:cmake
depends_lib     port:boost port:libsdl_mixer path:lib/pkgconfig/sdl.pc:libsdl path:bin/qmake-mac:qt4-mac port:freetype

post-patch {
    reinplace "s:SET(CMAKE_INSTALL_PREFIX \"\$\{PROJECT_BINARY_DIR\}/:SET\(CMAKE_INSTALL_PREFIX \"${applications_dir}/:" ${worksrcpath}/CMakeLists.txt

    # Determine which archs to build
    if {[variant_isset universal]} {
        set archs ${configure.universal_archs}
    } else {
        set archs ${configure.build_arch}
    }
    reinplace "s:SET(CMAKE_OSX_ARCHITECTURES \"i386\"):SET(CMAKE_OSX_ARCHITECTURES \"${archs}\"):" ${worksrcpath}/CMakeLists.txt
}

configure.cmd       cmake
# cmake is unable to find FreeType2, so specify it here
configure.pre_args  -DFreeType2_INCLUDE_DIR:PATH=${prefix}/include/freetype2 \
                    -DFreeType2_LIBRARIES:FILEPATH=${prefix}/lib/libfreetype.dylib
configure.args      -DQT_QMAKE_EXECUTABLE=${prefix}/libexec/qt4-mac/bin/qmake \
                    -G \"Unix Makefiles\" .

# This post-destroot phase is similar to the 'make macosx_bundle' target,
# but it does not copy libraries into the bundle and does not require perl as
# another dependency
post-destroot {
    set appdir ${destroot}${applications_dir}/Stellarium.app/Contents

    move ${appdir}/bin ${appdir}/MacOS
    move ${appdir}/share ${appdir}/Resources
    eval move [glob ${appdir}/Resources/stellarium/*] ${appdir}/Resources/
    delete ${appdir}/Resources/stellarium
}

# Supports universal builds through cmake, archs are set in post-patch
variant universal {}

livecheck.url http://sourceforge.net/projects/stellarium/files/
livecheck.regex "Stellarium-sources/.*/stellarium-(.*)[quotemeta ${extract.suffix}]"
