# $Id$

PortSystem      1.0

name            xemacs
conflicts       emacs
version         21.4.22
revision        4
set sumo_date   2009-02-17
categories      editors x11
platforms       darwin
maintainers     nomaintainer
description     A highly customizable open source text editor.

long_description \
    XEmacs is a highly customizable open source text editor and application development \
    system. It is protected under the GNU Public License and related to other versions of \
    Emacs, in particular GNU Emacs.

homepage        http://www.xemacs.org
master_sites    http://ftp.xemacs.org/pub/xemacs/xemacs-21.4/:xemacs \
                ftp://ftp.xemacs.org/pub/xemacs/xemacs-21.4/:xemacs \
                http://ftp.xemacs.org/pub/xemacs/packages/:package \
                ftp://ftp.xemacs.org/pub/xemacs/packages/:package \
                http://mirrors.ibiblio.org/pub/mirrors/xemacs/packages/:package

use_bzip2       yes
set xemacs_dist ${name}-${version}${extract.suffix}
set sumo_dist   ${name}-sumo-${sumo_date}${extract.suffix}
set mule_dist   ${name}-mule-sumo-${sumo_date}${extract.suffix}

distfiles       ${xemacs_dist}:xemacs ${sumo_dist}:package ${mule_dist}:package

checksums           xemacs-${version}.tar.bz2 \
                    md5     060bf7565cb3233c6e7071354e9a23a4 \
                    sha1    67876eb2bbedc02e7b660db8b4c31b5b98be865e \
                    rmd160  0e747204bda24b1b1520b81a301f7c8573a76231 \
                    xemacs-sumo-2009-02-17.tar.bz2 \
                    md5     4ccf48e0ef0c37858dd0240f6343402a \
                    sha1    13eab46524c8e9070e71289c06d49e831e48b7b2 \
                    rmd160  a9912b3720e2b6d91017f14b6e5c11275acdeefd \
                    xemacs-mule-sumo-2009-02-17.tar.bz2 \
                    md5     e24b5544961e8f56e6adf1742eaf4078 \
                    sha1    dc50bc3b62e5ff1cd766c7e4f31880bd200caad5 \
                    rmd160  506b7465687ff9dafe26f46e049b6aad8915eb49

configure.args  --mandir=${prefix}/share/man \
                --without-postgresql \
                --without-ldap \
                --with-sound=none \
                --pdump \
                --site-prefixes=${prefix} \
                --with-tty \
                --with-dialogs=athena \
                --with-widgets=athena \
                --with-athena=3d \
                --with-database=gdbm \
                --with-mule

depends_build   port:xbitmaps
depends_lib     port:libpng port:Xaw3d port:ncurses port:gdbm port:jpeg \
                port:tiff port:compface port:gettext port:zlib

destroot.args   prefix=${destroot}${prefix} mandir=${destroot}${prefix}/share/man/man1

destroot.keepdirs ${destroot}${prefix}/lib/xemacs
post-destroot {
    set xemacs_lib ${destroot}${prefix}/lib/xemacs-${version}
    xinstall -d -m 0755 ${xemacs_lib}
    system "cd ${destroot}${prefix}/lib && ln -s xemacs-${version} xemacs"
    if {[file exists ${workpath}/mule-packages]} {
        ui_debug "Installing mule-sumo distribution into destroot"
        file copy ${workpath}/mule-packages ${xemacs_lib}/
    }
    if {[file exists ${workpath}/xemacs-packages]} {
        ui_debug "Installing sumo distribution into destroot"
        file copy ${workpath}/xemacs-packages ${xemacs_lib}
    }
}

variant no_sumo \
    description "do not install sumo and mule" {
    configure.args-delete --with-mule
    depends_lib-delete    port:gettext
    distfiles-delete      ${sumo_dist}:package ${mule_dist}:package
}

# https://trac.macports.org/ticket/31679
if {${configure.compiler} == "clang"} {
    configure.cflags-append -std=c89
}
if {${os.major} >= 11 && ${os.platform} == "darwin"} {
    configure.ldflags-append -Wl,-no_pie
}