# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           xcode 1.0

github.setup        alexzielenski Mousecape 1813
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          aqua sysutils
maintainers         {i0ntempest @i0ntempest} openmaintainer
license             unknown

description         Cursor Manager for macOS/OS X
long_description    A free cursor manager for Mac OS X 10.8+ built using private, nonintrusive CoreGraphics APIs.

checksums           rmd160  4d24c3894623bb8e7610c9075862077946a1aee9 \
                    sha256  aad2e8ce6873e16601275be54718c067537a944715662290ddaa9da148071b89 \
                    size    4903492

build.dir           ${worksrcpath}/${name}
xcode.target        mousecloak com.alexzielenski.mousecloakhelper ${name}
xcode.configuration Release

patchfiles-append   patch-remove-sparkle.diff \
                    patch-CGSRrgisterCursorImages.diff
patch.args          -p1

post-patch {
    # Disable Sparkle without messing with xib files
    system -W ${build.dir}/${name} "/usr/libexec/PlistBuddy -c \"Delete :SUFeedURL\" ${name}-Info.plist"
    # Fix version
    system -W ${build.dir}/${name} "/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString [expr ${version}-1]\" ${name}-Info.plist"
    system -W ${build.dir}/${name} "/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion [expr ${version}-1]\" ${name}-Info.plist"
}

if {${os.major} >= 22} {
    xcode.build.settings-append \
        CODE_SIGN_IDENTITY=-
} else {
    xcode.build.settings-append \
        CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO
}

destroot {
    file copy ${build.dir}/build/${xcode.configuration}/${name}.app ${destroot}${applications_dir}
    ln -s ${applications_dir}/${name}.app/Contents/MacOS/mousecloak ${destroot}${prefix}/bin/
}
