# $Id: Portfile 51102 2009-05-18 02:44:02Z ryandesign@macports.org $

PortSystem          1.0
name                pennmush
version             1.8.3p9
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          games
maintainers         nomaintainer
description         The PennMUSH mud server
long_description \
   There are a number of flavors of MUSH server freely available to those \
   who want to run their own MUSHes: TinyMUSH 3.0, TinyMUSH 2.2, TinyMUX 1.6, \
   and PennMUSH 1.7.x. TinyMUSH uses a disk-based database, while PennMUSH \
   keeps its database in the computer's memory (TinyMUX can do either). This \
   makes PennMUSH suitable for computers which have plenty of memory or \
   little disk space. From a user standpoint they offer many similar features \
   and a very similar command parser.

platforms           darwin

homepage            http://www.pennmush.org/
master_sites        http://download.pennmush.org/Source/ \
                    http://download.pennmush.org/Source/oldsrc/${branch}/

checksums           md5     88dc8ec2c07171831d9d0959549d82e3 \
                    sha1    a06f18221a40ed847bba7e30935c38937309fabe \
                    rmd160  de5777b8b2c592fecc23ade2c5cceccfee17086b

depends_lib         port:openssl port:pcre path:bin/perl:perl5 port:gettext

patchfiles          patch-game_txt_Makefile

configure.args      --without-mysql --without-postgresql --without-sqlite3 \
                    --with-perl=${prefix}/bin/perl --with-ssl=${prefix} \
                    --with-pcre=${prefix}
post-configure {
   copy ${worksrcpath}/options.h.dist ${worksrcpath}/options.h
}

post-build {
   system "cd ${worksrcpath}/game/txt && make clean all"
}

set pennmush_install_dir ${prefix}/libexec/${name}

# Do our own install since the Makefiles aren't quite up to snuff for
# full autoconf use yet...
destroot {
   global pennmush_install_dir
   xinstall -m 755 -d ${destroot}${pennmush_install_dir}
   eval copy [glob ${worksrcpath}/game/*] ${destroot}${pennmush_install_dir}
   xinstall -m 755 ${worksrcpath}/src/netmud \
      ${destroot}${pennmush_install_dir}/netmush
   xinstall -m 755 ${worksrcpath}/src/info_slave \
      ${destroot}${pennmush_install_dir}
   xinstall -m 755 ${worksrcpath}/utils/ln-dir.sh \
      ${destroot}${pennmush_install_dir}
   reinplace "s|GAMEDIR=|GAMEDIR=${pennmush_install_dir}|g" \
      ${destroot}${pennmush_install_dir}/restart
   delete ${destroot}${pennmush_install_dir}/mush.cnf
}

post-activate {
   global pennmush_install_dir
   if {![file exists ${pennmush_install_dir}/mush.cnf]} {
      copy ${pennmush_install_dir}/mushcnf.dst ${pennmush_install_dir}/mush.cnf
   }
}

variant mysql5 description {Use MySQL for database} {
   depends_lib-append      path:bin/mysql_config5:mysql5
   configure.args-delete   --without-mysql
   configure.args-append   --with-mysql=${prefix}/bin/mysql_config5
}

variant postgresql83 description {Use PostGreSQL for database} {
   depends_lib-append      port:postgresql83
   configure.args-delete   --without-postgresql
   configure.args-append   --with-postgresql=${prefix}/lib/postgresql83/bin/pg_config
}

variant sqlite3 description {Use SQLite3 for database} {
   depends_lib-append      port:sqlite3
   configure.args-delete   --without-sqlite3
   configure.args-append   --with-sqlite3=${prefix}
}

