# $Id: Portfile 68195 2010-05-28 20:57:34Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               archcheck 1.0
PortGroup               xcodeversion 1.0

name                    wine-devel
conflicts               wine wine-crossover-games
set my_name             wine
version                 1.2-rc2
license                 LGPL-2.1+
categories              x11
maintainers             ryandesign jwa openmaintainer
homepage                http://www.winehq.org/
platforms               darwin
use_bzip2               yes
distname                ${my_name}-${version}
dist_subdir             ${my_name}
set wine_distfile       [suffix ${distname}]
set wine_gecko_distfile wine_gecko-1.0.0-x86.cab
distfiles               ${wine_distfile} ${wine_gecko_distfile}
extract.only            ${wine_distfile}
build.target            depend all
use_parallel_build      yes
universal_variant       no

minimum_xcodeversions   {8 2.5}

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 \
    ${wine_distfile} \
    md5     99b4511a5a005a1ef363700d482f80f1 \
    sha1    6952b5036f218e0be917184933cf0a252b8f8e86 \
    rmd160  53daa6202ee9b6c427f6c62c7875b1ec3bc8b594 \
    ${wine_gecko_distfile} \
    md5     9c5c335fc077c0558561afaf25a09e51 \
    sha1    afa22c52bca4ca77dcb9edb3c9936eb23793de01 \
    rmd160  57618dbffa7b7226dcd44f86c3c569ab8a5ff938

# Note: Most of the X11 libs are dlopen()'d
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:tiff \
    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/libtiff.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:flex \
    port:pkgconfig

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-tiff \
                        --without-v4l \
                        --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."
    # Only affects Xcode 3.0.x and 3.1.x, not 3.2.x.
    # See http://bugs.winehq.org/show_bug.cgi?id=14920
    configure.args-append --disable-win16
}

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 ${filespath}/wine.in ${destroot}${prefix}/bin/wine
    reinplace s|@PREFIX@|${prefix}|g ${destroot}${prefix}/bin/wine
    
    xinstall -d ${destroot}${prefix}/share/wine/gecko
    xinstall -m 644 ${distpath}/${wine_gecko_distfile} ${destroot}${prefix}/share/wine/gecko
    
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        ANNOUNCE \
        AUTHORS \
        COPYING.LIB \
        LICENSE \
        README \
        ${destroot}${prefix}/share/doc/${name}
}

livecheck.type          regex
livecheck.regex         {"/announce/([0-9]+\.[0-9]*([13579]|[02468]-rc\d+)(\.[0-9]+)*)"}
