# $Id: Portfile,v 1.4 2006/01/09 08:33:11 mww Exp $

PortSystem 1.0

name			gdc
version			0.17
revision		1
set gcc_version	3.3.6
categories		lang
platforms		darwin
maintainers		mww@opendarwin.org
description		D language compiler
long_description	gcc 3.3 with D language frontend

homepage		http://www.digitalmars.com/d/
master_sites	http://home.earthlink.net/~dvdfrdmn/d/:gdc \
				gnu:/gcc/gcc-${gcc_version}:gcc
set gdc			gdc-${version}.tar.bz2
set gcc_core	gcc-core-${gcc_version}.tar.bz2
set gcc_cxx		gcc-g++-${gcc_version}.tar.bz2
distfiles		${gdc}:gdc ${gcc_core}:gcc ${gcc_cxx}:gcc
checksums		${gdc} md5 4e8cccc0d416cb6d7e5bd043901dcedb \
				${gcc_core} md5 18c52e6fb8966b7700665dca289d077f \
				${gcc_cxx} md5 6b3d00b8d079805be1b895f7f6ce47a0
use_bzip2		yes
dist_subdir		gcc33

set bindir		${prefix}/lib/${name}/bin
worksrcdir		build

post-extract {
	file mkdir ${worksrcpath}
	system "ln -sf ${workpath}/d ${workpath}/gcc-${gcc_version}/gcc/d"
}

post-patch {
	system "cd ${workpath}/gcc-${gcc_version}/ && gcc/d/setup-gcc.sh"
}

configure.cmd	${workpath}/gcc-${gcc_version}/configure
configure.args	--enable-languages=d,c,c++ \
				--bindir=${bindir} \
				--libdir=${prefix}/lib/${name} \
				--includedir=${prefix}/include/d/${gcc_version} \
				--with-gxx-include-dir=${prefix}/include/d/${gcc_version} \
				--infodir=${prefix}/share/info \
				--mandir=${prefix}/share/man \
				--libexecdir=${prefix}/libexec/${name} \
				--with-system-zlib \
				--disable-nls \
				--with-local-prefix=${prefix}

build.target	bootstrap-lean

post-destroot {
	system "cd ${destroot}${prefix}/bin && \
		ln -sf ${bindir}/gdc && ln -sf ${bindir}/gdmd"
	foreach man1page {cpp gcc gcov g++} {
		file delete ${destroot}${prefix}/share/man/man1/${man1page}.1
	}
	file delete -force ${destroot}${prefix}/share/man/man7 \
		${destroot}${prefix}/share/info
	# only need -I${prefix}/include/d/3.3.6 this way:
	system "cd ${destroot}${prefix}/include/d/${gcc_version}/gcc \
		&& find .. -name config.d -exec ln -s {} \\; \
		&& find .. -name configunix.d -exec ln -s {} \\;"
	system "cd ${destroot}${prefix}/include/d/${gcc_version} \
		&& find . -name phobos-ver-syms -exec ln -s {} \\;"
}

platform darwin 8 {
	configure.env CC=/usr/bin/gcc-3.3 CPP=/usr/bin/cpp-3.3
}

