# $Id: Portfile 63130 2010-01-27 13:57:41Z kimuraw@macports.org $

PortSystem 1.0

name			ruby186
version			1.8.6-p388

categories		lang ruby
maintainers		kimuraw openmaintainer

description		Powerful and clean object-oriented scripting language
long_description	Ruby is the interpreted scripting language for quick \
					and easy object-oriented programming. It has many \
					features to process text files and to do system \
					management tasks (as in Perl). It is simple, \
					straight-forward, extensible, and portable. \
					Note: this port conflicts with the ruby port, so you \
					can have either that or this one active at one time.
homepage		http://www.ruby-lang.org/
master_sites	ruby:1.8
use_bzip2		yes

dist_subdir		ruby
distname		ruby-${version}
checksums		md5     f26cefbc8ab6728650ab9ae773d22bcb \
				sha1    175e7f1571761e522e88cc8a8ed123f000c99c59 \
				rmd160  9f451182ef4fb485109d96953e6af388151cadc8

platforms		darwin

depends_lib		port:libiconv \
				port:readline \
				port:openssl \
				port:zlib \
				port:ncurses

patchfiles		patch-Makefile.in \
				patch-configure.in \
				patch-instruby.rb \
				patch-mkconfig.rb \
				patch-mkmf.rb \
				patch-ruby.c

# bug15528: TCPServer.open('localhost', 0) fails on some Mac
# [ruby-core:21033]: The DRb code in drb.rb does not correctly deal with
#                    multiple network families if they're present.
patchfiles-append \
				patch-bug15528.diff \
				patch-ruby_core21033.diff

use_autoconf	yes

configure.args	--enable-shared \
				--mandir="${prefix}/share/man" \
				--enable-pthread \
				--without-tk

if {![variant_isset universal] && [info exists build_arch] && $build_arch != ""} {
	configure.env-append ARCH_FLAG="-arch ${build_arch}"
}

destroot.target	install install-doc
post-destroot {
	foreach type {site vendor} {
		set libdir ${destroot}${prefix}/lib/ruby/${type}_ruby
		xinstall -m 0755 -d ${libdir}

		# special file for installation control of modules
		xinstall -m 0644 ${filespath}/${type}-specific.rb ${libdir}

		# prevent empty site/vendor directories from being pruned
		foreach subdir [exec find ${libdir} -type d -empty] {
			destroot.keepdirs-append ${subdir}
		}
	}
    # error at activate, for these case sensitive files
	foreach rdoc {Exception2MessageMapper/fail-i.yaml \
				  REXML/Parsers/XPathParser/predicate-i.yaml} {
		if {[file exists ${destroot}${prefix}/share/ri/1.8/system/${rdoc}]} {
			delete ${destroot}${prefix}/share/ri/1.8/system/${rdoc}
		}
	}
}

platform darwin {
	# for proper rdoc/ri creation, make sure to link to destroot libruby.dylib
	destroot.env	DYLD_LIBRARY_PATH=${destroot}${prefix}/lib
}

platform darwin 9 {
	patchfiles-append      	dot-darwin.diff \
							etc-irbrc.diff \
							ignore-gsetcontext.diff \
							md5_sha1_commoncrypto.diff \
							use-dyld.diff \
							use-setreugid.diff \
							words-bigendian-from-arch.diff
}

variant tk conflicts mactk description {Enable MacPorts Tk bindings} {
	configure.args-delete	--without-tk
	configure.args-append	--with-tk
	depends_lib-append		port:tcl \
							port:tk
}

variant mactk conflicts tk description {Enable Mac OS X Tk framework bindings} {
	configure.args-delete   --without-tk
	configure.args-append   --enable-tcltk-framework
}

variant thread_hooks description {Enable thread hooks} {
	patchfiles-append		patch-thread-hooks
}

default_variants	+thread_hooks

livecheck.type	regex
livecheck.url	http://www.ruby-lang.org/en/downloads/
livecheck.regex	{>Ruby (.*?)</a> \\\(md5:}

