2016-11-06 00:29:11 +01:00
|
|
|
{ stdenv, fetchurl
|
|
|
|
, makeWrapper, unzip, which
|
2014-01-10 19:09:52 +01:00
|
|
|
|
2016-11-06 00:29:11 +01:00
|
|
|
# Versions 2.070.2 and up require a working dmd compiler to build:
|
|
|
|
, bootstrapDmd }:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "dmd-${version}";
|
|
|
|
version = "2.070.2";
|
2014-01-10 19:09:52 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2016-11-06 00:29:11 +01:00
|
|
|
url = "http://downloads.dlang.org/releases/2.x/${version}/dmd.${version}.zip";
|
|
|
|
sha256 = "1pbhxxf41v816j0aky3q2pcd8a6phy3363l7vr5r5pg8ps3gl701";
|
2014-01-10 19:09:52 +01:00
|
|
|
};
|
|
|
|
|
2016-11-06 00:29:11 +01:00
|
|
|
nativeBuildInputs = [ bootstrapDmd makeWrapper unzip which ];
|
2014-01-10 19:09:52 +01:00
|
|
|
|
2015-05-02 11:05:43 +02:00
|
|
|
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
|
2015-12-25 20:58:05 +01:00
|
|
|
# Allow to use "clang++", commented in Makefile
|
|
|
|
substituteInPlace src/dmd/posix.mak \
|
|
|
|
--replace g++ clang++ \
|
|
|
|
--replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_
|
2015-05-02 11:05:43 +02:00
|
|
|
'';
|
|
|
|
|
2015-09-06 01:01:16 +02:00
|
|
|
# Buid and install are based on http://wiki.dlang.org/Building_DMD
|
2014-01-10 19:09:52 +01:00
|
|
|
buildPhase = ''
|
|
|
|
cd src/dmd
|
2016-11-05 22:56:13 +01:00
|
|
|
make -f posix.mak INSTALL_DIR=$out
|
2014-01-10 19:09:52 +01:00
|
|
|
export DMD=$PWD/dmd
|
2014-11-14 14:11:38 +01:00
|
|
|
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-14 14:11:38 +01:00
|
|
|
|
2014-11-13 15:57:58 +01:00
|
|
|
cd ../druntime
|
|
|
|
mkdir $out/include
|
|
|
|
mkdir $out/include/d2
|
|
|
|
cp -r import/* $out/include/d2
|
2014-11-14 14:11:38 +01:00
|
|
|
|
2014-01-10 19:09:52 +01:00
|
|
|
cd ../phobos
|
2014-11-13 15:57:58 +01:00
|
|
|
mkdir $out/lib
|
2015-05-02 11:05:43 +02:00
|
|
|
${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-14 14:11:38 +01:00
|
|
|
}
|
2014-11-13 15:57:58 +01:00
|
|
|
|
|
|
|
cp -r std $out/include/d2
|
|
|
|
cp -r etc $out/include/d2
|
|
|
|
|
2015-12-25 20:58:05 +01:00
|
|
|
wrapProgram $out/bin/dmd \
|
|
|
|
--prefix PATH ":" "${stdenv.cc}/bin" \
|
|
|
|
--set CC "$""{CC:-$CC""}"
|
2015-11-28 18:19:30 +01:00
|
|
|
|
2014-11-13 15:57:58 +01:00
|
|
|
cd $out/bin
|
|
|
|
tee dmd.conf << EOF
|
2014-11-14 14:11:38 +01:00
|
|
|
[Environment]
|
2015-09-06 01:01:16 +02:00
|
|
|
DFLAGS=-I$out/include/d2 -L-L$out/lib ${stdenv.lib.optionalString (!stdenv.cc.isClang) "-L--no-warn-search-mismatch -L--export-dynamic"}
|
2014-11-14 14:11:38 +01:00
|
|
|
EOF
|
2014-01-10 19:09:52 +01:00
|
|
|
'';
|
|
|
|
|
2014-11-14 14:11:38 +01:00
|
|
|
meta = with stdenv.lib; {
|
2014-01-10 19:09:52 +01:00
|
|
|
description = "D language compiler";
|
|
|
|
homepage = http://dlang.org/;
|
2014-11-14 14:11:38 +01:00
|
|
|
license = licenses.free; # parts under different licenses
|
|
|
|
platforms = platforms.unix;
|
2014-01-10 19:09:52 +01:00
|
|
|
};
|
|
|
|
}
|