# $Id: Portfile,v 1.41 2004/10/08 06:05:31 mww Exp $

PortSystem 1.0
name			mysql
version			3.23.58
categories		databases
maintainers		mij@opendarwin.org
description		Multithreaded SQL database server
homepage		http://www.mysql.com/
platforms		darwin sunos

long_description	MySQL is an open-source, multi-threaded SQL database \
			with a command syntax very similar to mSQL.

master_sites		ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/Downloads/MySQL-3.23/ \
			freebsd \
			opendarwin

checksums		md5 835a96c86132fbde0db36db60c5b34cd

patchfiles		patch-libmysql-violite.c patch-sql-violite.c

set dbdir		${prefix}/var/db/mysql

configure.env		LDFLAGS="-L${prefix}/lib -lncurses" \
			CPPFLAGS="-I${prefix}/include"

configure.args		--localstatedir=${dbdir} --without-server \
			--sysconfdir=${prefix}/etc --without-bench \
			--mandir=${prefix}/share/man --infodir=${prefix}/share/info

platform darwin 6 { depends_lib-append lib:libdl:dlcompat }

variant sunos	{ configure.env LDFLAGS="-L${prefix}/lib" \
				CPPFLAGS="-I${prefix}/include" }

variant innodb	{ configure.args-append --with-innodb }

variant server	{
  depends_run path:/Library/StartupItems/DarwinPortsStartup:DarwinPortsStartup

  configure.args --localstatedir=${dbdir} --sysconfdir=${prefix} --without-bench

  pre-destroot {  addgroup mysql
  		  set gid [existsgroup mysql]
		  adduser mysql gid=${gid} realname=MySQL\ Server
  		  system "install -o mysql -g mysql -m 755 -d ${dbdir}" }

  post-destroot { system "install -m 755 -d ${destroot}${prefix}/etc/rc.d"
		  system "install -m 755 ${workpath}/${worksrcdir}/support-files/mysql.server ${destroot}${prefix}/etc/rc.d/mysql-server.sh"
		  system "install -m 644 ${workpath}/${worksrcdir}/support-files/my-medium.cnf ${destroot}${prefix}/etc/my.cnf"
		  ui_msg "===============================================================================\n"
		  ui_msg "If this is a new installation of MySQL, you must run\n${prefix}/bin/mysql_install_db after installing this port!\n"
		  ui_msg "You must also run:\n\n	'chown -R mysql:mysql ${dbdir}'\n\nbefore starting the MySQL daemon.\n"
		  ui_msg "===============================================================================\n"
  }
}
