# $Id: Portfile 50572 2009-05-04 19:19:09Z jeremyhu@macports.org $

PortSystem 1.0

name            emacs
version         22.3
revision        1
categories      editors
maintainers     gmail.com:darren.bane
description     The GNU Emacs text editor (command line only)
long_description \
    GNU Emacs is a self-documenting, customizable, extensible real-time \
    display editor. Users new to Emacs will be able to use basic        \
    features fairly rapidly by studying the tutorial and using the      \
    self-documentation features. Emacs also has an extensive            \
    interactive manual browser. It is easily extensible since its       \
    editing commands are written in Lisp.

platforms       darwin freebsd
homepage        http://www.gnu.org/software/emacs/emacs.html
master_sites    gnu
checksums       md5 aa8ba34f548cd78b35914ae5a7bb87eb
patchfiles	patch-Makefile.in.diff \
		patch-leim-Makefile.in.diff
configure.args  --without-x \
                --without-carbon

depends_lib     port:ncurses

post-destroot {
    xinstall -d ${destroot}${prefix}/share/emacs/${version}/leim
    delete ${destroot}${prefix}/bin/ctags
    delete ${destroot}${prefix}/share/man/man1/ctags.1
    if {[variant_isset carbon]} {
        global version
        delete ${destroot}${prefix}/bin/emacs ${destroot}${prefix}/bin/emacs-${version}
    }
}

platform darwin 7 {
    depends_build-append    port:autoconf
}

livecheck.check regex
livecheck.url   http://ftp.gnu.org/gnu/emacs/?C=M&O=D
livecheck.regex ${name}-(\\d+\\.\\d+\\w*)\\.tar

variant x11 description {Builds emacs as a X11 program with Lucid widgets} {
    configure.args-delete   --without-x
    configure.args-append   --with-x-toolkit=lucid \
                            --without-carbon \
                            --with-xpm \
                            --with-jpeg \
                            --with-tiff \
                            --with-gif \
                            --with-png
    depends_lib-append      port:xorg-libXmu \
                            port:xpm \
                            lib:libjpeg:jpeg \
                            lib:libtiff:tiff \
                            path:include/gif_lib.h:giflib \
                            lib:libpng:libpng
}

variant motif requires x11 description {Builds emacs as an X11 program with Motif widgets} {
    configure.args-delete   --with-x-toolkit=lucid
    configure.args-append   --with-x-toolkit=motif
    depends_lib-append      lib:libXm:openmotif
}

variant gtk requires x11 description {Builds emacs as an X11 program with GTK+2 widgets} {
    configure.args-delete   --with-x-toolkit=lucid
    configure.args-append   --with-x-toolkit=gtk
    depends_lib-append      lib:libgtk.2:gtk2 \
                            lib:libglib.2:glib2
}

variant carbon conflicts x11 description {Adds a Mac (Carbon) version of Emacs} {
    configure.args-delete   --without-carbon
    configure.args-append   --with-carbon \
                            --enable-carbon-app=${applications_dir}
}

variant atsui requires carbon description {Adds a Mac (Carbon) version of Emacs that uses the ATSUI protocol} {
    configure.cflags-append -DUSE_ATSUI
}

