# -*- 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: Portfile 104704 2013-04-01 03:14:41Z jeremyhu@macports.org $

PortSystem          1.0

name                emacs-app
version             24.3
revision            1
categories          aqua editors
maintainers         hum css openmaintainer

description         The GNU Emacs text editor (Cocoa version)

long_description    GNU Emacs is a self-documenting, customizable, extensible  \
                    real-time display editor. This is a port of the latest GNU \
                    Emacs source to the OpenStep (or NeXTstep) APIs, as        \
                    implemented by Cocoa on OS X. It differs from Carbon ports \
                    of GNU Emacs in that it makes a more concerted attempt     \
                    from the ground up to follow OS X desktop and UI conventions.

homepage            http://www.gnu.org/software/emacs/
platforms           darwin
license             GPL-3+

master_sites        gnu:emacs
distname            emacs-${version}
dist_subdir         emacs
checksums           rmd160  b67e847861002bbb76ae6588ff659408763313cf \
                    sha256  0098ca3204813d69cd8412045ba33e8701fa2062f4bff56bedafc064979eef41

conflicts           emacs-app-devel

depends_build       port:pkgconfig

depends_lib         port:ncurses \
                    port:libxml2 \
                    port:gnutls

patchfiles          patch-src_emacs.c.diff

post-patch {
    reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/src/emacs.c
}

configure.args      --with-ns --without-x --without-dbus

universal_variant   no

destroot {
    system -W ${worksrcpath} "make install"
    xinstall -m 755 -d ${destroot}${applications_dir}
    file copy ${worksrcpath}/nextstep/Emacs.app \
        ${destroot}${applications_dir}
    file copy ${filespath}/site-start.el \
        ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp
    reinplace "s|__PREFIX__|${prefix}|g" \
        ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
}

variant fullscreen description {Obsolete compatibility variant} {}

variant oldfullscreen description {Obsolete compatibility variant} {}

variant inline description {Apply inline patch from MacEmacsJP} {
    # inline patch fetched from MacEmacsJP.
    # patch-macemacsjp-inline.diff
    # http://svn.sourceforge.jp/svnroot/macemacsjp/inline_patch/trunk/emacs-inline.patch
    # revision 582 (2012/05/20) modified for emacs-24.3.
    patchfiles-append   patch-macemacsjp-inline.diff
    # http://sakito.jp/emacs/emacs24.html
    depends_build-append port:autoconf port:automake port:libtool
    build.target        bootstrap
}

variant jpfont requires inline description {Obsolete compatibility variant} {}

variant patches requires inline description {Obsolete compatibility variant} {}

default_variants    +inline

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