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

name                openmotif
version             2.3.8
revision            5
categories          x11
license             LGPL
maintainers         nomaintainer
description         The Open Motif toolkit for X11

long_description    This is The Open Group's full version of the Motif user \
                    interface component toolkit based on the original OSF sources.

homepage            https://motif.ics.com/
master_sites        sourceforge:project/motif/Motif%20${version}%20Source%20Code
distname            motif-${version}

checksums           rmd160 a4c10db68d880d3096c97cc1c995351616a90a57 \
                    sha256 859b723666eeac7df018209d66045c9853b50b4218cecadb794e2359619ebce7 \
                    size   5704328

depends_build       port:pkgconfig \
                    port:xbitmaps \
                    port:bison \
                    port:flex

depends_lib         path:include/turbojpeg.h:libjpeg-turbo \
                    port:fontconfig \
                    port:freetype \
                    port:libpng \
                    port:libiconv \
                    port:Xft2 \
                    port:xorg-libice \
                    port:xorg-libsm \
                    port:xorg-libX11 \
                    port:xorg-libXext \
                    port:xorg-libXmu \
                    port:xorg-libXp \
                    port:xorg-libXt \
                    port:xrender

patchfiles          wcs-functions.patch \
                    include-stdlib.patch \
                    patch-lib-xm-vendor.diff

# See https://trac.macports.org/ticket/42847
if {[string match "*clang*" ${configure.compiler}]} {
    patchfiles-append   clang-unsupported-cflags.patch

    # error: incompatible function pointer types passing 'void (char *)'
    # to parameter of type 'void (*)(String) __attribute__((noreturn))'
    #     XtSetErrorHandler (WmXtErrorHandler)
    # But adding this flag unconditionally breaks build with gcc-4.2.
    configure.cflags-append -Wno-error=incompatible-function-pointer-types
}

configure.args      --enable-xft \
                    --enable-jpeg \
                    --enable-png \
                    --x-includes=${prefix}/include \
                    --x-libraries=${prefix}/lib

configure.env       "YACC=${prefix}/bin/bison -y"

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} BUGREPORT COPYING ChangeLog \
        README RELNOTES TODO ${destroot}${docdir}
}
