PortSystem          1.0

name                geoexpress-sdk
version             9.5.4.4709
maintainers         {vince @Veence}
platforms           darwin
description         LizardTech's SDK for reading MrSID and JPEG 2000 imagery
long_description    LizardTech's SDK for reading MrSID and JPEG 2000 imagery. This \
                    SDK is NOT open source software, and must be downloaded \
                    manually from https://www.extensis.com/support/developers \
                    Please carefully review the SDK agreement prior to downloading \
                    and installing this software.
homepage            https://www.extensis.com/support/developers
master_sites        https://bin.extensis.com/download/developer/
categories          gis
license             Restrictive NoMirror

if { ${os.major} >= 16 } {
    distname        MrSID_DSDK-${version}-darwin16.universal.clang80
    worksrcdir      MrSID_DSDK-${version}-darwin16.universal.clang80
    checksums       rmd160  1afa1c4bf109712cfbc436c20431cf102ca7a175 \
                    sha256  086f5dd508484e7ad915fb76ab962e96099b37ca8d759a0112d51eaa007cb488 \
                    size    56829152

} elseif { ${os.major} == 15 } {
    distname        MrSID_DSDK-${version}-darwin15.universal.clang70
    worksrcdir      MrSID_DSDK-${version}-darwin15.universal.clang70
    checksums       rmd160  05b120821507a71eb3dac2a1b20ecb8bce016210 \
                    sha256  b5a067659451a9178cab165640071a004f03a8dd90f8a73bf3e3934528951079 \
                    size    56759213
} else {
  pre-fetch {
    ui_error "${name} ${version} requires Mac OS X 10.11 or greater."
    return -code error "incompatible Mac OS X version"
  }
}

fetch {
    file mkdir ${distpath}
    if {![file exists ${distpath}/${distfiles}]} {
        ui_error "NOTE: Due to licensing restrictions, '${distfiles}' must be manually downloaded from ${homepage}"
        ui_error "and placed in ${distpath} for example using: ‘sudo cp ~/Downloads/${distfiles} ${distpath}'"
    }
}

use_configure no
build {}

destroot {
    set     SID_RST ${prefix}/share/Geo_DSDK/Raster_DSDK
    set     SID_LAS ${prefix}/share/Geo_DSDK/Lidar_DSDK

    copy    ${worksrcpath} ${destroot}${prefix}/share/Geo_DSDK

    # Tweak libraries
    system  "install_name_tool -id ${SID_RST}/lib/libltidsdk.9.dylib ${destroot}${SID_RST}/lib/libltidsdk.9.dylib"
    system  "install_name_tool -id ${SID_LAS}/lib/liblti_lidar_dsdk.dylib ${destroot}${SID_LAS}/lib/liblti_lidar_dsdk.1.dylib"
    system  "install_name_tool -id ${SID_RST}/lib/libtbb.dylib ${destroot}${SID_RST}/lib/libtbb.dylib"
    system  "install_name_tool -id ${SID_LAS}/lib/libtbb.dylib ${destroot}${SID_LAS}/lib/libtbb.dylib"
    system  "install_name_tool -change @rpath/libtbb.dylib ${SID_RST}/lib/libtbb.dylib ${destroot}${SID_RST}/lib/libltidsdk.9.dylib"
    system  "install_name_tool -change @rpath/libtbb.dylib ${SID_LAS}/lib/libtbb.dylib ${destroot}${SID_LAS}/lib/liblti_lidar_dsdk.1.dylib"
}