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

name              eiffelstudio
set major_version 25.02
set minor_version 98732
version           ${major_version}.${minor_version}
categories        lang
license           GPL-2
maintainers       {jann @roederja} {gmail.com:javier.hector @jvelilla} {eiffel.com:jfiat @jocelyn} {eiffel.com:eifops @eiffeldev} openmaintainer
description       The ISE Eiffel Compiler and IDE
long_description  EiffelStudio is a development environment for the \
                  Eiffel programming language developed by Eiffel Software. \
                  EiffelStudio includes a combination of tools integrated under \
                  a single user interface: compiler, interpreter, debugger, \
                  browser, metrics tool, profiler, diagram tool. \
                  The user interface rests on a number of specific UI paradigms, \
                  in particular "pick-and-drop" for effective browsing.
homepage          https://www.eiffel.com
master_sites      ${homepage}/cdn/EiffelStudio/${major_version}/${minor_version}/pp/:source
depends_lib       path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                  path:lib/pkgconfig/xtst.pc:xorg-libXtst \
                  port:adwaita-icon-theme
depends_build     bin:bzip2:bzip2 \
                  port:pkgconfig
use_tar           yes

set porterpackage PorterPackage_${major_version}_rev_${minor_version}${extract.suffix}
distfiles         ${porterpackage}:source 
extract.only      ${porterpackage}
worksrcdir        PorterPackage

checksums         ${porterpackage} \
                  rmd160  9069c6800e7bf0f20129707bc38315b96185a23c \
                  sha256  fd7a1ec2a09e87535f077bdef542fed1665f6790c46b837b44497aec5b65c6dd \
                  size    98037760

use_configure     no

platform darwin {
    switch -- ${configure.build_arch} {
        arm64 {
            set ise_platform macosx-armv6
        }
        i386 {
            set ise_platform macosx-x86
        }
        ppc {
            set ise_platform macosx-ppc
        }
        x86_64 {
            set ise_platform macosx-x86-64
        }
    }
}

if {![info exists ise_platform]} {
                       set ise_platform undefined
}

build             {                   
                    system -W ${worksrcpath} "env CC=${configure.cc} ${worksrcpath}/compile_exes $ise_platform"
                    # Make sure we only build one edition
                    file delete ${worksrcpath}/bin/ecb_ent.tar.bz2
                    
                    system -W ${worksrcpath} "${worksrcpath}/make_images $ise_platform"
                  }

destroot          {
                    xinstall -m 755 -d ${destroot}${applications_dir}

                    system "tar -xjf ${worksrcpath}/Eiffel_${major_version}_rev_[string map { "." "" } ${minor_version}]-${ise_platform}.tar.bz2 -C ${destroot}${applications_dir}/"

                  }

notes "
To complete the installation you have to install either XQuartz from www.xquartz.org or the xorg-server port. \n\
Also, you need to add the following to your .zshenv or .zprofile file : \n\
export ISE_PLATFORM=$ise_platform \n\
export ISE_EIFFEL=${applications_dir}/Eiffel_${major_version} \n\
export PATH=\$PATH:\$ISE_EIFFEL/studio/spec/\$ISE_PLATFORM/bin:\$ISE_EIFFEL/library/gobo/spec/\$ISE_PLATFORM/bin:\$ISE_EIFFEL/tools/spec/\$ISE_PLATFORM/bin \n\
"
