# -*- 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

PortSystem          1.0
PortGroup           cmake 1.1
PortGroup           qt4 1.0
PortGroup           github 1.0

conflicts           stellarium
github.setup        Stellarium stellarium 75d3f92af766dbeb92a1d89ff682233bec66587b
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball

name                stellarium-qt4
version             0.12.11-20190501
revision            1
categories          science
license             GPL-2+
maintainers         nomaintainer

description         Stellarium is a free open source planetarium for your computer. \
                    This older version is the last version based on qt4 which may \
                    run, or run more efficiently, on older or less powerful systems.
long_description    {*}${description} It has been updated with some fixes and features \
                    found in later versions of Stellarium.

homepage            http://stellarium.org/

checksums           rmd160  5f63a134009b478fb1ba1b8f2de8179a43a8c553 \
                    sha256  f7adb816d76d49c219c43d2da5968dcbbc3d7c16685b190c38079f83cd04b5a1 \
                    size    111785689

depends_lib-append  port:freetype \
                    port:zlib \
                    port:libiconv \
                    path:lib/libssl.dylib:openssl \
                    port:phonon

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

    # be more liberal with the allowed system versions
    reinplace "s:10.6.0:10.4.11:" ${worksrcpath}/data/Info.plist

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

# 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
    move {*}[glob ${appdir}/Resources/stellarium/*] ${appdir}/Resources/
    delete ${appdir}/Resources/stellarium

    # copy .app-specific files
    copy ${worksrcpath}/data/Info.plist ${appdir}
    copy ${worksrcpath}/data/PkgInfo ${appdir}
    copy ${worksrcpath}/data/Icon.icns ${appdir}/Resources/

    # copy other useful file(s)
    copy ${worksrcpath}/util/qt.conf ${appdir}/Resources/
}


notes "
The SSL support in this older Stellarium version may not be able to\
download the star files from various https sites. Until this is fixed\
(if it is fixed) you can download these files manually using wget or curl\
or a similar current downloader.

The list of files that Stellarium attempts to download are stored in:
~/Library/Application Support/Stellarium/log.txt

The star files are downloaded into:
~/Library/Application Support/Stellarium/stars/default/

Note, you must delete the file from a previously failed download attempt if it exists \
to have a successful download using wget. These commands will download \
the first two large star catalogs:

cd ~/Library/Application\ Support/Stellarium/stars/default
wget https://github.com/Stellarium/stellarium-data/releases/download/stars-2.0/stars_4_1v0_2.cat
wget https://github.com/Stellarium/stellarium-data/releases/download/stars-2.0/stars_5_2v0_1.cat

"

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

livecheck none
