# -*- 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$
PortSystem      1.0
PortGroup       compilers 1.0

name            eso-blt84
conflicts       eso-blt84-devel
version         2.4
revision        12

set _name               blt
categories              x11
license                 MIT
maintainers     eso.org:usd-help
description             BLT is an extension to the Tk toolkit, adding new widgets, \
			geometry managers, and miscellaneous commands.
long_description        ${description}
  
homepage                http://blt.sourceforge.net/
platforms               darwin

#master_sites            sourceforge:blt/BLT/BLT%20${version}
master_sites            https://ftp.eso.org/pub/usg/eso-blt
dist_subdir             eso-tcltk
distname		BLT${version}
distfiles               eso-blt2.4.tar.gz

worksrcdir		blt${version}

checksums           md5     75a000636595060865077d45a21e72ef \
                    rmd160  6f9ecf386d194b82b95a1263acb11a7291614a7a \
                    sha256  f45775794f35beacf7dd1248fd8df7c4a634a54bfc0f655bcfcb362b866d614a

depends_build \
      port:xorg-libX11 \
      port:gsed
depends_run \
			port:eso-tk84

use_parallel_build      no

compilers.choose    cc cxx
compilers.setup     gcc 

default_variants  +${compilers.gcc_default}

prefix              /opt/local/libexec/eso/tcltk-8.4
destroot.destdir    INSTALL_ROOT=${destroot}

configure.optflags      -O3
configure.cflags-append -fno-common
if { [gcc_variant_isset] && [compilers::get_current_gcc_version] >= 14 } {
  configure.cflags-append  \
          -Wno-incompatible-pointer-types \
          -Wno-implicit-function-declaration \

}

configure.args	\
    	--exec_prefix=${prefix} \
			--bindir=${prefix}/bin \
			--includedir=${prefix}/include \
			--libdir=${prefix}/lib \
      --mandir=${prefix}/share/man \
			--with-tcllibs=${prefix}/lib \
			--with-tklibs=${prefix}/lib \
			--with-tclincls=${prefix}/include \
			--with-tkincls=${prefix}/include \
      --with-tcl=${prefix} \
      --with-tk=${prefix} \
      --x-includes=/opt/local/include \
			--x-libraries=/opt/local/lib 


post-patch {
  system "gsed -i \
    -e 's%pkgIndex.tcl \$(scriptdir).*%pkgIndex.tcl \$(INSTALL_ROOT)\$(scriptdir)%' ${worksrcpath}/library/Makefile.in"

  system "gsed -i \
    -e 's%INSTALL_DIR%INSTALL_ROOT%g' ${worksrcpath}/Makefile.in"
    
  system "gsed -i \
    -e's%^SHLIB_TCL_ONLY_LIB_SPECS.*%SHLIB_TCL_ONLY_LIB_SPECS = -install_name \${libdir}/\${tcl_only_lib_so}%' ${worksrcpath}/src/shared/Makefile.in"

  system "gsed -i \
    -e 's%^SHLIB_LIB_SPECS.*%SHLIB_LIB_SPECS = -install_name \${libdir}/\${lib_so}%' ${worksrcpath}/src/shared/Makefile.in"
}

post-destroot {
    
    delete ${destroot}${prefix}/share/man/mann/busy.n
    move ${destroot}${prefix}/share/man/mann/bitmap.n ${destroot}${prefix}/share/man/mann/blt-bitmap.n
}
