# -*- 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

PortSystem      1.0
PortGroup       github 1.0

github.setup    XQuartz quartz-wm 1.3.2 quartz-wm-
revision        1
categories      x11
platforms       macosx
maintainers     {jeremyhu @jeremyhu} openmaintainer
license         APSL-2

description     Apple's Window Manager for X11
long_description quartz-wm is the XQuartz window-manager.

homepage        https://www.xquartz.org
github.tarball_from releases

checksums       sha1    9e43d795b9c996b9204cdb2d4b9e922f243e4028 \
                rmd160  aff2fce05bc75497de665a5fa6b64b99e498a5c3 \
                sha256  3a4ff60ef53e7a37af2c7af3431aa0256a161807cce2161863c0657a5de2d1f5

use_xz          yes

depends_build   port:pkgconfig  \
                port:xorg-util-macros

depends_lib     port:xorg-libXinerama \
                port:xorg-libXrandr \
                port:xorg-libAppleWM \
                path:lib/pkgconfig/pixman-1.pc:libpixman

# Work-around for build failures on macOS 12
# https://trac.macports.org/ticket/63355
if {${os.platform} eq "darwin" && ${os.major} >= 21} {
    patchfiles-append monterey-fix.patch
}

# http://trac.macports.org/ticket/33515
if {${os.arch} eq "powerpc"} {
    # This is sub-optimal, but it will work for now
    post-patch {
        reinplace "/install_name_tool/d" ${worksrcpath}/lib/Makefile.in
    }
} elseif {${os.major} < 10} {
    depends_build-append port:cctools
    depends_skip_archcheck-append cctools
}

# http://trac.macports.org/ticket/36043
compiler.blacklist-append gcc-4.0

configure.args  --disable-silent-rules \
                --with-bundle-id-prefix=org.macports

platform macosx {
    if {${os.major} < 10} {
        # Xplugin.h is missing on Tiger and incorrect on Leopard
        configure.cppflags-append -I${filespath}/include
    }
    if {${os.major} > 11} {
        configure.args-append --enable-xplugin-dock-support
    }
}
