PortSystem        1.0

name              eiffelstudio
set major_version 24.05
set minor_version 107822
version           ${major_version}.${minor_version}
categories        lang
license           GPL-2
maintainers       {jann @roederja} {javierv @jvelilla} 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  c591a049c49ca23237bbfec4888546b1ea8099d9 \
                  sha256  ca3f2f428568eea7823a1a8bd0d66713b5cadb051cada956a0d3b85a0022621c \
                  size    88320000

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\
"