# $Id: Portfile 32348 2007-12-26 20:23:54Z pmq@macports.org $

PortSystem          1.0

name                crafty
categories          games
version             20.14
platforms	    darwin
maintainers	    pmq
description         Crafty is a chess program, that can be interfaced with xboard.

long_description    \
    Crafty is the derivative of Cray Blitz, a computer chess program. It is \
    a very strong one, and its current peak ICC ratings are 3286 (bullet), \
    3388 (blitz) and 2792 (standard). It can be used with xboard just like \
    gnuchess.

homepage            http://www.cis.uab.edu/hyatt/hyatt.html
master_sites        ftp://ftp.cis.uab.edu/pub/hyatt/source:src \
		    ftp://ftp.cis.uab.edu/pub/hyatt/documentation:doc \
		    ftp://ftp.cis.uab.edu/pub/hyatt/book:book

set dist_srczip	    ${name}-${version}.zip
set dist_book1	    book.bin
set dist_book2 	    bookc.bin
set dist_book3 	    books.bin
set dist_ascii	    ${name}.doc.ascii
set dist_ps	    ${name}.doc.ps
set dist_man	    ${name}.man
dist_subdir	    ${name}/${version}

distfiles	    ${dist_srczip}:src \
		    ${dist_book1}:book \
		    ${dist_book2}:book \
		    ${dist_book3}:book \
		    ${dist_ascii}:doc \
		    ${dist_ps}:doc \
		    ${dist_man}:doc

checksums           ${dist_srczip} md5 ab681d84fc2f01ce0789cf4f47c945f8 \
		    ${dist_book1} md5 085e207bd19bd974d511e77fbef36507 \
		    ${dist_book2} md5 bc153dca6a22adb07a729a0df80ecd50 \
		    ${dist_book3} md5 6d7abc20944720986086ff6569fe35ec \
		    ${dist_ascii} md5 5fd73027a1de1674763562e1987197ba \
		    ${dist_ps} md5 6cef69aa2f9ea1ceb74b6c14edc8291f \
		    ${dist_man} md5 26163f4048f3ca05a1f6a1a2fb64525f

depends_build	    bin:unzip:unzip

extract {
    file mkdir work

    # extract the src zip
    system "cd ${workpath} && unzip ${distpath}/${dist_srczip}"
}

use_configure	    no

build.target	    darwin
# in a next version, point crafty to the default location for books
# for the moment use the classic bookpath switch when launching it
# should you want to use endgame tables, put them into the TBDIR
# build.args	    -DBOOKDIR=${prefix}/share/${name}/ \
#		    -DTBDIR=${prefix}/share/${name}/TB/

destroot {
    # copy the executable
	xinstall -m 755 -d ${destroot}/${prefix}/bin
    file copy ${worksrcpath}/${name} ${destroot}/${prefix}/bin/

    # copy the book files
    xinstall -m 755 -d ${destroot}/${prefix}/share/${name}
    file copy ${distpath}/${dist_book1} \
    	      ${distpath}/${dist_book2} \
	      ${distpath}/${dist_book3} \
	${destroot}/${prefix}/share/${name}/

    # copy the docs
    xinstall -m 755 -d ${destroot}/${prefix}/share/doc/${name}
    file copy ${distpath}/${dist_ascii} \
    	      ${distpath}/${dist_ps} \
	${destroot}/${prefix}/share/doc/${name}

    # copy the manpage, renaming the extension
    file copy ${distpath}/${dist_man} \
    	${destroot}/${prefix}/share/man/man1/${name}.1
}
