# -*- 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
# $Id: Portfile 92888 2012-05-10 07:39:36Z jwa@macports.org $

PortSystem      1.0
PortGroup       xcode 1.0

name            TeXShop3
conflicts	TeXShop
version         3.08

categories      aqua editors
license         GPL-2+
maintainers     jwa openmaintainer
description     TeX previewer for Mac OS X
long_description   \
    TeXShop is a TeX previewer for Mac OS X, written in Cocoa.  \
    Since pdf is a native file format on OS X, TeXShop uses     \
    "pdftex" and "pdflatex" rather than "tex" and "latex" to    \
    typeset, these programs in the standard teTeX distribution  \
    of TeX produce pdf output instead of dvi output.
homepage        http://www.uoregon.edu/~koch/texshop/texshop.html
master_sites    http://pages.uoregon.edu/koch/texshop/texshop-64
use_zip         yes
distname        texshopsource
dist_subdir     TeXShop/${version}_${revision}
worksrcdir      texshop-${version}
set propername	TeXShop

checksums           rmd160  32f7c5ae07f19b74c57de8b706525216122e850d \
                    sha256  ac79e83cdd3c230f910d478862c0637aeb5d55cf19a1a313fd4cb687690769cf

pre-fetch {
    platform darwin {
        if {${os.major} < 11} {
            ui_error "${name} requires at least 10.7, Lion"
            return -code error	"This version is for 10.7, Lion, and later only"
        }
    }
}

post-extract    {
    set sparkle "Sparkle.framework/Versions/A/Sparkle"
    set ogrekit "OgreKit.framework/Versions/A/OgreKit"
    if {![variant_isset universal]} {
        # thin the bundled frameworks
        system "cd ${worksrcpath} && lipo -thin ${configure.build_arch} $sparkle -output $sparkle"
        system "cd ${worksrcpath} && lipo -thin ${configure.build_arch} $ogrekit -output $ogrekit"
    }
}

build.target    ${propername}

xcode.project   ${propername}.xcodeproj
xcode.configuration Release
xcode.build.settings    FRAMEWORK_SEARCH_PATHS=${worksrcpath} \
                        CONFIGURATION_BUILD_DIR=${worksrcpath}/build

destroot.target     ${propername}
eval xcode.destroot.settings INSTALL_MODE_FLAG=755 ${xcode.build.settings}

post-destroot        {
    file delete -force ${destroot}${applications_dir}/TeX.mdimporter
}

livecheck.type      regex
livecheck.url       http://pages.uoregon.edu/koch/texshop/version.html
livecheck.regex     ${propername} Changes (\\d+\\.\\d+)
