# -*- 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
# $Id: Portfile 115248 2013-12-30 08:16:04Z jeremyhu@macports.org $

PortSystem              1.0
PortGroup               perl5 1.0

perl5.branches          5.8 5.10 5.12 5.14 5.16
perl5.setup             SDL_Perl 2.1.3
revision                5
maintainers             nomaintainer
categories-append       devel
description             Perl bindings for the Simple DirectMedia Layer
long_description        ${description}
homepage                http://sdl.perl.org/
master_sites            http://search.cpan.org/CPAN/authors/id/D/DG/DGOEHRIG/
checksums               md5 6ce26e1b710ce52def4ec22637cd5176 \
                        sha1 9c11cd7e4356f9b254cd9e3a2f993b1751a21552 \
                        rmd160 26a4d317d9a5761fc893b732f2236eaad8d12b88
platforms               darwin

if {${perl5.major} != ""} {

patchfiles              patch-make-lib-SDL-Build-Darwin.pm patch-src-SDL.xs \
                        patch-test-testgfxprim.pl

depends_lib-append      port:p${perl5.major}-module-build \
                        port:libsdl

variant image {
    depends_lib-append  port:libsdl_image
}

variant mixer {
    depends_lib-append  port:libsdl_mixer
}

variant net {
    depends_lib-append  port:libsdl_net
}

variant ttf {
    depends_lib-append  port:libsdl_ttf
}

variant gfx {
    depends_lib-append  port:libsdl_gfx
}

default_variants        +image +mixer +net +ttf +gfx

configure.cmd           ${perl5.bin}
configure.pre_args      Build.PL
configure.env-append    PREFIX=${prefix}
configure.args          'Build Build' installdirs=vendor

build.cmd               ${perl5.bin}
build.pre_args          Build
build.args              build

# Work around build system problem:
post-build {
    file rename ${worksrcpath}/blib/arch/auto/src/SDL \
        ${worksrcpath}/blib/arch/auto/
    file rename ${worksrcpath}/blib/arch/auto/src/SDL_perl \
        ${worksrcpath}/blib/arch/auto/
    system "rmdir ${worksrcpath}/blib/arch/auto/src"
}

test.pre_args           Build

destroot.cmd            ${perl5.bin}
destroot.pre_args       Build
destroot.args           install
destroot.destdir        destdir=${destroot}
}
