# -*- 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               github 1.0
PortGroup               xcode 1.0
PortGroup               xcodeversion 1.0

github.setup            quicksilver Quicksilver 1.3.1 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
maintainers             {ryandesign @ryandesign} openmaintainer
categories              aqua sysutils
license                 Apache-2
supported_archs         x86_64

description             OS X launcher utility app

long_description        Quicksilver is a launcher utility app for OS X which \
                        lets you access applications, documents, contacts, \
                        music and more\; browse your Mac’s filesystem using \
                        keywords and fuzzy matching\; manage content through \
                        drag and drop, or grabbing selected content \
                        directly\; and interact with installed applications \
                        through plugins.

homepage                https://qsapp.com

# Fetch from git instead of distfile because it needs submodules
fetch.type              git

post-fetch {
    system -W ${worksrcpath} "git submodule update --init"
}

set config_root         ${prefix}/share/QS

post-extract {
    file mkdir ${workpath}${config_root}
}

post-patch {
    reinplace -E "s|/tmp/QS|${workpath}${config_root}|" ${build.dir}/Configuration/Common.xcconfig
}

# Quicksilver uses new Objective-C features which require the MacOSX10.8 SDK when compiling on 10.7.
minimum_xcodeversions {11 4.4}
platform darwin 11 {
    configure.sdkroot ${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
}

# Blacklist compilers that don't support new Objective-C features.
# Blacklisting does not work because xcode portgroup doesn't recognize MacPorts compilers.
# https://trac.macports.org/ticket/40762
compiler.blacklist      *gcc* {clang < 421}

build.dir               ${worksrcpath}/${name}

xcode.project           ${name}.xcodeproj
xcode.target            {Quicksilver Distribution}
xcode.configuration     Release

post-build {
    # set Info.plist to be world-writable, so that regular users can
    # set preferences that require writing to Info.plist
    file attributes ${build.dir}/build/${xcode.configuration}/${name}.app/Contents/Info.plist -permissions a+rw
}

destroot {
    move ${workpath}${config_root} ${destroot}${config_root}
    move {*}[glob ${build.dir}/build/${xcode.configuration}/*.app] ${destroot}${applications_dir}
}

if {${os.major} < 11} {
    known_fail yes
    pre-fetch {
        ui_error "${name} @${version} requires Mac OS X 10.7 or greater."
        ui_error "You can download an older version of ${name} for your OS from ${homepage}download.php"
        return -code error "incompatible Mac OS X version"
    }
}

livecheck.type          regex
livecheck.version       ${version}
livecheck.url           https://github.qsapp.com/
livecheck.regex         {>Quicksilver ([0-9.]+)}
