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

name                Cenon
version             4.0.6
revision            0
set library_version 4.0.0
categories          aqua graphics
platforms           darwin
maintainers         nomaintainer
description         Modular Graphics Application
long_description    Cenon is a graphical tool kernel.  Built upon a modular \
                    graphical core, Cenon offers a wide variety of \
                    possible applications.  The default install \
                    includes support for desktop publishing, vector \
                    graphics conversion (PostScript, PDF, DXF, HPGL \
                    Gerber, DIN, and more), graphics (TIFF, GIF, JPEG, \
                    etc.), Typography (font import, text rotation), and \
                    some rudimentary drafting features.

homepage            http://www.cenon.info/
master_sites        http://www.cenon.zone/download/source/

distfiles           Cenon-${version}.tar.bz2 \
                    CenonLibrary-${library_version}-1.tar.bz2
                
checksums           Cenon-${version}.tar.bz2 \
                    rmd160  e8e05629f1cbfbb3959d480f1056f45e468fb3ae \
                    sha256  e31cdfd3bd4df86e1f96561bdb73ee31bf977e0d755886fc877e892eac6ae862 \
                    size    10931177 \
                    CenonLibrary-${library_version}-1.tar.bz2 \
                    rmd160  5d2f9bd2e1c3838c839c324202563ccb44706f10 \
                    sha256  b329331a4b5b40d93eeeddd98f6922a53401b6e4f437538cd98392f8828cbb44 \
                    size    2131692

use_bzip2           yes

platform darwin {
    if {${os.major} < 12} {
        # PreferencesPanel.subproj/General.bproj/French.lproj/General.xib: error: The document "General.xib" could not be opened. Could not read archive.
        #     Failure Reason: This version of Xcode is too old to read this arch
        #     Recovery Suggestion: Please use a newer version of Xcode. Consider changing the document's Development Target to preserve compatibil
        known_fail  yes
        pre-fetch {
            ui_error "${name} @${version} requires OS X 10.8 Mountain Lion or later"
            return -code error "incompatible Mac OS X version"
        }
    }
}

# This is a temporary kludge. The new Xcode build system fails to
# destroot this for reasons that are poorly understood.
# Remove this when a better fix is known.
if {[vercmp ${xcodeversion} 10.0] >= 0} {
    destroot.pre_args   -UseNewBuildSystem=NO
}

worksrcdir          Cenon

patchfiles          patch-App.m.diff \
                   patch-functions.m.diff \
                    patch-VHFShared-vhfCommonFunctions.m.diff

post-patch {
    reinplace "s|%PREFIX%|${prefix}|g" \
        ${worksrcpath}/functions.m \
        ${worksrcpath}/VHFShared/vhfCommonFunctions.m
}

use_configure       no

set xcodebuilddir   build

xcode.project       ${name}.xcodeproj
xcode.configuration Release

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/Library/Application\ Support/${name}
    copy ${worksrcpath}/Devices ${worksrcpath}/Documentation \
        ${worksrcpath}/Examples ${worksrcpath}/Projects \
        ${destroot}${prefix}/Library/Application\ Support/${name}/
}
