PortSystem 1.0
PortGroup		deprecated 1.0

# Reached EOL in 2011
deprecated.upstream_support no

name			ruby186
conflicts               ruby
version			1.8.6-p420
revision        7

categories		lang ruby
maintainers		{kimuraw @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/
license			{Ruby GPL-2}
master_sites	ruby:1.8
use_bzip2		yes

dist_subdir		ruby
distname		ruby-${version}
checksums		md5     1c7a978e9ffd4f56dc2ad74bbd2c34f3 \
				sha1    00e977ac46df0ccd1545657426439a82f44bf284 \
				rmd160  2f76f19e0a3a35d92200769052d4a049c1478c42

platforms		darwin

depends_lib		port:libiconv \
				port:readline \
                port:openssl10 \
				port:zlib \
				port:ncurses \
				port:gdbm

pre-fetch {
    if {${os.major} > 12} {
        ui_error "${name} @${version} is not supported OS X 10.9 or later."
        return -code error "incompatible OS version"
    }
}

# enable vendordir
patchfiles		patch-vendordir.diff

# 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.
# #25647: build failure with openssl 1.0.0
#         patch from http://redmine.ruby-lang.org/issues/show/2022
# ruby_bug3674: http://redmine.ruby-lang.org/issues/show/3674
### [ruby-core:25606]: Virtual Timer Expired when forking
patchfiles-append \
				patch-bug15528.diff \
				patch-ruby_core21033.diff \
				patch-bug25647.diff \
				patch-ruby_bug3674.diff

# dot-darwin.diff: avoid "darwin" matches /win/ in lib/rdoc/options.rb
# etc-irbrc.diff: require /etc/irbrc when the platform is not Windows
# md5_sha1_commoncrypto.diff: use CommonCrypto when available
# use-setreugid.diff: use setreuid()/setregid() on 10.5 or later
# words-bigendian-from-arch.diff: [ruby-core:12895], [ruby-dev:32160]
patchfiles-append      	dot-darwin.diff \
						etc-irbrc.diff \
						md5_sha1_commoncrypto.diff \
						use-setreugid.diff \
						words-bigendian-from-arch.diff

# #30275: ruby built with clang or llvm-gcc does not work
# see list "MacPorts on Lion (common issues, fixes, and workarounds)"
# http://lists.macosforge.org/pipermail/macports-dev/2011-July/015263.html
compiler.blacklist *clang* *llvm-gcc-4.2

if {[string match *clang* ${configure.compiler}]} {
	configure.optflags -O0
}

configure.args	--enable-shared \
				--mandir="${prefix}/share/man" \
				--enable-pthread \
				--without-tk \
                --with-openssl-include=${prefix}/include/openssl-1.0 \
                --with-openssl-lib=${prefix}/lib/openssl-1.0 \
				--disable-ucontext

if {(!${universal_possible} || ![variant_isset universal]) && ${configure.build_arch} ne ""} {
	configure.env-append "ARCH_FLAG=-arch ${configure.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
}

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
}

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

