$Id$

PortSystem 1.0
PortGroup  muniversal 1.0

name            emacs-snapshot
version         20110408
revision        1

categories      editors
maintainers     dports openmaintainer
description     The GNU Emacs text editor
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    http://emacs.naquadah.org/unstable/
distfiles       ${name}_${version}.orig.tar.xz

checksums           md5     40017fbea3a5bc5c26ae12014ded7464 \
                    sha1    2cfc069868ca62f672c8deb970c5d1aaf888fb2a \
                    rmd160  fcff524894c3da6896be00a85c4b8be0de9e8f0c

pre-configure {
    system "cd ${worksrcpath}; sh ./autogen.sh"
}

configure.args  --without-x \
                --with-dbus \
                --without-gconf \
                --without-libotf \
                --without-m17n-flt \
                --without-gpm \
                --infodir ${prefix}/share/info/${name}

use_xz	yes

depends_build   port:pkgconfig \
                bin:unlzma:lzmautils 

depends_lib     port:ncurses \
                port:dbus \
                port:texinfo

post-destroot {
    xinstall -d ${destroot}${prefix}/share/emacs/${version}/leim
    delete ${destroot}${prefix}/bin/ctags
    delete ${destroot}${prefix}/share/man/man1/ctags.1
}

livecheck.type  regex
livecheck.url   http://emacs.naquadah.org/unstable/?C=M&O=D
livecheck.regex ${name}_(\\d+\\w*)\\.orig.tar.xz

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-xaw3d \
                            --with-xpm \
                            --with-jpeg \
                            --with-tiff \
                            --with-gif \
                            --with-png \
                            --without-rsvg \
                            --with-xft 
    depends_lib-append      port:xorg-libXmu \
                            port:xorg-libXaw \
                            port:xpm \
                            port:jpeg \
                            port:tiff \
                            port:giflib \
                            port:libpng \
                            port:Xft2

    # autoconf appears to be dropping linker flags for freetype &
    # fontconfig; work around this. See #28083
    configure.ldflags-append -lfreetype -lfontconfig
}

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-delete   --without-gconf
    configure.args-delete   --without-rsvg
    configure.args-append   --with-x-toolkit=gtk
    configure.args-append   --with-gconf
    configure.args-append   --with-rsvg
    depends_lib-append      port:gtk2 \
                            port:glib2 \
                            port:gconf \
                            port:librsvg
}
