# $Id: Portfile 52067 2009-06-09 17:20:10Z jeremyhu@macports.org $

PortSystem          1.0

name                xinit
version             1.1.1
revision            4
categories          x11
platforms           darwin
maintainers         jeremyhu
description         X11 startup script processor
long_description    xinit is responsible for configuring the initial environment \
		    when X11 starts up.

homepage            http://www.x.org
master_sites        http://xorg.freedesktop.org/archive/individual/app/

checksums           md5     93c73705ed9eb1e1a6b6938405672f2b \
                    sha1    577a111efc9b5a8ec6cc294ae7c35048eebde704 \
                    rmd160  bed92df836e14c78876afa1eed41dabd4859e77d

use_bzip2	    yes
use_parallel_build  yes

depends_run         bin:xauth:xauth \
                    bin:xset:xset \
                    bin:xrdb:xrdb \
                    port:mkfontscale \
                    port:mkfontdir

depends_build       port:pkgconfig \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:xorg-libX11

use_autoreconf yes
autoreconf.args -fvi

patchfiles sl.patch
patch.args -p1

post-patch {
	reinplace "s|org.x|org.macports|" ${worksrcpath}/privileged_startx/org.x.privileged_startx.plist.cpp
	reinplace "s|org.x|org.macports|" ${worksrcpath}/privileged_startx/privileged_startx_types.h
	reinplace "s|org.x|org.macports|" ${worksrcpath}/privileged_startx/server.c
	reinplace "s|org.x|org.macports|" ${worksrcpath}/startx.cpp
}

post-destroot {
	file delete -force ${destroot}/Library/LaunchAgents/org.x.startx.plist
	move ${destroot}/Library/LaunchDaemons/org.x.privileged_startx.plist ${destroot}/Library/LaunchDaemons/org.macports.privileged_startx.plist

	xinstall -d ${destroot}${prefix}/lib/X11/xinit/xinitrc.d
	eval xinstall -m 755 [glob ${filespath}/xinitrc.d/*.sh] ${destroot}${prefix}/lib/X11/xinit/xinitrc.d
	reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${prefix}/lib/X11/xinit/xinitrc.d/99-quartz-wm.sh

	xinstall -m 755 ${filespath}/font_cache.sh ${destroot}${prefix}/bin/font_cache
	reinplace "s|^X11DIR=.*$|X11DIR=${prefix}|" ${destroot}${prefix}/bin/font_cache
	reinplace "s|^X11FONTDIR=.*$|X11FONTDIR=${prefix}/share/fonts|" ${destroot}${prefix}/bin/font_cache
}
