# $Id: Portfile 80046 2011-07-03 12:02:42Z jmr@macports.org $

PortSystem 1.0

name		xorg-server-devel
conflicts       xorg-server
set my_name	xorg-server
version		1.10.99.901
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    xorg:individual/xserver/

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

checksums           md5     3bb1a707b51b914f88a84b8d4af19943 \
                    sha1    106b6806b64ae368f1f8d52568ca272f88d0c567 \
                    rmd160  268a3993204012653c62e0f7fa20db9285a675f9

use_bzip2	yes
use_parallel_build yes

# Yes, mesa is a *BUILD* dependency
depends_build \
	port:pkgconfig \
	port:mesa \
	port:xorg-applewmproto \
	port:xorg-bigreqsproto \
	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

# 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-bundle-id-prefix=org.macports \
	--without-dtrace \
	--without-doxygen \
	--without-fop \
	--without-xmlto \
	--disable-devel-docs \
	--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-DIX-Set-backgroundState-correctly-for-root-window.patch \
        0002-XQuartz-GLX-Create-a-new-dispatch-table-rather-than-.patch \
        0003-XQuartz-Move-lXplugin-to-LDFLAGS-from-LDADD.patch \
        0004-XQuartz-Add-a-semicolon-after-DEBUG_LOG.patch \
        0005-XQuartz-ASL-Update-logging-to-support-differnet-leve.patch \
        0006-XQuartz-ASL-Use-xpr-subsystem-for-logging-xpr-messag.patch \
        0007-XQuartz-ASL-Use-GLXAqua-subsystem-for-logging-GLXAqu.patch \
        0008-XQuartz-ASL-Use-xpbproxy-subsystem-for-logging-xpbpr.patch \
        0009-XQuartz-xpbproxy-Correct-NSUInteger-format-strings.patch \
        0010-test-fix-memset-size-for-WindowRec-37801.patch \
        0011-XQuartz-Remove-explicit-link-against-libGL.patch \
        0012-XQuartz-AIGLX-Setup-dispatch-table-based-on-runtime-.patch \
        0013-XQuartz-AIGLX-Remove-unnecessary-includes-in-indirec.patch \
        1001-XQuartz-Add-missing-include-for-pthread.h.patch \
        5001-configure.ac-Add-fno-strict-aliasing-to-CFLAGS.patch \
        5002-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch \
        5003-fb-Revert-fb-changes-that-broke-XQuartz.patch

patch.pre_args -p1

use_autoreconf yes
autoreconf.args -fvi

build.args V=1

depends_build-append \
	port:xorg-util-macros \
	port:xorg-font-util

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
	}
}

variant docs description "Install extra documentation" {
	depends_build-append \
		port:doxygen \
		port:fop \
		port:xmlto \
		port:xorg-sgml-doctools

	depends_skip_archcheck-append \
		doxygen \
		xmlto

	configure.args-delete \
		--without-doxygen \
		--without-fop \
		--without-xmlto \
		--disable-devel-docs 

	configure.args-append \
		--with-doxygen \
		--with-fop \
		--with-xmlto \
		--enable-devel-docs

	configure.env-append \
		DOXYGEN="${prefix}/bin/doxygen" \
		FOP="${prefix}/bin/fop" \
		XMLTO="${prefix}/bin/xmlto"
}
