# $Id: Portfile,v 1.6 2005/04/13 11:18:27 mww Exp $

PortSystem 1.0
name			MyODBC
version			3.51.11
categories		databases
platforms		darwin
maintainers		simon@cotsworth.com
description		MySQL Connector/ODBC

long_description	MySQL Connector/ODBC (also known as MyODBC) allows you \
				to connect to a MySQL database server using the ODBC database \
				API on all Microsoft Windows and most Unix platforms, \
				including through such applications and programming \
				environments such as Microsoft Access, Microsoft Excel, and \
				Borland Delphi.

homepage		http://www.mysql.com/

set sitedir		Downloads/${name}3/
master_sites	ftp://planetmirror.com/pub/mysql/${sitedir} \
                http://www.softagency.co.jp/MySQL/${sitedir} \
                ftp://sunsite.dk/mirrors/mysql/${sitedir} \
                http://mysql.mirror.anlx.net/${sitedir} \
                http://gd.tuwien.ac.at/db/mysql/${sitedir} \
                http://mysql.mediatraffic.fi/${sitedir} \
                ftp://filepile.tiscali.de/mirror/mysql/${sitedir} \
                http://mirrors.tilian.co.uk/mysql.com/${sitedir} \
                ftp://ftp.rtfm.no/pub/mysql/${sitedir} \
                http://www.mysql.cz/${sitedir} \
                ftp://ftp.u-paris10.fr/mysql.com/${sitedir} \
                http://mysql.oms-net.nl/${sitedir} \
                ftp://ftp.free.fr/pub/MySQL/${sitedir}

checksums		md5 fb295a2a07dab09caf608f2227b531ef
#				sha1 f59b754a6249af2de057969f845ad9739b0ff3ac

depends_lib		lib:libmysqlclient:mysql4 \
				lib:libodbc.1:unixODBC \
				lib:libz.1:zlib

post-patch	{
	reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/imyodbc/Makefile.osx
}

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

configure.args	--with-unixODBC=${prefix} \
				--with-unixODBC-includes=${prefix}/include \
				--with-unixODBC-libs=${prefix}/lib \
				--with-odbc-ini=${prefix}/etc/odbc.ini \
				--with-mysql-path=${prefix} \
				--enable-thread-safe \
				--enable-shared \
				--enable-static \
				--without-debug \
				--without-samples \
				--disable-gui

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

variant darwin	{
	configure.args-append	--enable-bundles \
							--enable-dmlink \
							--enable-imyodbc
}

variant samples {
	configure.args-delete	--without-samples
	configure.args-append	--with-samples	
}

variant debug {
	configure.args-delete	--without-debug
	configure.args-append	--with-debug	
}

post-destroot	{
	# install directories
	foreach dir [list ${name} doc/${name} unixODBC] {
		xinstall -d -m 0755 ${destroot}${prefix}/share/$dir
	}

	# install readme files
	foreach readme [glob ${worksrcpath}/\[A-Z\]*\[A-Z\] ${worksrcpath}/\[A-Z\]*.\[a-z\]] {
		xinstall -m 0644 $readme ${destroot}${prefix}/share/doc/${name}
	}

	# install samples
	if { [variant_isset samples] } {
		xinstall -d -m 0755 ${destroot}${prefix}/share/${name}/samples
		foreach sample [glob ${worksrcpath}/samples/.libs/my_*] {
			xinstall -m 0755 $sample \
			  ${destroot}${prefix}/share/${name}/samples
		}
	}

	# install example odbc.ini
	xinstall -m 0644 ${portpath}/${filesdir}/odbc.ini \
	  ${destroot}${prefix}/share/${name}/odbc.ini.dist
	reinplace "s|/usr/local|${prefix}|g" \
	  ${destroot}${prefix}/share/${name}/odbc.ini.dist

	# install MyODBC templates
	foreach template [glob ${portpath}/${filesdir}/*.template] {
		xinstall -m 0644 $template ${destroot}${prefix}/share/unixODBC
	}
	reinplace "s|__PREFIX__|${prefix}|g" \
	  ${destroot}${prefix}/share/unixODBC/mysql.driver.template
}
