# $Id: Portfile 66417 2010-04-12 11:57:03Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               archcheck 1.0
PortGroup               xcodeversion 1.0

name                    wine-crossover-games
conflicts               wine wine-devel
version                 9.0.0
categories              x11
maintainers             jeremyhu openmaintainer
homepage                http://www.codeweavers.com/
platforms               darwin
distname                crossover-wine-src-${version}
worksrcdir              wine
build.target            depend all
use_parallel_build      yes
universal_variant       no

minimum_xcodeversions   {8 2.5}

description \
    Wine Is Not an Emulator (1.1.34 with CodeWeavers modifications)

long_description \
    Wine is an implementation of the Windows APIs on top of X11.  This version contains the Codeweavers patches for Crossover Games

master_sites \
    http://media.codeweavers.com/pub/crossover/source/ \
    http://media.codeweavers.com/pub/crossover/source/archive/${version}/

checksums \
    md5     1498eaf24cc2b8615c4c7849702815bd \
    sha1    ee0de1222350b667602828c1b591fad1ad9984df \
    rmd160  9f64ad3668b489e9ccc27a9f79939f1a272d64c4

depends_lib \
    port:expat \
    port:fontconfig \
    port:freetype \
    port:jpeg \
    port:lcms \
    port:libiconv \
    port:libpng \
    port:libxml2 \
    port:libxslt \
    port:ncurses \
    port:openssl \
    port:zlib \
    port:xorg-libsm \
    port:xorg-libXcomposite \
    port:xorg-libXcursor \
    port:xorg-libXi \
    port:xorg-libXinerama \
    port:xorg-libXrandr \
    port:xorg-libXxf86vm \
    port:mesa

archcheck.files         lib/libexpat.dylib \
                        lib/libfontconfig.dylib \
                        lib/libfreetype.dylib \
                        lib/libjpeg.dylib \
                        lib/liblcms.dylib \
                        lib/libiconv.dylib \
                        lib/libpng.dylib \
                        lib/libxml2.dylib \
                        lib/libxslt.dylib \
                        lib/libncurses.dylib \
                        lib/libssl.dylib \
                        lib/libz.dylib \
                        lib/libSM.dylib \
                        lib/libXcomposite.dylib \
                        lib/libXcursor.dylib \
                        lib/libXi.dylib \
                        lib/libXinerama.dylib \
                        lib/libXrandr.dylib \
                        lib/libXxf86vm.dylib \
                        lib/libGL.dylib

depends_build \
    port:pkgconfig

# Extract only the wine directory. We don't need the others, and their presence
# interferes with the wine build (which uses parts of them if present).
extract.post_args-append wine

patchfiles sl-audio.patch

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

configure.args          --without-alsa \
                        --without-audioio \
                        --without-capi \
                        --with-cms \
                        --with-coreaudio \
                        --without-cups \
                        --with-curses \
                        --without-esd \
                        --with-fontconfig \
                        --with-freetype \
                        --without-gphoto \
                        --with-glu \
                        --without-gnutls \
                        --without-gsm \
                        --without-hal \
                        --without-jack \
                        --with-jpeg \
                        --without-ldap \
                        --without-mpg123 \
                        --without-nas \
                        --without-openal \
                        --with-opengl \
                        --with-openssl \
                        --without-oss \
                        --with-png \
                        --with-pthread \
                        --without-sane \
                        --with-xcomposite \
                        --with-xcursor \
                        --with-xinerama \
                        --with-xinput \
                        --with-xml \
                        --with-xrandr \
                        --with-xrender \
                        --with-xshape \
                        --with-xshm \
                        --with-xslt \
                        --with-xxf86vm \
                        --with-x \
                        --x-include=${prefix}/include \
                        --x-lib=${prefix}/lib

# This is not 64-bit friendly yet
if {[info exists supported_archs]} {
    supported_archs i386
}
configure.build_arch i386

platform darwin 9 {
    # Fix "Xcode 3.x cannot build 16-bit code correctly. Use --disable-win16 if you don't need 16-bit support."
    configure.args-append --disable-win16
}

platform darwin 10 {
    # Fix "Xcode 3.x cannot build 16-bit code correctly. Use --disable-win16 if you don't need 16-bit support."
    configure.args-append --disable-win16

    # _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
    xinstall -m 755 ${filespath}/wine.in ${destroot}${prefix}/bin/wine
    reinplace s|@PREFIX@|${prefix}|g ${destroot}${prefix}/bin/wine
}

livecheck.type          regex
livecheck.url           [lindex ${master_sites} 0]
livecheck.regex         {(\d+(\.\d+)+)\.tar}
