# $Id: Portfile 83133 2011-08-26 06:29:05Z ryandesign@macports.org $

PortSystem 1.0

name		neverball
version             1.5.4
categories	games
platforms	darwin
maintainers	gmail.com:mvitocruz
license             GPL-2+

description	Tilt the floor to roll a ball through an obstacle course.
long_description	\
		Tilt the floor to roll a ball through an obstacle     \
		course before time runs out. Neverball is part puzzle \
		game, part action game, and entirely a test of skill.

homepage            http://neverball.org/
master_sites	${homepage}

checksums           rmd160  f546b5e6c12df1a125976a7e23fa55146480241d \
                    sha256  ea31ca9f6eec70c8e66eaa20d7ce9e48295fdb077313b97637c503b16b7b0da6

depends_lib	path:lib/pkgconfig/sdl.pc:libsdl \
                    port:libpng \
                    port:jpeg \
                    port:libvorbis \
                    port:libsdl_ttf \
                    port:physfs

patchfiles          patch-Makefile.diff \
                    patch-share-fs.c.diff

post-patch {
    reinplace "s|@CPPFLAGS@|${configure.cppflags}|g" ${worksrcpath}/Makefile
}

use_configure	no

build.args          CC="${configure.cc} [get_canonical_archflags]" \
                    DATADIR=${prefix}/share/games/${name}

destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/games
    file copy ${worksrcpath}/data ${destroot}${prefix}/share/games/${name}
    fs-traverse item ${destroot}${prefix}/share/games/${name} {
        if {[file isfile ${item}]} {
            switch [file extension ${item}] {
                .map {
                    delete ${item}
                }
                .sol {
                    file attributes ${item} -permissions 0644
                }
            }
        }
    }
    xinstall -s -m 755 -W ${worksrcpath} neverball neverputt ${destroot}${prefix}/bin
}

platform macosx {
	post-destroot {
		xinstall -d -m 755 \
			${destroot}${applications_dir}/Neverball.app/Contents/MacOS \
			${destroot}${applications_dir}/Neverputt.app/Contents/MacOS
		ln -s ${prefix}/bin/neverball \
			${destroot}${applications_dir}/Neverball.app/Contents/MacOS/Neverball
		ln -s ${prefix}/bin/neverputt \
			${destroot}${applications_dir}/Neverputt.app/Contents/MacOS/Neverputt
	}
}
