# $Id: Portfile 68247 2010-05-29 22:39:48Z jeremyhu@macports.org $

PortSystem 1.0

name		xorg-server
set my_name	xorg-server
version		1.8.1
revision        1
categories	x11 devel
maintainers	jeremyhu openmaintainer
description	The X.org / Xquartz X server.
homepage	http://www.x.org
platforms	darwin macosx
long_description The X.org X server allows you to run X11 applications on your computer.

#master_sites	http://xquartz.macosforge.org/downloads/src
master_sites    http://xorg.freedesktop.org/archive/individual/xserver/

dist_subdir     ${my_name}
distname        ${my_name}-${version}

checksums           md5     7c3b873692f4e93938261d774510e78d \
                    sha1    cba0d3b3d28696609a1f9b110d4d129cd066e133 \
                    rmd160  27bd6d1e565e241412f1fb8e18b5b9b194b94356

use_bzip2	yes
use_parallel_build yes

# Yes, mesa is a *BUILD* dependency
depends_build \
	port:pkgconfig \
	port:mesa \
	port:xorg-applewmproto \
	port:xorg-damageproto \
	port:xorg-fixesproto \
	port:xorg-fontsproto \
	port:xorg-glproto \
	port:xorg-inputproto \
	port:xorg-randrproto \
	port:xorg-recordproto \
	port:xorg-renderproto \
	port:xorg-resourceproto \
	port:xorg-scrnsaverproto \
	port:xorg-videoproto \
	port:xorg-xcmiscproto \
	port:xorg-xproto \
	port:xorg-xextproto \
	port:xorg-xineramaproto \
	port:xorg-xtrans \
	port:autoconf \
	port:automake \
	port:libtool \
	port:xorg-util-macros \
	port:doxygen

if {[info exists supported_archs]} {
        depends_skip_archcheck doxygen
}

# This xinit dependency needs to be port: not bin: because we specifically run ${prefix}/bin/startx from bundle-main.c
depends_run \
	port:xinit \
	port:xorg-fonts \
	port:xkeyboard-config

depends_lib \
	path:lib/pkgconfig/pixman-1.pc:libpixman \
	port:xorg-libxkbfile \
	port:xorg-libXfont \
	port:xorg-libXt \
	port:xorg-libAppleWM \
	port:xorg-libXfixes

configure.args --with-apple-applications-dir=${applications_dir} \
	--with-launchd-id-prefix=org.macports \
	--without-dtrace \
	--with-sha1=CommonCrypto

# GL/internal/dri_interface.h is missing in prefix (provided by libdrm for the xorg DDX... not helpful for us)
configure.cppflags-append -I/usr/include -I${filespath}/dri

configure.env-append \
	RAWCPP=${configure.cpp}

patchfiles \
        0001-XQuartz-Don-t-trust-deltaXY-for-middle-mouse-clicks.patch \
        0002-XQuartz-Don-t-use-deltaXY-for-determining-pointer-lo.patch \
        0003-XQuartz-Fix-a-build-failure-on-Tiger.patch \
        0004-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch \
        0005-fb-Revert-fb-changes-that-broke-XQuartz.patch

patch.pre_args -p1

build.args V=1

post-destroot {
	ln -s Xquartz ${destroot}${prefix}/bin/X
}

platform macosx {
	if { ![file exists /usr/include/Xplugin.h] } {
		# Xplugin.h is missing on Tiger
		configure.cppflags-append -I${filespath}/include
	}
}
