# $Id: Portfile 56424 2009-08-27 10:30:18Z ryandesign@macports.org $

PortSystem              1.0

name                    wine
version                 1.0.1
revision                3
categories              x11
maintainers             ryandesign jwa openmaintainer
homepage                http://www.winehq.org/
platforms               darwin
use_bzip2               yes
build.target            depend all
use_parallel_build      yes
universal_variant       no

description \
    Wine Is Not an Emulator

long_description \
    Wine is an implementation of the Windows APIs on top of X11.

master_sites \
    sourceforge:wine \
    http://ibiblio.org/pub/linux/system/emulators/wine/

checksums \
    md5     b49540f4ed194c7e8da4cdc4b5bd3404 \
    sha1    0550b03bf7b314514a87b6abb2198da96ef83b22 \
    rmd160  fecd2bf970c51c80fc02ca39631034f066da145e

# Note: Most of the X11 libs are dlopen()'d
depends_lib \
    port:expat \
    port:fontconfig \
    port:freetype \
    port:jpeg \
    port:libiconv \
    port:libxml2 \
    port:libxslt \
    port:ncurses \
    port:openssl \
    port:zlib \
    port:xorg-libsm \
    port:xorg-libXcursor \
    port:xorg-libXi \
    port:xorg-libXinerama \
    port:xorg-libXrandr \
    port:xorg-libXxf86vm \
    port:mesa

depends_build \
    port:pkgconfig \
    port:autoconf

# patch-freetype.c-pFT_MulFix.diff should no longer be needed with wine 1.2
patchfiles \
    patch-freetype.c-pFT_MulFix.diff

use_autoreconf yes
autoreconf.args -fvi

configure.ldflags-append \
    -framework CoreServices \
    -lz

configure.args --x-include=${prefix}/include --x-lib=${prefix}/lib

platform darwin 10 {
    # _getdirentries_is_not_available_when_64_bit_inodes_are_in_effect dlls/ntdll/directory.o
    configure.cppflags-append -D_DARWIN_NO_64_BIT_INODE
}

pre-fetch {
    if {"big" == ${os.endian}} {
        ui_error "${name} can only be used on an Intel Mac or other computer with a little-endian processor."
        return -code error "incompatible processor"
    }
}

post-destroot {
    xinstall -d ${destroot}${prefix}/libexec/wine
    file rename ${destroot}${prefix}/bin/wine ${destroot}${prefix}/libexec/wine/wine
    xinstall -m 755 ${filespath}/wine.in ${destroot}${prefix}/bin/wine
    reinplace s|@PREFIX@|${prefix}|g ${destroot}${prefix}/bin/wine
}

livecheck.check         regex
livecheck.regex         {/announce/([0-9]+\.[0-9]*[02468](\.[0-9]+)*)}
