nixpkgs/pkgs/development/compilers/dmd/default.nix

75 lines
2.1 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, unzip, makeWrapper }:
2014-01-10 19:09:52 +01:00
stdenv.mkDerivation {
name = "dmd-2.067.1";
2014-01-10 19:09:52 +01:00
src = fetchurl {
url = http://downloads.dlang.org/releases/2015/dmd.2.067.1.zip;
sha256 = "0ny99vfllvvgcl79pwisxcdnb3732i827k9zg8c0j4s0n79k5z94";
2014-01-10 19:09:52 +01:00
};
nativeBuildInputs = [ unzip makeWrapper ];
2014-01-10 19:09:52 +01:00
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
# Allow to use "clang++", commented in Makefile
substituteInPlace src/dmd/posix.mak \
--replace g++ clang++ \
--replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_
# Was not able to compile on darwin due to "__inline_isnanl"
# being undefined.
substituteInPlace src/dmd/root/port.c --replace __inline_isnanl __inline_isnan
'';
# Buid and install are based on http://wiki.dlang.org/Building_DMD
2014-01-10 19:09:52 +01:00
buildPhase = ''
cd src/dmd
make -f posix.mak INSTALL_DIR=$out
2014-01-10 19:09:52 +01:00
export DMD=$PWD/dmd
cd ../druntime
2014-01-10 19:09:52 +01:00
make -f posix.mak INSTALL_DIR=$out DMD=$DMD
cd ../phobos
make -f posix.mak INSTALL_DIR=$out DMD=$DMD
cd ../..
'';
installPhase = ''
cd src/dmd
2014-11-13 15:57:58 +01:00
mkdir $out
mkdir $out/bin
cp dmd $out/bin
2014-11-13 15:57:58 +01:00
cd ../druntime
mkdir $out/include
mkdir $out/include/d2
cp -r import/* $out/include/d2
2014-01-10 19:09:52 +01:00
cd ../phobos
2014-11-13 15:57:58 +01:00
mkdir $out/lib
${let bits = if stdenv.is64bit then "64" else "32";
osname = if stdenv.isDarwin then "osx" else "linux"; in
"cp generated/${osname}/release/${bits}/libphobos2.a $out/lib"
}
2014-11-13 15:57:58 +01:00
cp -r std $out/include/d2
cp -r etc $out/include/d2
wrapProgram $out/bin/dmd \
--prefix PATH ":" "${stdenv.cc}/bin" \
--set CC "$""{CC:-$CC""}"
2014-11-13 15:57:58 +01:00
cd $out/bin
tee dmd.conf << EOF
[Environment]
DFLAGS=-I$out/include/d2 -L-L$out/lib ${stdenv.lib.optionalString (!stdenv.cc.isClang) "-L--no-warn-search-mismatch -L--export-dynamic"}
EOF
2014-01-10 19:09:52 +01:00
'';
meta = with stdenv.lib; {
2014-01-10 19:09:52 +01:00
description = "D language compiler";
homepage = http://dlang.org/;
license = licenses.free; # parts under different licenses
platforms = platforms.unix;
2014-01-10 19:09:52 +01:00
};
}