about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/ocaml
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/ocaml')
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix21
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix34
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix75
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch32
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix69
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix67
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix7
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.02.nix7
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.03.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.04.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.05.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.06.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/4.07.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix96
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/builder.sh8
-rwxr-xr-xnixpkgs/pkgs/development/compilers/ocaml/configure-3.08.01482
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff20
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/generic.nix100
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch9
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix34
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/mips64.patch240
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch45
22 files changed, 2388 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix
new file mode 100644
index 000000000000..4337de702e16
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, xlibsWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "ocaml-${version}";
+  version = "3.08.0";
+
+  builder = ./builder.sh;
+  src = fetchurl {
+    url = "http://tarballs.nixos.org/${name}.tar.gz";
+    sha256 = "135g5waj7djzrj0dbc8z1llasfs2iv5asq41jifhldxb4l2b97mx";
+  };
+  configureScript = ./configure-3.08.0;
+  dontAddPrefix = "True";
+  configureFlags = ["-no-tk" "-x11lib" xlibsWrapper];
+  buildFlags = ["world" "bootstrap" "opt"];
+  checkTarget = ["opt.opt"];
+
+  meta = {
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix
new file mode 100644
index 000000000000..99a65dec1501
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, xlibsWrapper, ncurses }:
+
+stdenv.mkDerivation (rec {
+
+  name = "ocaml-${version}";
+  version = "3.10.0";
+
+  src = fetchurl {
+    url = "https://caml.inria.fr/pub/distrib/ocaml-3.10/${name}.tar.bz2";
+    sha256 = "1ihmx1civ78s7k2hfc05z1s9vbyx2qw7fg8lnbxnfd6zxkk8878d";
+  };
+
+  prefixKey = "-prefix ";
+  configureFlags = ["-no-tk" "-x11lib" xlibsWrapper];
+  buildFlags = "world bootstrap world.opt";
+  buildInputs = [xlibsWrapper ncurses];
+  installTargets = "install installopt";
+  patchPhase = ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+  '';
+  postBuild = ''
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+  '';
+
+  meta = {
+    homepage = http://caml.inria.fr/ocaml;
+    license = with stdenv.lib.licenses; [ qpl lgpl2 ];
+    description = "Most popular variant of the Caml language";
+    platforms = stdenv.lib.platforms.linux;
+  };
+
+})
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix
new file mode 100644
index 000000000000..e65510c172e6
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix
@@ -0,0 +1,75 @@
+{ stdenv, fetchurl, ncurses, xlibsWrapper }:
+
+let
+   useX11 = stdenv.isi686 || stdenv.isx86_64;
+   useNativeCompilers = stdenv.isi686 || stdenv.isx86_64 || stdenv.isMips;
+   inherit (stdenv.lib) optionals optionalString;
+in
+
+stdenv.mkDerivation rec {
+  
+  name = "ocaml-${version}";
+  version = "3.11.2";
+  
+  src = fetchurl {
+    url = "https://caml.inria.fr/pub/distrib/ocaml-3.11/${name}.tar.bz2";
+    sha256 = "86f3387a0d7e7c8be2a3c53af083a5a726e333686208d5ea0dd6bb5ac3f58143";
+  };
+
+  # Needed to avoid a SIGBUS on the final executable on mips
+  NIX_CFLAGS_COMPILE = if stdenv.isMips then "-fPIC" else "";
+
+  patches = optionals stdenv.isDarwin [ ./gnused-on-osx-fix.patch ] ++
+    [ (fetchurl {
+        name = "0007-Fix-ocamlopt-w.r.t.-binutils-2.21.patch";
+        url = "http://caml.inria.fr/mantis/file_download.php?file_id=418&type=bug";
+	sha256 = "612a9ac108bbfce2238aa5634123da162f0315dedb219958be705e0d92dcdd8e";
+      })
+    ];
+
+  prefixKey = "-prefix ";
+  configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" xlibsWrapper ];
+  buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
+  buildInputs = [ncurses] ++ optionals useX11 [ xlibsWrapper ];
+  installTargets = "install" + optionalString useNativeCompilers " installopt";
+  prePatch = ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+    patch -p0 < ${./mips64.patch}
+  '';
+  postBuild = ''
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://caml.inria.fr/ocaml;
+    license = with licenses; [
+      qpl /* compiler */
+      lgpl2 /* library */
+    ];
+    description = "Most popular variant of the Caml language";
+
+    longDescription =
+      '' Objective Caml is the most popular variant of the Caml language.
+         From a language standpoint, it extends the core Caml language with a
+         fully-fledged object-oriented layer, as well as a powerful module
+         system, all connected by a sound, polymorphic type system featuring
+         type inference.
+
+         The Objective Caml system is an industrial-strength implementation
+         of this language, featuring a high-performance native-code compiler
+         (ocamlopt) for 9 processor architectures (IA32, PowerPC, AMD64,
+         Alpha, Sparc, Mips, IA64, HPPA, StrongArm), as well as a bytecode
+         compiler (ocamlc) and an interactive read-eval-print loop (ocaml)
+         for quick development and portability.  The Objective Caml
+         distribution includes a comprehensive standard library, a replay
+         debugger (ocamldebug), lexer (ocamllex) and parser (ocamlyacc)
+         generators, a pre-processor pretty-printer (camlp4) and a
+         documentation generator (ocamldoc).
+       '';
+
+    platforms = with platforms; linux ++ darwin;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch
new file mode 100644
index 000000000000..4b867bbb1e6f
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch
@@ -0,0 +1,32 @@
+diff -Nuar ocaml-3.12.1/configure ocaml-3.12.1-fix-configure/configure
+--- ocaml-3.12.1/configure	2011-07-04 23:15:01.000000000 +0200
++++ ocaml-3.12.1-fix-configure/configure	2012-06-06 22:20:40.000000000 +0200
+@@ -259,7 +259,7 @@
+     bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
+     mathlib="";;
+   *,*-*-darwin*)
+-    bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings"
++    bytecccompopts="-fno-defer-pop $gcc_warnings"
+     mathlib=""
+     # Tell gcc that we can use 32-bit code addresses for threaded code
+     # unless we are compiled for a shared library (-fPIC option)
+@@ -739,7 +739,7 @@
+   *,*,rhapsody,*)      nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs"
+                        if $arch64; then partialld="ld -r -arch ppc64"; fi;;
+   *,gcc*,cygwin,*)     nativecccompopts="$gcc_warnings -U_WIN32";;
+-  amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
++  amd64,gcc*,macosx,*) partialld="ld -r";;
+   amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
+   *,gcc*,*,*)          nativecccompopts="$gcc_warnings";;
+ esac
+@@ -752,8 +752,8 @@
+                     asppprofflags='-pg -DPROFILING';;
+   alpha,*,*)        as='as'
+                     aspp='gcc -c';;
+-  amd64,*,macosx)   as='as -arch x86_64'
+-                    aspp='gcc -arch x86_64 -c';;
++  amd64,*,macosx)   as='as'
++                    aspp='gcc -c';;
+   amd64,*,solaris)  as='as --64'
+                     aspp='gcc -m64 -c';;
+   amd64,*,*)        as='as'
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix
new file mode 100644
index 000000000000..8636f670059c
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix
@@ -0,0 +1,69 @@
+{ stdenv, fetchurl, ncurses, xlibsWrapper }:
+
+let
+   useX11 = !stdenv.isAarch32 && !stdenv.isMips;
+   useNativeCompilers = !stdenv.isMips;
+   inherit (stdenv.lib) optionals optionalString;
+in
+
+stdenv.mkDerivation rec {
+  
+  name = "ocaml-${version}";
+  version = "3.12.1";
+  
+  src = fetchurl {
+    url = "https://caml.inria.fr/pub/distrib/ocaml-3.12/${name}.tar.bz2";
+    sha256 = "13cmhkh7s6srnlvhg3s9qzh3a5dbk2m9qr35jzq922sylwymdkzd";
+  };
+
+  prefixKey = "-prefix ";
+  configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" xlibsWrapper ];
+  buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
+  buildInputs = [ncurses] ++ optionals useX11 [ xlibsWrapper ];
+  installTargets = "install" + optionalString useNativeCompilers " installopt";
+  patches = optionals stdenv.isDarwin [ ./3.12.1-darwin-fix-configure.patch ];
+  preConfigure = ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+  '';
+  postBuild = ''
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+  '';
+
+  passthru = {
+    nativeCompilers = useNativeCompilers;
+  };
+
+  meta = with stdenv.lib; {
+    homepage = http://caml.inria.fr/ocaml;
+    branch = "3.12";
+    license = with licenses; [
+      qpl /* compiler */
+      lgpl2 /* library */
+    ];
+    description = "Most popular variant of the Caml language";
+
+    longDescription =
+      ''
+        OCaml is the most popular variant of the Caml language.  From a
+        language standpoint, it extends the core Caml language with a
+        fully-fledged object-oriented layer, as well as a powerful module
+        system, all connected by a sound, polymorphic type system featuring
+        type inference.
+
+        The OCaml system is an industrial-strength implementation of this
+        language, featuring a high-performance native-code compiler (ocamlopt)
+        for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc,
+        Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc)
+        and an interactive read-eval-print loop (ocaml) for quick development
+        and portability.  The OCaml distribution includes a comprehensive
+        standard library, a replay debugger (ocamldebug), lexer (ocamllex) and
+        parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4)
+        and a documentation generator (ocamldoc).
+      '';
+
+    platforms = with platforms; linux;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix
new file mode 100644
index 000000000000..0a30ef1352c4
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix
@@ -0,0 +1,67 @@
+{ stdenv, fetchurl, ncurses, xlibsWrapper }:
+
+let
+   useX11 = !stdenv.isAarch32 && !stdenv.isMips;
+   useNativeCompilers = !stdenv.isMips;
+   inherit (stdenv.lib) optionals optionalString;
+in
+
+stdenv.mkDerivation rec {
+  name = "ocaml-${version}";
+  version = "4.00.1";
+  
+  src = fetchurl {
+    url = "https://caml.inria.fr/pub/distrib/ocaml-4.00/${name}.tar.bz2";
+    sha256 = "33c3f4acff51685f5bfd7c260f066645e767d4e865877bf1613c176a77799951";
+  };
+
+  prefixKey = "-prefix ";
+  configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" xlibsWrapper ];
+  buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
+  buildInputs = [ncurses] ++ optionals useX11 [ xlibsWrapper ];
+  installTargets = "install" + optionalString useNativeCompilers " installopt";
+  preConfigure = ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+  '';
+  postBuild = ''
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+  '';
+
+  passthru = {
+    nativeCompilers = useNativeCompilers;
+  };
+
+  meta = with stdenv.lib; {
+    homepage = http://caml.inria.fr/ocaml;
+    branch = "4.00";
+    license = with licenses; [
+      qpl /* compiler */
+      lgpl2 /* library */
+    ];
+    description = "Most popular variant of the Caml language";
+
+    longDescription =
+      ''
+        OCaml is the most popular variant of the Caml language.  From a
+        language standpoint, it extends the core Caml language with a
+        fully-fledged object-oriented layer, as well as a powerful module
+        system, all connected by a sound, polymorphic type system featuring
+        type inference.
+
+        The OCaml system is an industrial-strength implementation of this
+        language, featuring a high-performance native-code compiler (ocamlopt)
+        for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc,
+        Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc)
+        and an interactive read-eval-print loop (ocaml) for quick development
+        and portability.  The OCaml distribution includes a comprehensive
+        standard library, a replay debugger (ocamldebug), lexer (ocamllex) and
+        parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4)
+        and a documentation generator (ocamldoc).
+      '';
+
+    platforms = with platforms; linux;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix
new file mode 100644
index 000000000000..aa6cf68d2c96
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix
@@ -0,0 +1,7 @@
+import ./generic.nix rec {
+  major_version = "4";
+  minor_version = "01";
+  patch_version = "0";
+  patches = [ ./fix-clang-build-on-osx.diff ];
+  sha256 = "03d7ida94s1gpr3gadf4jyhmh5rrszd5s4m4z59daaib25rvfyv7";
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.02.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.02.nix
new file mode 100644
index 000000000000..9ac53f567909
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.02.nix
@@ -0,0 +1,7 @@
+import ./generic.nix rec {
+  major_version = "4";
+  minor_version = "02";
+  patch_version = "3";
+  patches = [ ./ocamlbuild.patch ];
+  sha256 = "1qwwvy8nzd87hk8rd9sm667nppakiapnx4ypdwcrlnav2dz6kil3";
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.03.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.03.nix
new file mode 100644
index 000000000000..c9536c487d05
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.03.nix
@@ -0,0 +1,6 @@
+import ./generic.nix rec {
+  major_version = "4";
+  minor_version = "03";
+  patch_version = "0";
+  sha256 = "09p3iwwi55r6rbrpyp8f0wmkb0ppcgw67yxw6yfky60524wayp39";
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.04.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.04.nix
new file mode 100644
index 000000000000..4f49bcf80728
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.04.nix
@@ -0,0 +1,9 @@
+import ./generic.nix {
+  major_version = "4";
+  minor_version = "04";
+  patch_version = "2";
+  sha256 = "0bhgjzi78l10824qga85nlh18jg9lb6aiamf9dah1cs6jhzfsn6i";
+
+  # If the executable is stipped it does not work
+  dontStrip = true;
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.05.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.05.nix
new file mode 100644
index 000000000000..a63b06a9f628
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.05.nix
@@ -0,0 +1,9 @@
+import ./generic.nix {
+  major_version = "4";
+  minor_version = "05";
+  patch_version = "0";
+  sha256 = "1y9fw1ci9pwnbbrr9nwr8cq8vypcxwdf4akvxard3mxl2jx2g984";
+
+  # If the executable is stipped it does not work
+  dontStrip = true;
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.06.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.06.nix
new file mode 100644
index 000000000000..b54b8a6288fe
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.06.nix
@@ -0,0 +1,9 @@
+import ./generic.nix {
+  major_version = "4";
+  minor_version = "06";
+  patch_version = "1";
+  sha256 = "1n3pygfssd6nkrq876wszm5nm3v4605q4k16a66h1nmq9wvf01vg";
+
+  # If the executable is stipped it does not work
+  dontStrip = true;
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.07.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.07.nix
new file mode 100644
index 000000000000..c1952f30ba68
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/4.07.nix
@@ -0,0 +1,9 @@
+import ./generic.nix {
+  major_version = "4";
+  minor_version = "07";
+  patch_version = "1";
+  sha256 = "1f07hgj5k45cylj1q3k5mk8yi02cwzx849b1fwnwia8xlcfqpr6z";
+
+  # If the executable is stripped it does not work
+  dontStrip = true;
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix b/nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix
new file mode 100644
index 000000000000..999b2ebd6f67
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix
@@ -0,0 +1,96 @@
+{ stdenv, fetchurl
+, ncurses
+, libX11, xproto, buildEnv
+}:
+
+let
+   useX11 = stdenv.isi686 || stdenv.isx86_64;
+   x11deps = [ libX11 xproto ];
+   inherit (stdenv.lib) optionals;
+
+   baseOcamlBranch  = "4.07";
+   baseOcamlVersion = "${baseOcamlBranch}.1";
+   metaocamlPatch   = "107";
+in
+
+stdenv.mkDerivation rec {
+  name = "ber-metaocaml-${version}";
+  version = metaocamlPatch;
+
+  src = fetchurl {
+    url = "https://caml.inria.fr/pub/distrib/ocaml-${baseOcamlBranch}/ocaml-${baseOcamlVersion}.tar.gz";
+    sha256 = "1x4sln131mcspisr22qc304590rvg720rbl7g2i4xiymgvhkpm1a";
+  };
+
+  metaocaml = fetchurl {
+    url = "http://okmij.org/ftp/ML/ber-metaocaml-107.tar.gz";
+    sha256 = "0xy6n0yj1f53pk612zfmn49pn04bd75qa40xgmr0w0lzx6dqsfmm";
+  };
+
+  x11env = buildEnv { name = "x11env"; paths = x11deps; };
+  x11lib = "${x11env}/lib";
+  x11inc = "${x11env}/include";
+
+  prefixKey = "-prefix ";
+  configureFlags = optionals useX11
+    [ "-x11lib" x11lib
+      "-x11include" x11inc
+      "-flambda"
+    ];
+
+  dontStrip = true;
+  buildInputs = [ ncurses ] ++ optionals useX11 x11deps;
+
+  postConfigure = ''
+    tar -xvzf $metaocaml
+    cd ${name}
+    make patch
+    cd ..
+  '';
+
+  buildPhase = ''
+    make world
+    make -i install
+
+    make bootstrap
+    make opt.opt
+    make installopt
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+    cd ${name}
+    make all
+  '';
+
+  installPhase = ''
+    make install
+    make install.opt
+  '';
+
+  checkPhase = ''
+    cd ${name}
+    make test
+    make test-compile
+    make test-native
+    cd ..
+  '';
+
+  passthru = {
+    nativeCompilers = true;
+  };
+
+  meta = with stdenv.lib; {
+    description     = "Multi-Stage Programming extension for OCaml";
+    homepage        = http://okmij.org/ftp/ML/MetaOCaml.html;
+    license         = with licenses; [ /* compiler */ qpl /* library */ lgpl2 ];
+    maintainers     = with maintainers; [ thoughtpolice ];
+
+    branch          = baseOcamlBranch;
+    platforms       = with platforms; linux ++ darwin;
+    broken          = stdenv.isAarch64 || stdenv.isMips;
+
+    longDescription = ''
+      A simple extension of OCaml with the primitive type of code values, and
+      three basic multi-stage expression forms: Brackets, Escape, and Run.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/builder.sh b/nixpkgs/pkgs/development/compilers/ocaml/builder.sh
new file mode 100644
index 000000000000..a1807682d867
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/builder.sh
@@ -0,0 +1,8 @@
+source $stdenv/setup
+
+configureFlags="-prefix $out $configureFlags"
+genericBuild
+
+#cd emacs/
+#mkdir -p $out/share/ocaml/emacs
+#make EMACSDIR=$out/share/ocaml/emacs install
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/configure-3.08.0 b/nixpkgs/pkgs/development/compilers/ocaml/configure-3.08.0
new file mode 100755
index 000000000000..9c8705855120
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/configure-3.08.0
@@ -0,0 +1,1482 @@
+#! /bin/sh
+
+#########################################################################
+#                                                                       #
+#                            Objective Caml                             #
+#                                                                       #
+#            Xavier Leroy, projet Cristal, INRIA Rocquencourt           #
+#                                                                       #
+#   Copyright 1999 Institut National de Recherche en Informatique et    #
+#   en Automatique.  All rights reserved.  This file is distributed     #
+#   under the terms of the GNU Library General Public License, with     #
+#   the special exception on linking described in file LICENSE.         #
+#                                                                       #
+#########################################################################
+
+# $Id: configure,v 1.215.2.3 2004/07/09 15:08:51 doligez Exp $
+
+configure_options="$*"
+prefix=/usr/local
+bindir=''
+libdir=''
+mandir=''
+manext=1
+host_type=unknown
+ccoption=''
+cclibs=''
+curseslibs=''
+mathlib='-lm'
+dllib=''
+x11_include_dir=''
+x11_lib_dir=''
+tk_wanted=yes
+pthread_wanted=yes
+tk_defs=''
+tk_libs=''
+tk_x11=yes
+dl_defs=''
+verbose=no
+withcurses=yes
+withsharedlibs=yes
+binutils_dir=''
+gcc_warnings="-Wall"
+
+# Try to turn internationalization off, can cause config.guess to malfunction!
+unset LANG
+unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME 
+
+# Turn off some macOS debugging stuff, same reason
+unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED
+
+# Parse command-line arguments
+
+while : ; do
+  case "$1" in
+    "") break;;
+    -prefix|--prefix)
+        prefix=$2; shift;;
+    -bindir|--bindir)
+        bindir=$2; shift;;
+    -libdir|--libdir)
+        libdir=$2; shift;;
+    -mandir|--mandir)
+        case "$2" in
+          */man[1-9ln])
+            mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'`
+            manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;;
+          *)
+            mandir=$2
+            manext=1;;
+        esac
+        shift;;
+    -host*|--host*)
+        host_type=$2; shift;;
+    -cc*)
+        ccoption="$2"; shift;;
+    -lib*)
+        cclibs="$2 $cclibs"; shift;;
+    -no-curses)
+        withcurses=no;;
+    -no-shared-libs)
+        withsharedlibs=no;;
+    -x11include*|--x11include*)
+        x11_include_dir=$2; shift;;
+    -x11lib*|--x11lib*)
+        x11_lib_dir=$2; shift;;
+    -with-pthread*|--with-pthread*)
+        ;; # Ignored for backward compatibility
+    -no-pthread*|--no-pthread*)
+        pthread_wanted=no;;
+    -no-tk|--no-tk)
+        tk_wanted=no;;
+    -tkdefs*|--tkdefs*)
+        tk_defs=$2; shift;;
+    -tklibs*|--tklibs*)
+        tk_libs=$2; shift;;
+    -tk-no-x11|--tk-no-x11)
+        tk_x11=no;;
+    -dldefs*|--dldefs*)
+        dl_defs="$2"; shift;;
+    -dllibs*|--dllibs*)
+        dllib="$2"; shift;;
+    -binutils*|--binutils*)
+        binutils_dir=$2; shift;;
+    -verbose|--verbose)
+        verbose=yes;;
+    *) echo "Unknown option \"$1\"." 1>&2; exit 2;;
+  esac
+  shift
+done
+
+# Sanity checks
+
+case "$prefix" in
+  /*) ;;
+   *) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
+esac
+case "$bindir" in
+  /*) ;;
+  "") ;;
+   *) echo "The -bindir directory must be absolute." 1>&2; exit 2;;
+esac
+case "$libdir" in
+  /*) ;;
+  "") ;;
+   *) echo "The -libdir directory must be absolute." 1>&2; exit 2;;
+esac
+case "$mandir" in
+  /*) ;;
+  "") ;;
+   *) echo "The -mandir directory must be absolute." 1>&2; exit 2;;
+esac
+
+# Generate the files
+
+cd config/auto-aux
+rm -f s.h m.h Makefile
+touch s.h m.h Makefile
+
+# Write options to Makefile
+
+echo "# generated by ./configure $configure_options" >> Makefile
+
+# Where to install
+
+echo "PREFIX=$prefix" >> Makefile
+case "$bindir" in
+  "") echo 'BINDIR=$(PREFIX)/bin' >> Makefile
+      bindir="$prefix/bin";;
+   *) echo "BINDIR=$bindir" >> Makefile;;
+esac
+case "$libdir" in
+  "") echo 'LIBDIR=$(PREFIX)/lib/ocaml' >> Makefile
+      libdir="$prefix/lib/ocaml";;
+   *) echo "LIBDIR=$libdir" >> Makefile;;
+esac
+echo 'STUBLIBDIR=$(LIBDIR)/stublibs' >> Makefile
+case "$mandir" in
+  "") echo 'MANDIR=$(PREFIX)/man' >> Makefile
+      mandir="$prefix/man";;
+   *) echo "MANDIR=$mandir" >> Makefile;;
+esac
+echo "MANEXT=$manext" >> Makefile
+
+# Determine the system type
+
+if test "$host_type" = "unknown"; then
+  if host_type=`../gnu/config.guess`; then :; else
+    echo "Cannot guess host type"
+    echo "You must specify one with the -host option"
+    exit 2
+  fi
+fi
+if host=`../gnu/config.sub $host_type`; then :; else
+  echo "Please specify the correct host type with the -host option"
+  exit 2
+fi
+echo "Configuring for a $host ..."
+
+# Do we have gcc?
+
+if test -z "$ccoption"; then
+  if sh ./searchpath gcc; then
+    echo "gcc found"
+    cc=gcc
+  else
+    cc=cc
+  fi
+else
+  cc="$ccoption"
+fi
+
+# Check for buggy versions of GCC
+
+buggycc="no"
+
+case "$host,$cc" in
+  i[3456]86-*-*,gcc*)
+    case `$cc --version` in
+      2.7.2.1) cat <<'EOF'
+
+WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor.
+This version of gcc is known to generate incorrect code for the
+Objective Caml runtime system on some Intel x86 machines. (The symptom
+is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.)
+In particular, the version of gcc 2.7.2.1 that comes with
+Linux RedHat 4.x / Intel is affected by this problem.
+Other Linux distributions might also be affected.
+If you are using one of these configurations, you are strongly advised
+to use another version of gcc, such as 2.95, which are
+known to work well with Objective Caml.
+
+Press <enter> to proceed or <interrupt> to stop.
+EOF
+        read reply;;
+      2.96*) cat <<'EOF'
+
+WARNING: you are using gcc version 2.96 on an Intel x86 processor.
+Certain patched versions of gcc 2.96 are known to generate incorrect
+code for the Objective Caml runtime system.  (The symptom is a segmentation
+violation on boot/ocamlc.)  Those incorrectly patched versions can be found
+in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions
+might also be affected.  (See bug #57760 on bugzilla.redhat.com)
+
+Auto-configuration will now select gcc compiler flags that work around
+the problem.  Still, if you observe segmentation faults while running
+ocamlc or ocamlopt, you are advised to try another version of gcc,
+such as 2.95.3 or 3.2.
+
+EOF
+        buggycc="gcc.2.96";;
+
+            esac;;
+esac
+
+# Configure the bytecode compiler
+
+bytecc="$cc"
+bytecccompopts=""
+bytecclinkopts=""
+ostype="Unix"
+exe=""
+
+case "$bytecc,$host" in
+  cc,*-*-nextstep*)
+    # GNU C extensions disabled, but __GNUC__ still defined!
+    bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
+    bytecclinkopts="-posix";;
+  *,*-*-rhapsody*)
+    # Almost the same as NeXTStep
+    bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
+    mathlib="";;
+  *,*-*-darwin*)
+    # Almost the same as rhapsody
+    bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings"
+    mathlib="";;
+  *,*-*-beos*)
+    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    # No -lm library
+    mathlib="";;
+  gcc,alpha*-*-osf*)
+    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    if cc="$bytecc" sh ./hasgot -mieee; then
+      bytecccompopts="-mieee $bytecccompopts";
+    fi
+    # Put code and static data in lower 4GB
+    bytecclinkopts="-Wl,-T,12000000 -Wl,-D,14000000"
+    # Tell gcc that we can use 32-bit code addresses for threaded code
+    echo "#define ARCH_CODE32" >> m.h;;
+  cc,alpha*-*-osf*)
+    bytecccompopts="-std1 -ieee";;
+  gcc,alpha*-*-linux*)
+    if cc="$bytecc" sh ./hasgot -mieee; then
+      bytecccompopts="-mieee $bytecccompopts";
+    fi;;
+  cc,mips-*-irix6*)
+    # Add -n32 flag to ensure compatibility with native-code compiler
+    bytecccompopts="-n32"
+    # Turn off warning "unused library"
+    bytecclinkopts="-n32 -Wl,-woff,84";;
+  cc*,mips-*-irix6*)
+    # (For those who want to force "cc -64")
+    # Turn off warning "unused library"
+    bytecclinkopts="-Wl,-woff,84";;
+  *,alpha*-*-unicos*)
+    # For the Cray T3E
+    bytecccompopts="-DUMK";;
+  gcc*,powerpc-*-aix4.3*)
+    # Avoid name-space pollution by requiring Unix98-conformant includes
+    bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
+  *,powerpc-*-aix4.3*)
+    bytecccompopts="-D_XOPEN_SOURCE=500";;
+  gcc*,*-*-cygwin*)
+    bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
+    exe=".exe"
+    ostype="Cygwin";;
+  gcc*,x86_64-*-linux*)
+    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    # Tell gcc that we can use 32-bit code addresses for threaded code
+    echo "#define ARCH_CODE32" >> m.h;;
+  gcc*)
+    bytecccompopts="-fno-defer-pop $gcc_warnings";;
+esac
+
+# Configure compiler to use in further tests
+
+cc="$bytecc -O $bytecclinkopts"
+export cc cclibs verbose
+
+# Check C compiler
+
+sh ./runtest ansi.c
+case $? in
+  0) echo "The C compiler is ANSI-compliant.";;
+  1) echo "The C compiler $cc is not ANSI-compliant."
+     echo "You need an ANSI C compiler to build Objective Caml."
+     exit 2;;
+  *) echo "Unable to compile the test program."
+     echo "Make sure the C compiler $cc is properly installed."
+     exit 2;;
+esac
+
+# Check the sizes of data types
+
+echo "Checking the sizes of integers and pointers..."
+set `sh ./runtest sizes.c`
+case "$2,$3" in
+  4,4) echo "OK, this is a regular 32 bit architecture."
+       echo "#undef ARCH_SIXTYFOUR" >> m.h;;
+  8,8) echo "Wow! A 64 bit architecture!"
+       echo "#define ARCH_SIXTYFOUR" >> m.h;;
+  *,8) echo "Wow! A 64 bit architecture!"
+       echo "Unfortunately, Objective Caml cannot work in the case"
+       echo "sizeof(long) != sizeof(long *)."
+       echo "Objective Caml won't run on this architecture."
+       exit 2;;
+  *,*) echo "This architecture seems to be neither 32 bits nor 64 bits."
+       echo "Objective Caml won't run on this architecture."
+       exit 2;;
+    *) echo "Unable to compile the test program."
+       echo "Make sure the C compiler $cc is properly installed."
+       exit 2;;
+esac
+if test $1 != 4 && test $2 != 4 && test $4 != 4; then
+  echo "Sorry, we can't find a 32-bit integer type"
+  echo "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)"
+  echo "Objective Caml won't run on this architecture."
+  exit 2
+fi
+
+echo "#define SIZEOF_INT $1" >> m.h
+echo "#define SIZEOF_LONG $2" >> m.h
+echo "#define SIZEOF_SHORT $4" >> m.h
+
+if test $2 = 8; then
+     echo "#define ARCH_INT64_TYPE long" >> m.h
+     echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h
+     echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h
+     int64_native=true
+else
+  sh ./runtest longlong.c
+  case $? in
+  0) echo "64-bit \"long long\" integer type found (printf with \"%ll\")."
+     echo "#define ARCH_INT64_TYPE long long" >> m.h
+     echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
+     echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h
+     int64_native=true;;
+  1) echo "64-bit \"long long\" integer type found (printf with \"%q\")."
+     echo "#define ARCH_INT64_TYPE long long" >> m.h
+     echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
+     echo '#define ARCH_INT64_PRINTF_FORMAT "q"' >> m.h
+     int64_native=true;;
+  2) echo "64-bit \"long long\" integer type found (but no printf)."
+     echo "#define ARCH_INT64_TYPE long long" >> m.h
+     echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
+     echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
+     int64_native=true;;
+  *) echo "No suitable 64-bit integer type found, will use software emulation."
+     echo "#undef ARCH_INT64_TYPE" >> m.h
+     echo "#undef ARCH_UINT64_TYPE" >> m.h
+     echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
+     int64_native=false;;
+  esac
+fi
+
+# Determine endianness
+
+sh ./runtest endian.c
+case $? in
+  0) echo "This is a big-endian architecture."
+     echo "#define ARCH_BIG_ENDIAN" >> m.h;;
+  1) echo "This is a little-endian architecture."
+     echo "#undef ARCH_BIG_ENDIAN" >> m.h;;
+  2) echo "This architecture seems to be neither big endian nor little endian."
+     echo "Objective Caml won't run on this architecture."
+     exit 2;;
+  *) echo "Something went wrong during endianness determination."
+     echo "You'll have to figure out endianness yourself"
+     echo "(option ARCH_BIG_ENDIAN in m.h).";;
+esac
+
+# Determine alignment constraints
+
+case "$host" in
+  sparc-*-*|hppa*-*-*)
+    # On Sparc V9 with certain versions of gcc, determination of double
+    # alignment is not reliable (PR#1521), hence force it.
+    # Same goes for hppa.
+    # But there's a knack (PR#2572):
+    # if we're in 64-bit mode (sizeof(long) == 8), 
+    # we must not doubleword-align floats...
+    if test $2 = 8; then
+      echo "Doubles can be word-aligned."
+      echo "#undef ARCH_ALIGN_DOUBLE" >> m.h
+    else
+      echo "Doubles must be doubleword-aligned."
+      echo "#define ARCH_ALIGN_DOUBLE" >> m.h
+    fi;;
+  *)
+    sh ./runtest dblalign.c
+    case $? in
+      0) echo "Doubles can be word-aligned."
+         echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;;
+      1) echo "Doubles must be doubleword-aligned."
+         echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
+      *) echo "Something went wrong during alignment determination for doubles."
+         echo "I'm going to assume this architecture has alignment constraints over doubles."
+         echo "That's a safe bet: Objective Caml will work even if"
+         echo "this architecture has actually no alignment constraints."
+         echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
+    esac;;
+esac
+
+if $int64_native; then
+  case "$host" in
+    hppa*-*-*)
+      if test $2 = 8; then
+        echo "64-bit integers can be word-aligned."
+        echo "#undef ARCH_ALIGN_INT64" >> m.h
+      else
+        echo "64-bit integers must be doubleword-aligned."
+        echo "#define ARCH_ALIGN_INT64" >> m.h
+      fi;;
+    *)
+      sh ./runtest int64align.c
+      case $? in
+        0) echo "64-bit integers can be word-aligned."
+           echo "#undef ARCH_ALIGN_INT64" >> m.h;;
+        1) echo "64-bit integers must be doubleword-aligned."
+           echo "#define ARCH_ALIGN_INT64" >> m.h;;
+        *) echo "Something went wrong during alignment determination for 64-bit integers."
+           echo "I'm going to assume this architecture has alignment constraints."
+           echo "That's a safe bet: Objective Caml will work even if"
+           echo "this architecture has actually no alignment constraints."
+           echo "#define ARCH_ALIGN_INT64" >> m.h;;
+      esac
+  esac
+else
+  echo "#undef ARCH_ALIGN_INT64" >> m.h
+fi
+
+# Check semantics of division and modulus
+
+sh ./runtest divmod.c
+case $? in
+  0) echo "Native division and modulus have round-towards-zero semantics, will use them."
+     echo "#undef NONSTANDARD_DIV_MOD" >> m.h;;
+  1) echo "Native division and modulus do not have round-towards-zero semantics, will use software emulation."
+     echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
+  *) echo "Something went wrong while checking native division and modulus, please report it."
+     echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
+esac
+
+# Shared library support
+
+shared_libraries_supported=false
+dl_needs_underscore=false
+sharedcccompopts=''
+mksharedlib=''
+byteccrpath=''
+mksharedlibrpath=''
+
+if test $withsharedlibs = "yes"; then
+  case "$host" in
+    *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*)
+      sharedcccompopts="-fPIC"
+      mksharedlib="$bytecc -shared -o"
+      bytecclinkopts="$bytecclinkopts -Wl,-E"
+      byteccrpath="-Wl,-rpath,"
+      mksharedlibrpath="-Wl,-rpath,"
+      shared_libraries_supported=true;;
+    alpha*-*-osf*)
+      case "$bytecc" in
+        gcc*)
+          sharedcccompopts="-fPIC"
+          mksharedlib="$bytecc -shared -o"
+          byteccrpath="-Wl,-rpath,"
+          mksharedlibrpath="-Wl,-rpath,"
+          shared_libraries_supported=true;;
+        cc*)
+          sharedcccompopts=""
+          mksharedlib="ld -shared -expect_unresolved '*' -o"
+          byteccrpath="-Wl,-rpath,"
+          mksharedlibrpath="-rpath "
+          shared_libraries_supported=true;;
+      esac;;
+    *-*-solaris2*)
+      case "$bytecc" in
+        gcc*)
+          sharedcccompopts="-fPIC"
+          if sh ./solaris-ld; then
+            mksharedlib="$bytecc -shared -o"
+            byteccrpath="-R"
+            mksharedlibrpath="-R"
+          else
+            mksharedlib="$bytecc -shared -o"
+            bytecclinkopts="$bytecclinkopts -Wl,-E"
+            byteccrpath="-Wl,-rpath,"
+            mksharedlibrpath="-Wl,-rpath,"
+          fi
+          shared_libraries_supported=true;;
+        *)
+          sharedcccompopts="-KPIC"
+          byteccrpath="-R"
+          mksharedlibrpath="-R"
+          mksharedlib="/usr/ccs/bin/ld -G -o"
+          shared_libraries_supported=true;;
+      esac;;
+    mips*-*-irix[56]*)
+      case "$bytecc" in
+        cc*) sharedcccompopts="";;
+        gcc*) sharedcccompopts="-fPIC";;
+      esac
+      mksharedlib="ld -shared -rdata_shared -o"
+      byteccrpath="-Wl,-rpath,"
+      mksharedlibrpath="-rpath "
+      shared_libraries_supported=true;;
+    powerpc-apple-darwin*)
+      mksharedlib="cc -bundle -flat_namespace -undefined suppress -o"
+      bytecccompopts="$dl_defs $bytecccompopts"
+      #sharedcccompopts="-fnocommon"
+      dl_needs_underscore=true
+      shared_libraries_supported=true;;
+  esac
+fi
+
+# Further machine-specific hacks
+
+case "$host" in
+  ia64-*-linux*|alpha*-*-linux*|x86_64-*-linux*)
+    echo "Will use mmap() instead of malloc() for allocation of major heap chunks."
+    echo "#define USE_MMAP_INSTEAD_OF_MALLOC" >> s.h;;
+esac
+
+# Configure the native-code compiler
+
+arch=none
+model=default
+system=unknown
+
+case "$host" in
+  alpha*-*-osf*)                arch=alpha; system=digital;;
+  alpha*-*-linux*)              arch=alpha; system=linux;;
+  alpha*-*-freebsd*)            arch=alpha; system=freebsd;;
+  alpha*-*-netbsd*)             arch=alpha; system=netbsd;;
+  alpha*-*-openbsd*)            arch=alpha; system=openbsd;;
+  sparc*-*-sunos4.*)            arch=sparc; system=sunos;;
+  sparc*-*-solaris2.*)          arch=sparc; system=solaris;;
+  sparc*-*-*bsd*)               arch=sparc; system=bsd;;
+  sparc*-*-linux*)              arch=sparc; system=linux;;
+  i[3456]86-*-linux*)           arch=i386; system=linux_`sh ./runtest elf.c`;;
+  i[3456]86-*-*bsd*)            arch=i386; system=bsd_`sh ./runtest elf.c`;;
+  i[3456]86-*-nextstep*)        arch=i386; system=nextstep;;
+  i[3456]86-*-solaris*)         arch=i386; system=solaris;;
+  i[3456]86-*-beos*)            arch=i386; system=beos;;
+  i[3456]86-*-cygwin*)          arch=i386; system=cygwin;;
+  mips-*-irix6*)                arch=mips; system=irix;;
+  hppa1.1-*-hpux*)              arch=hppa; system=hpux;;
+  hppa2.0*-*-hpux*)             arch=hppa; system=hpux;;
+  hppa*-*-linux*)		arch=hppa; system=linux;;
+  powerpc-*-linux*)             arch=power; model=ppc; system=elf;;
+  powerpc-*-netbsd*)            arch=power; model=ppc; system=bsd;;
+  powerpc-*-rhapsody*)          arch=power; model=ppc; system=rhapsody;;
+  powerpc-*-darwin*)            arch=power; model=ppc; system=rhapsody;;
+  arm*-*-linux*)                arch=arm; system=linux;;
+  ia64-*-linux*)                arch=ia64; system=linux;;
+  ia64-*-freebsd*)              arch=ia64; system=freebsd;;
+  x86_64-*-linux*)              arch=amd64; system=linux;;
+  x86_64-*-freebsd*)            arch=amd64; system=freebsd;;
+  x86_64-*-openbsd*)            arch=amd64; system=openbsd;;
+esac
+
+if test -z "$ccoption"; then
+  case "$arch,$system,$cc" in
+    alpha,digital,gcc*) nativecc=cc;;
+    mips,*,gcc*) nativecc=cc;;
+    *) nativecc="$bytecc";;
+  esac
+else
+  nativecc="$ccoption"
+fi
+
+nativecccompopts=''
+nativecclinkopts=''
+nativeccrpath="$byteccrpath"
+
+case "$arch,$nativecc,$system,$host_type" in
+  alpha,cc*,digital,*) nativecccompopts=-std1;;
+  mips,cc*,irix,*)     nativecccompopts=-n32
+                       nativecclinkopts="-n32 -Wl,-woff,84";;
+  *,*,nextstep,*)      nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
+                       nativecclinkopts="-posix";;
+  *,*,rhapsody,*darwin[1-5].*)
+                       nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
+  *,*,rhapsody,*)
+                 nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs";;
+  *,gcc*,cygwin,*)     nativecccompopts="$gcc_warnings -U_WIN32";;
+  *,gcc*,*,*)          nativecccompopts="$gcc_warnings";;
+esac
+
+asflags=''
+aspp='$(AS)'
+asppflags=''
+asppprofflags='-DPROFILING'
+
+case "$arch,$model,$system" in
+  alpha,*,digital)  asflags='-O2'; asppflags='-O2 -DSYS_$(SYSTEM)';
+                    asppprofflags='-pg -DPROFILING';;
+  alpha,*,linux)    aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  alpha,*,freebsd)  aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  alpha,*,netbsd)   aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  alpha,*,openbsd)  aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  mips,*,irix)      asflags='-n32 -O2'; asppflags="$asflags";;
+  sparc,*,bsd)      aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  sparc,*,linux)    aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  sparc,*,*)        case "$cc" in
+                      gcc*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+                         *) asppflags='-P -DSYS_$(SYSTEM)';;
+                    esac;;
+  i386,*,solaris)   aspp='/usr/ccs/bin/as'; asppflags='-P -DSYS_$(SYSTEM)';;
+  i386,*,*)         aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  hppa,*,*)         aspp="$cc"; asppflags='-traditional -c -DSYS_$(SYSTEM)';;
+  power,*,elf)      aspp='gcc'; asppflags='-c';;
+  power,*,bsd)      aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  power,*,rhapsody) ;;
+  arm,*,linux)      aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+  ia64,*,*)         asflags=-xexplicit
+                    aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM) -Wa,-xexplicit';;
+  amd64,*,*)        aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
+esac
+
+cc_profile='-pg'
+case "$arch,$model,$system" in
+  alpha,*,digital) profiling='prof';;
+  i386,*,linux_elf) profiling='prof';;
+  i386,*,bsd_elf) profiling='prof';;
+  sparc,*,solaris)
+    profiling='prof'
+    case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
+  amd64,*,linux) profiling='prof';;
+  *) profiling='noprof';;
+esac
+
+# Where are GNU binutils?
+
+binutils_objcopy=''
+binutils_nm=''
+
+if test "$arch" != "none"; then
+  binutils_path="${binutils_dir}:${PATH}:/usr/libexec/binutils"
+  old_IFS="$IFS"
+  IFS=':'
+  for d in ${binutils_path}; do
+    if test -z "$d"; then continue; fi
+    if test -f "$d/objcopy" && test -f "$d/nm"; then
+      echo "objcopy and nm found in $d"
+      if test `$d/objcopy --help | grep -s -c 'redefine-sym'` -eq 0; then
+        echo "$d/objcopy does not support option --redefine-sym, discarded"
+        continue;
+      fi
+      if test `$d/nm --version | grep -s -c 'GNU nm'` -eq 0; then
+        echo "$d/nm is not from GNU binutils, discarded"
+        continue;
+      fi
+      binutils_objcopy="$d/objcopy"
+      binutils_nm="$d/nm"
+      break
+    fi
+  done
+  IFS="$old_IFS"
+fi
+
+# Where is ranlib?
+
+if sh ./searchpath ranlib; then
+  echo "ranlib found"
+  echo "RANLIB=ranlib" >> Makefile
+  echo "RANLIBCMD=ranlib" >> Makefile
+else
+  echo "ranlib not used"
+  echo "RANLIB=ar rs" >> Makefile
+  echo "RANLIBCMD=" >> Makefile
+fi
+
+# Do #! scripts work?
+
+if (SHELL=/bin/sh; export SHELL; (./sharpbang || ./sharpbang2) >/dev/null); then
+  echo "#! appears to work in shell scripts"
+  case "$host" in
+    *-*-sunos*|*-*-unicos*)
+      echo "We won't use it, though, because under SunOS and Unicos it breaks"
+      echo "on pathnames longer than 30 characters"
+      echo "SHARPBANGSCRIPTS=false" >> Makefile;;
+    *-*-cygwin*)
+      echo "We won't use it, though, because of conflicts with .exe extension"
+      echo "under Cygwin"
+      echo "SHARPBANGSCRIPTS=false" >> Makefile;;
+    *)
+      echo "SHARPBANGSCRIPTS=true" >> Makefile;;
+  esac
+else
+  echo "No support for #! in shell scripts"
+  echo "SHARPBANGSCRIPTS=false" >> Makefile
+fi
+
+# Write the OS type (Unix or Cygwin)
+
+echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h
+echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h
+
+# Use 64-bit file offset if possible
+
+bytecccompopts="$bytecccompopts -D_FILE_OFFSET_BITS=64"
+nativecccompopts="$nativecccompopts -D_FILE_OFFSET_BITS=64"
+
+# Check the semantics of signal handlers
+
+if sh ./hasgot sigaction sigprocmask; then
+  echo "POSIX signal handling found."
+  echo "#define POSIX_SIGNALS" >> s.h
+else
+  if sh ./runtest signals.c; then
+    echo "Signals have the BSD semantics."
+    echo "#define BSD_SIGNALS" >> s.h
+  else
+    echo "Signals have the System V semantics."
+  fi
+  if sh ./hasgot sigsetmask; then
+    echo "sigsetmask() found"
+    echo "#define HAS_SIGSETMASK" >> s.h
+  fi
+fi
+
+# For the sys module
+
+if sh ./hasgot times; then
+  echo "times() found."
+  echo "#define HAS_TIMES" >> s.h
+fi
+
+# For the terminfo module
+
+if test "$withcurses" = "yes"; then
+  for libs in "" "-lcurses" "-ltermcap" "-lcurses -ltermcap" "-lncurses"; do
+    if sh ./hasgot $libs tgetent tgetstr tgetnum tputs; then
+      echo "termcap functions found (with libraries '$libs')"
+      echo "#define HAS_TERMCAP" >> s.h
+      curseslibs="${libs}"
+      break
+    fi
+  done
+fi
+
+# Configuration for the libraries
+
+otherlibraries="unix str num dynlink bigarray"
+
+# For the Unix library
+
+has_sockets=no
+if sh ./hasgot socket socketpair bind listen accept connect; then
+  echo "You have BSD sockets."
+  echo "#define HAS_SOCKETS" >> s.h
+  has_sockets=yes
+elif sh ./hasgot -lnsl -lsocket socket socketpair bind listen accept connect; then
+  echo "You have BSD sockets (with libraries '-lnsl -lsocket')"
+  cclibs="$cclibs -lnsl -lsocket"
+  echo "#define HAS_SOCKETS" >> s.h
+  has_sockets=yes
+fi
+
+if sh ./hasgot -i sys/socket.h -t socklen_t; then
+  echo "socklen_t is defined in <sys/socket.h>"
+  echo "#define HAS_SOCKLEN_T" >> s.h
+fi
+
+if sh ./hasgot inet_aton; then
+  echo "inet_aton() found."
+  echo "#define HAS_INET_ATON" >> s.h
+fi
+
+if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \
+               -t 'struct sockaddr_in6' \
+&& sh ./hasgot getaddrinfo getnameinfo inet_pton inet_ntop; then
+  echo "IPv6 is supported."
+  echo "#define HAS_IPV6" >> s.h
+fi
+
+if sh ./hasgot -i unistd.h; then
+  echo "unistd.h found."
+  echo "#define HAS_UNISTD" >> s.h
+fi
+
+if sh ./hasgot -i sys/types.h -t off_t; then
+  echo "off_t is defined in <sys/types.h>"
+  echo "#define HAS_OFF_T" >> s.h
+fi
+
+if sh ./hasgot -i sys/types.h -i dirent.h; then
+  echo "dirent.h found."
+  echo "#define HAS_DIRENT" >> s.h
+fi
+
+if sh ./hasgot rewinddir; then
+  echo "rewinddir() found."
+  echo "#define HAS_REWINDDIR" >> s.h
+fi
+
+if sh ./hasgot lockf; then
+  echo "lockf() found."
+  echo "#define HAS_LOCKF" >> s.h
+fi
+
+if sh ./hasgot mkfifo; then
+  echo "mkfifo() found."
+  echo "#define HAS_MKFIFO" >> s.h
+fi
+
+if sh ./hasgot getcwd; then
+  echo "getcwd() found."
+  echo "#define HAS_GETCWD" >> s.h
+fi
+
+if sh ./hasgot getwd; then
+  echo "getwd() found."
+  echo "#define HAS_GETWD" >> s.h
+fi
+
+if sh ./hasgot getpriority setpriority; then
+  echo "getpriority() found."
+  echo "#define HAS_GETPRIORITY" >> s.h
+fi
+
+if sh ./hasgot -i sys/types.h -i utime.h && sh ./hasgot utime; then
+  echo "utime() found."
+  echo "#define HAS_UTIME" >> s.h
+fi
+
+if sh ./hasgot utimes; then
+  echo "utimes() found."
+  echo "#define HAS_UTIMES" >> s.h
+fi
+
+if sh ./hasgot dup2; then
+  echo "dup2() found."
+  echo "#define HAS_DUP2" >> s.h
+fi
+
+if sh ./hasgot fchmod fchown; then
+  echo "fchmod() found."
+  echo "#define HAS_FCHMOD" >> s.h
+fi
+
+if sh ./hasgot truncate ftruncate; then
+  echo "truncate() found."
+  echo "#define HAS_TRUNCATE" >> s.h
+fi
+
+select_include=''
+if sh ./hasgot -i sys/types.h -i sys/select.h; then
+  echo "sys/select.h found."
+  echo "#define HAS_SYS_SELECT_H" >> s.h
+  select_include='-i sys/select.h'
+fi
+
+has_select=no
+if sh ./hasgot select && \
+   sh ./hasgot -i sys/types.h $select_include -t fd_set ; then
+  echo "select() found."
+  echo "#define HAS_SELECT" >> s.h
+  has_select=yes
+fi
+
+if sh ./hasgot symlink readlink lstat;  then
+  echo "symlink() found."
+  echo "#define HAS_SYMLINK" >> s.h
+fi
+
+has_wait=no
+if sh ./hasgot waitpid;  then
+  echo "waitpid() found."
+  echo "#define HAS_WAITPID" >> s.h
+  has_wait=yes
+fi
+
+if sh ./hasgot wait4;  then
+  echo "wait4() found."
+  echo "#define HAS_WAIT4" >> s.h
+  has_wait=yes
+fi
+
+if sh ./hasgot -i limits.h && sh ./runtest getgroups.c; then
+  echo "getgroups() found."
+  echo "#define HAS_GETGROUPS" >> s.h
+fi
+
+if sh ./hasgot -i termios.h &&
+   sh ./hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then
+  echo "POSIX termios found."
+  echo "#define HAS_TERMIOS" >> s.h
+fi
+
+# Async I/O under OSF1 3.x are so buggy that the test program hangs...
+testasyncio=true
+if test -f /usr/bin/uname; then
+  case "`/usr/bin/uname -s -r`" in
+    "OSF1 V3."*) testasyncio=false;;
+  esac
+fi
+if $testasyncio && sh ./runtest async_io.c; then
+  echo "Asynchronous I/O are supported."
+  echo "#define HAS_ASYNC_IO" >> s.h
+fi
+
+has_setitimer=no
+if sh ./hasgot setitimer; then
+  echo "setitimer() found."
+  echo "#define HAS_SETITIMER" >> s.h
+  has_setitimer="yes"
+fi
+
+if sh ./hasgot gethostname; then
+  echo "gethostname() found."
+  echo "#define HAS_GETHOSTNAME" >> s.h
+fi
+
+if sh ./hasgot -i sys/utsname.h && sh ./hasgot uname; then
+  echo "uname() found."
+  echo "#define HAS_UNAME" >> s.h
+fi
+
+has_gettimeofday=no
+if sh ./hasgot gettimeofday; then
+  echo "gettimeofday() found."
+  echo "#define HAS_GETTIMEOFDAY" >> s.h
+  has_gettimeofday="yes"
+fi
+
+if sh ./hasgot mktime; then
+  echo "mktime() found."
+  echo "#define HAS_MKTIME" >> s.h
+fi
+
+case "$host" in
+  *-*-cygwin*) ;;  # setsid emulation under Cygwin breaks the debugger
+  *) if sh ./hasgot setsid; then
+       echo "setsid() found."
+       echo "#define HAS_SETSID" >> s.h
+     fi;;
+esac
+
+if sh ./hasgot putenv; then
+  echo "putenv() found."
+  echo "#define HAS_PUTENV" >> s.h
+fi
+
+if sh ./hasgot -i locale.h && sh ./hasgot setlocale; then
+  echo "setlocale() and <locale.h> found."
+  echo "#define HAS_LOCALE" >> s.h
+fi
+
+if sh ./hasgot -i mach-o/dyld.h && sh ./hasgot NSLinkModule; then
+  echo "NSLinkModule() found. Using darwin dynamic loading."
+  echo "#define HAS_NSLINKMODULE" >> s.h
+elif sh ./hasgot $dllib dlopen; then
+  echo "dlopen() found."
+elif sh ./hasgot $dllib -ldl dlopen; then
+  echo "dlopen() found in -ldl."
+  dllib="$dllib -ldl"
+else
+  shared_libraries_supported=no
+fi
+
+if $shared_libraries_supported; then
+  echo "Dynamic loading of shared libraries is supported."
+  echo "#define SUPPORT_DYNAMIC_LINKING" >> s.h
+  if $dl_needs_underscore; then
+    echo '#define DL_NEEDS_UNDERSCORE' >>s.h
+  fi
+fi
+
+if sh ./hasgot -i sys/types.h -i sys/mman.h && sh ./hasgot mmap munmap; then
+  echo "mmap() found."
+  echo "#define HAS_MMAP" >> s.h
+fi
+
+nargs=none
+for i in 5 6; do
+  if sh ./trycompile -DNUM_ARGS=${i} gethostbyname.c; then nargs=$i; break; fi
+done
+if test $nargs != "none"; then
+  echo "gethostbyname_r() found (with ${nargs} arguments)."
+  echo "#define HAS_GETHOSTBYNAME_R $nargs" >> s.h
+fi
+
+nargs=none
+for i in 7 8; do
+  if sh ./trycompile -DNUM_ARGS=${i} gethostbyaddr.c; then nargs=$i; break; fi
+done
+if test $nargs != "none"; then
+  echo "gethostbyaddr_r() found (with ${nargs} arguments)."
+  echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h
+fi
+
+# Determine if the debugger is supported
+
+if test "$has_sockets" = "yes"; then
+  echo "Replay debugger supported."
+  debugger="ocamldebugger"
+else
+  echo "No replay debugger (missing system calls)"
+  debugger=""
+fi
+
+
+# Determine if system stack overflows can be detected
+
+case "$arch,$system" in
+  i386,linux_elf)
+    echo "System stack overflow can be detected."
+    echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
+  *)
+    echo "Cannot detect system stack overflow.";;
+esac
+
+# Determine the target architecture for the "num" library
+
+case "$host" in
+  alpha*-*-*)    bng_arch=alpha; bng_asm_level=1;;
+  i[3456]86-*-*) bng_arch=ia32
+                 if sh ./trycompile ia32sse2.c
+                 then bng_asm_level=2
+                 else bng_asm_level=1
+                 fi;;
+  mips-*-*)      bng_arch=mips; bng_asm_level=1;;
+  powerpc-*-*)   bng_arch=ppc; bng_asm_level=1;;
+  sparc*-*-*)    bng_arch=sparc; bng_asm_level=1;;
+  x86_64-*-*)    bng_arch=amd64; bng_asm_level=1;;
+  *)             bng_arch=generic; bng_asm_level=0;;
+esac
+
+echo "BNG_ARCH=$bng_arch" >> Makefile
+echo "BNG_ASM_LEVEL=$bng_asm_level" >> Makefile
+
+# Determine if the POSIX threads library is supported
+
+if test "$pthread_wanted" = "yes"; then
+  case "$host" in
+    *-*-solaris*)  pthread_link="-lpthread -lposix4";;
+    *-*-freebsd*)  pthread_link="-pthread";;
+    *-*-openbsd*)  pthread_link="-pthread";;
+    *)             pthread_link="-lpthread";;
+  esac
+  if ./hasgot -i pthread.h $pthread_link pthread_self; then
+    echo "POSIX threads library supported."
+    otherlibraries="$otherlibraries systhreads"
+    bytecccompopts="$bytecccompopts -D_REENTRANT"
+    nativecccompopts="$nativecccompopts -D_REENTRANT"
+    case "$host" in
+      *-*-freebsd*)
+          bytecccompopts="$bytecccompopts -D_THREAD_SAFE"
+          nativecccompopts="$nativecccompopts -D_THREAD_SAFE";;
+      *-*-openbsd*)
+          bytecccompopts="$bytecccompopts -pthread"
+          asppflags="$asppflags -pthread"
+          nativecccompopts="$nativecccompopts -pthread";;
+    esac
+    echo "Options for linking with POSIX threads: $pthread_link"
+    echo "PTHREAD_LINK=$pthread_link" >> Makefile
+    if sh ./hasgot $pthread_link sigwait; then
+      echo "sigwait() found"
+      echo "#define HAS_SIGWAIT" >> s.h
+    fi
+  else
+    echo "POSIX threads not found."
+    pthread_link=""
+  fi
+fi
+
+# Determine if the bytecode thread library is supported
+
+if test "$has_select" = "yes" \
+&& test "$has_setitimer" = "yes" \
+&& test "$has_gettimeofday" = "yes" \
+&& test "$has_wait" = "yes"; then
+  echo "Bytecode threads library supported."
+  otherlibraries="$otherlibraries threads"
+else
+  echo "Bytecode threads library not supported (missing system calls)"
+fi
+
+# Determine the location of X include files and libraries
+
+x11_include="not found"
+x11_link="not found"
+
+for dir in \
+    $x11_include_dir          \
+    ; \
+do
+  if test -f $dir/X11/X.h; then
+    x11_include=$dir
+    break
+  fi
+done
+
+if test "$x11_include" = "not found"; then
+  x11_try_lib_dir=''
+else
+  x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'`
+fi
+
+for dir in \
+    $x11_lib_dir          \
+    $x11_try_lib_dir      \
+    ; \
+do
+  if test -f $dir/libX11.a || \
+     test -f $dir/libX11.so || \
+     test -f $dir/libX11.dll.a || \
+     test -f $dir/libX11.sa; then
+    if test $dir = /usr/lib; then
+      x11_link="-lX11"
+    else
+      x11_link="-L$dir -lX11"
+      x11_libs="-L$dir"
+    fi
+    break
+  fi
+done
+
+
+if test "$x11_include" = "not found" || test "$x11_link" = "not found"
+then
+  echo "X11 not found, the \"graph\" library will not be supported."
+  x11_include=""
+else
+  echo "Location of X11 include files: $x11_include/X11"
+  echo "Options for linking with X11: $x11_link"
+  otherlibraries="$otherlibraries graph"
+  if test "$x11_include" = "/usr/include"; then
+    x11_include=""
+  else
+    x11_include="-I$x11_include"
+  fi
+  echo "X11_INCLUDES=$x11_include" >> Makefile
+  echo "X11_LINK=$x11_link" >> Makefile
+fi
+
+# See if we can compile the dbm library
+
+dbm_include="not found"
+dbm_link="not found"
+use_gdbm_ndbm=no
+
+for dir in ; do
+  if test -f $dir/ndbm.h; then
+    dbm_include=$dir
+    if sh ./hasgot dbm_open; then
+      dbm_link=""
+    elif sh ./hasgot -lndbm dbm_open; then
+      dbm_link="-lndbm"
+    elif sh ./hasgot -ldb1 dbm_open; then
+      dbm_link="-ldb1"
+    elif sh ./hasgot -lgdbm dbm_open; then
+      dbm_link="-lgdbm"
+    elif sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then
+      dbm_link="-lgdbm_compat -lgdbm" 
+    fi
+    break
+  fi
+  if test -f $dir/gdbm-ndbm.h; then
+    dbm_include=$dir
+    use_gdbm_ndbm=yes
+    if sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then
+      dbm_link="-lgdbm_compat -lgdbm"
+    fi
+    break   
+  fi
+done
+if test "$dbm_include" = "not found" || test "$dbm_link" = "not found"; then
+  echo "NDBM not found, the \"dbm\" library will not be supported."
+else
+  echo "NDBM found (in $dbm_include)"
+  if test "$dbm_include" = "/usr/include"; then
+    dbm_include=""
+  else
+    dbm_include="-I$dbm_include"
+  fi
+  echo "DBM_INCLUDES=$dbm_include" >> Makefile
+  echo "DBM_LINK=$dbm_link" >> Makefile
+  if test "$use_gdbm_ndbm" = "yes"; then
+    echo "#define DBM_USES_GDBM_NDBM" >> s.h
+  fi
+  otherlibraries="$otherlibraries dbm"
+fi
+
+# Look for tcl/tk
+
+echo "Configuring LablTk..."
+
+if test $tk_wanted = no; then
+  has_tk=false
+elif test $tk_x11 = no; then
+  has_tk=true
+elif test "$x11_include" = "not found" || test "$x11_link" = "not found"; then
+  echo "X11 not found."
+  has_tk=false
+else
+  tk_x11_include="$x11_include"
+  tk_x11_libs="$x11_libs -lX11"
+  has_tk=true
+fi
+
+if test $has_tk = true; then
+  tcl_version=''
+  tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  if test -z "$tcl_version" && test -z "$tk_defs"; then
+    tk_defs=-I/usr/local/include
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/usr/local/include/tcl8.2 -I/usr/local/include/tk8.2"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/usr/local/include/tcl8.3 -I/usr/local/include/tk8.3"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/usr/include/tcl8.2 -I/usr/include/tk8.2"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/usr/include/tcl8.3 -I/usr/include/tk8.3"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/usr/include/tcl8.4 -I/usr/include/tk8.4"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -z "$tcl_version"; then
+    tk_defs="-I/sw/include"
+    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
+  fi
+  if test -n "$tcl_version"; then
+    echo "tcl.h version $tcl_version found with \"$tk_defs\"."
+    case $tcl_version in
+    7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;;
+    7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;;
+    8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;;
+    8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;;
+    8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;;
+    8.3) tclmaj=8 tclmin=3 tkmaj=8 tkmin=3 ;;
+    8.4) tclmaj=8 tclmin=4 tkmaj=8 tkmin=4 ;;
+    *) echo "This version is not known."; has_tk=false ;;
+    esac
+  else
+    echo "tcl.h not found."
+    has_tk=false
+  fi
+fi
+
+if test $has_tk = true; then
+  if sh ./hasgot $tk_x11_include $tk_defs -i tk.h; then
+    echo "tk.h found."
+  else
+    echo "tk.h not found."
+    has_tk=false
+  fi
+fi
+
+tkauxlibs="$mathlib $dllib"
+tcllib=''
+tklib=''
+if test $has_tk = true; then
+  if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tcl_DoOneEvent
+  then tk_libs="$tk_libs $dllib"
+  elif sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
+  then
+    tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
+  elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
+  then
+    tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
+  elif test -z "$tk_libs" && tk_libs=-L/usr/local/lib && \
+    sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
+  then
+    tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
+  elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
+  then
+    tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
+# elif sh ./hasgot $tk_libs -ltcl $tkauxlibs Tcl_DoOneEvent; then
+#   tk_libs="$tk_libs -ltk -ltcl"
+  elif sh ./hasgot -L/sw/lib $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs \
+                   Tcl_DoOneEvent
+  then tk_libs="-L/sw/lib -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
+  else
+    echo "Tcl library not found."
+    has_tk=false
+  fi
+fi
+if test $has_tk = true; then
+  if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
+    echo "Tcl/Tk libraries found."
+  elif sh ./hasgot -L/sw/lib $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
+    tk_libs="-L/sw/lib $tk_libs"
+    echo "Tcl/Tk libraries found."
+  else
+    echo "Tcl library found."
+    echo "Tk library not found."
+    has_tk=false
+  fi
+fi
+
+if test $has_tk = true; then
+  if test $tk_x11 = yes; then
+    echo "TK_DEFS=$tk_defs "'$(X11_INCLUDES)' >> Makefile
+    echo "TK_LINK=$tk_libs "'$(X11_LINK)' >> Makefile
+  else
+    echo "TK_DEFS=$tk_defs" >> Makefile
+    echo "TK_LINK=$tk_libs" >> Makefile
+  fi
+  otherlibraries="$otherlibraries labltk"
+else
+  echo "Configuration failed, LablTk will not be built."
+fi
+
+# Camlp4
+
+(
+cd ../../camlp4/config
+EXE=$exe ./configure_batch -bindir "$bindir" -libdir "$libdir" -mandir "$mandir" -ocaml-top ../.. > /dev/null
+)
+
+# Final twiddling of compiler options to work around known bugs
+
+nativeccprofopts="$nativecccompopts"
+case "$buggycc" in
+  gcc.2.96)
+    bytecccompopts="$bytecccompopts -fomit-frame-pointer"
+    nativecccompopts="$nativecccompopts -fomit-frame-pointer";;
+esac
+
+# Finish generated files
+
+cclibs="$cclibs $mathlib"
+
+echo "BYTECC=$bytecc" >> Makefile
+echo "BYTECCCOMPOPTS=$bytecccompopts" >> Makefile
+echo "BYTECCLINKOPTS=$bytecclinkopts" >> Makefile
+echo "BYTECCLIBS=$cclibs $dllib $curseslibs $pthread_link" >> Makefile
+echo "BYTECCRPATH=$byteccrpath" >> Makefile
+echo "EXE=$exe" >> Makefile
+echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile
+echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile
+echo "MKSHAREDLIB=$mksharedlib" >> Makefile
+echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile
+echo "ARCH=$arch" >> Makefile
+echo "MODEL=$model" >> Makefile
+echo "SYSTEM=$system" >> Makefile
+echo "NATIVECC=$nativecc" >> Makefile
+echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile
+echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile
+echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile
+echo "NATIVECCRPATH=$nativeccrpath" >> Makefile
+echo "NATIVECCLIBS=$cclibs $dllib" >> Makefile
+echo "ASFLAGS=$asflags" >> Makefile
+echo "ASPP=$aspp" >> Makefile
+echo "ASPPFLAGS=$asppflags" >> Makefile
+echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile
+echo "PROFILING=$profiling" >> Makefile
+echo "BINUTILS_OBJCOPY=$binutils_objcopy" >> Makefile
+echo "BINUTILS_NM=$binutils_nm" >> Makefile
+echo "DYNLINKOPTS=$dllib" >> Makefile
+echo "OTHERLIBRARIES=$otherlibraries" >> Makefile
+echo "DEBUGGER=$debugger" >> Makefile
+echo "CC_PROFILE=$cc_profile" >> Makefile
+
+rm -f tst hasgot.c
+rm -f ../m.h ../s.h ../Makefile
+mv m.h s.h Makefile ..
+
+# Print a summary
+
+echo
+echo "** Configuration summary **"
+echo
+echo "Directories where Objective Caml will be installed:"
+echo "        binaries.................. $bindir"
+echo "        standard library.......... $libdir"
+echo "        manual pages.............. $mandir (with extension .$manext)"
+
+echo "Configuration for the bytecode compiler:"
+echo "        C compiler used........... $bytecc"
+echo "        options for compiling..... $bytecccompopts"
+echo "        options for linking....... $bytecclinkopts $cclibs $dllib $curseslibs $pthread_link"
+if $shared_libraries_supported; then
+echo "        shared libraries are supported"
+echo "        options for compiling..... $sharedcccompopts $bytecccompopts"
+echo "        command for building...... $mksharedlib lib.so $mksharedlibrpath/a/path objs"
+else
+echo "        shared libraries not supported"
+fi
+
+echo "Configuration for the native-code compiler:"
+if test "$arch" = "none"; then
+  echo "        (not supported on this platform)"
+else
+  if test "$model" = "default"; then
+    echo "        hardware architecture..... $arch"
+  else
+    echo "        hardware architecture..... $arch ($model)"
+  fi
+  if test "$system" = "unknown"; then : ; else
+  echo "        OS variant................ $system"
+  fi
+  echo "        C compiler used........... $nativecc"
+  echo "        options for compiling..... $nativecccompopts"
+  echo "        options for linking....... $nativecclinkopts $cclibs"
+  echo "        assembler ................ \$(AS) $asflags"
+  echo "        preprocessed assembler ... $aspp $asppflags"
+  if test "$profiling" = "prof"; then
+  echo "        profiling with gprof ..... supported"
+  else
+  echo "        profiling with gprof ..... not supported"
+  fi
+  if test -n "$binutils_objcopy" && test -n "$binutils_nm"; then
+  echo "        ocamlopt -pack ........... supported"
+  else
+  echo "        ocamlopt -pack ........... not supported (no binutils)"
+  fi
+fi
+
+if test "$debugger" = "ocamldebugger"; then
+  echo "Source-level replay debugger: supported"
+else
+  echo "Source-level replay debugger: not supported"
+fi
+
+echo "Additional libraries supported:"
+echo "        $otherlibraries"
+
+echo "Configuration for the \"num\" library:"
+echo "        target architecture ...... $bng_arch (asm level $bng_asm_level)"
+
+if test "$x11_include" != "not found" && test "$x11_lib" != "not found"; then
+echo "Configuration for the \"graph\" library:"
+echo "        options for compiling .... $x11_include"
+echo "        options for linking ...... $x11_link"
+fi
+
+if test $has_tk = true; then
+echo "Configuration for the \"labltk\" library:"
+echo "        use tcl/tk version ....... $tcl_version"
+echo "        options for compiling .... $tk_defs"
+echo "        options for linking ...... $tk_libs"
+else
+echo "The \"labltk\" library: not found"
+fi
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff b/nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff
new file mode 100644
index 000000000000..d7d9c863858f
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff
@@ -0,0 +1,20 @@
+diff --git a/configure b/configure
+index d45e88f..25d872b 100755
+--- a/configure
++++ b/configure
+@@ -322,7 +322,14 @@ case "$bytecc,$target" in
+     bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
+     mathlib="";;
+   *,*-*-darwin*)
+-    bytecccompopts="-fno-defer-pop $gcc_warnings"
++    # On recent version of OSX, gcc is a symlink to clang
++    if $bytecc --version | grep -q clang; then
++        # -fno-defer-pop is not supported by clang, and make recent
++        # versions of clang to fail
++        bytecccompopts="$gcc_warnings"
++    else
++        bytecccompopts="-fno-defer-pop $gcc_warnings"
++    fi
+     mathlib=""
+     mkexe="$mkexe -Wl,-no_compact_unwind"
+     # Tell gcc that we can use 32-bit code addresses for threaded code
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/generic.nix b/nixpkgs/pkgs/development/compilers/ocaml/generic.nix
new file mode 100644
index 000000000000..d1ee43c9152e
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/generic.nix
@@ -0,0 +1,100 @@
+{ minor_version, major_version, patch_version
+, url ? null
+, sha256, ...}@args:
+let
+  versionNoPatch = "${toString major_version}.${toString minor_version}";
+  version = "${versionNoPatch}.${toString patch_version}";
+  real_url = if url == null then
+    "http://caml.inria.fr/pub/distrib/ocaml-${versionNoPatch}/ocaml-${version}.tar.xz"
+  else url;
+  safeX11 = stdenv: !(stdenv.isAarch32 || stdenv.isMips);
+in
+
+{ stdenv, fetchurl, ncurses, buildEnv
+, libX11, xproto, useX11 ? safeX11 stdenv
+, flambdaSupport ? false
+}:
+
+assert useX11 -> !stdenv.isAarch32 && !stdenv.isMips;
+assert flambdaSupport -> stdenv.lib.versionAtLeast version "4.03";
+
+let
+   useNativeCompilers = !stdenv.isMips;
+   inherit (stdenv.lib) optional optionals optionalString;
+   name = "ocaml${optionalString flambdaSupport "+flambda"}-${version}";
+in
+
+let
+  x11env = buildEnv { name = "x11env"; paths = [libX11 xproto]; };
+  x11lib = x11env + "/lib";
+  x11inc = x11env + "/include";
+in
+
+stdenv.mkDerivation (args // rec {
+
+  inherit name;
+  inherit version;
+
+  src = fetchurl {
+    url = real_url;
+    inherit sha256;
+  };
+
+  prefixKey = "-prefix ";
+  configureFlags = optionals useX11 [ "-x11lib" x11lib
+                                      "-x11include" x11inc ]
+  ++ optional flambdaSupport "-flambda"
+  ;
+
+  buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
+  buildInputs = optional (!stdenv.lib.versionAtLeast version "4.07") ncurses
+    ++ optionals useX11 [ libX11 xproto ];
+  installTargets = "install" + optionalString useNativeCompilers " installopt";
+  preConfigure = optionalString (!stdenv.lib.versionAtLeast version "4.04") ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+  '';
+  postBuild = ''
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+  '';
+
+  passthru = {
+    nativeCompilers = useNativeCompilers;
+  };
+
+  meta = with stdenv.lib; {
+    homepage = http://caml.inria.fr/ocaml;
+    branch = versionNoPatch;
+    license = with licenses; [
+      qpl /* compiler */
+      lgpl2 /* library */
+    ];
+    description = "Most popular variant of the Caml language";
+
+    longDescription =
+      ''
+        OCaml is the most popular variant of the Caml language.  From a
+        language standpoint, it extends the core Caml language with a
+        fully-fledged object-oriented layer, as well as a powerful module
+        system, all connected by a sound, polymorphic type system featuring
+        type inference.
+
+        The OCaml system is an industrial-strength implementation of this
+        language, featuring a high-performance native-code compiler (ocamlopt)
+        for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc,
+        Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc)
+        and an interactive read-eval-print loop (ocaml) for quick development
+        and portability.  The OCaml distribution includes a comprehensive
+        standard library, a replay debugger (ocamldebug), lexer (ocamllex) and
+        parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4)
+        and a documentation generator (ocamldoc).
+      '';
+
+    platforms = with platforms; linux ++ darwin;
+    broken = stdenv.isAarch64 && !stdenv.lib.versionAtLeast version "4.06";
+  };
+
+})
+
+
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch b/nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch
new file mode 100644
index 000000000000..dc2bcb869766
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch
@@ -0,0 +1,9 @@
+diff -Nuar ocaml-3.11.1/ocamldoc/remove_DEBUG ocaml-3.11.1-nixpkgs/ocamldoc/remove_DEBUG
+--- ocaml-3.11.1/ocamldoc/remove_DEBUG	2004-04-15 18:18:52.000000000 +0200
++++ ocaml-3.11.1-nixpkgs/ocamldoc/remove_DEBUG	2011-01-01 17:37:07.000000000 +0100
+@@ -18,4 +18,4 @@
+ # respecting the cpp # line annotation conventions
+ 
+ echo "# 1 \"$1\""
+-LC_ALL=C sed -e '/DEBUG/s/.*//' "$1"
++grep -v 'DEBUG' "$1"
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix b/nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
new file mode 100644
index 000000000000..e9adbeff4904
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, xlibsWrapper, ncurses }:
+
+stdenv.mkDerivation (rec {
+
+  name = "metaocaml-${version}";
+  version = "3.09-alpha-30";
+
+  src = fetchurl {
+    url = "http://www.metaocaml.org/dist/old/MetaOCaml_309_alpha_030.tar.gz";
+    sha256 = "0migbn0zwfb7yb24dy7qfqi19sv3drqcv4369xi7xzpds2cs35fd";
+  };
+
+  prefixKey = "-prefix ";
+  configureFlags = ["-no-tk" "-x11lib" xlibsWrapper];
+  buildFlags = "world bootstrap world.opt";
+  buildInputs = [xlibsWrapper ncurses];
+  installTargets = "install installopt";
+  patchPhase = ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+  '';
+  postBuild = ''
+    mkdir -p $out/include
+    ln -sv $out/lib/ocaml/caml $out/include/caml
+  '';
+
+  meta = {
+    homepage = http://www.metaocaml.org/;
+    license = with stdenv.lib.licenses; [ qpl lgpl2 ];
+    description = "A compiled, type-safe, multi-stage programming language";
+    broken = true;
+  };
+
+})
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/mips64.patch b/nixpkgs/pkgs/development/compilers/ocaml/mips64.patch
new file mode 100644
index 000000000000..cdef9cafb932
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/mips64.patch
@@ -0,0 +1,240 @@
+http://caml.inria.fr/mantis/view.php?id=4849
+
+diff -bur ocaml-3.11.1/asmcomp/mips/arch.ml my_ocaml/asmcomp/mips/arch.ml
+--- asmcomp/mips/arch.ml	2002-11-29 16:03:36.000000000 +0100
++++ asmcomp/mips/arch.ml	2009-08-09 23:18:31.000000000 +0200
+@@ -35,7 +35,7 @@
+ 
+ let big_endian =
+   match Config.system with
+-    "ultrix" -> false
++    "ultrix" | "gnu" -> false
+   | "irix" -> true
+   | _ -> fatal_error "Arch_mips.big_endian"
+ 
+diff -bur ocaml-3.11.1/asmcomp/mips/emit.mlp my_ocaml/asmcomp/mips/emit.mlp
+--- asmcomp/mips/emit.mlp	2004-01-05 21:25:56.000000000 +0100
++++ asmcomp/mips/emit.mlp	2009-08-23 12:11:58.000000000 +0200
+@@ -58,7 +58,7 @@
+     !stack_offset +
+     4 * num_stack_slots.(0) + 8 * num_stack_slots.(1) +
+     (if !contains_calls then if !uses_gp then 8 else 4 else 0) in
+-  Misc.align size 16
++  Misc.align size 16	(* n32 require quadword alignment *)
+ 
+ let slot_offset loc cl =
+   match loc with
+@@ -252,7 +252,7 @@
+     | Lop(Icall_ind) ->
+         `	move	$25, {emit_reg i.arg.(0)}\n`;
+         liveregs i live_25;
+-        `	jal	{emit_reg i.arg.(0)}\n`;
++        `	jal	$25\n`; (* {emit_reg i.arg.(0)}\n; Equivalent but avoids "Warning: MIPS PIC call to register other than $25" on GNU as *)
+         `{record_frame i.live}\n`
+     | Lop(Icall_imm s) ->
+         liveregs i 0;
+@@ -269,7 +269,7 @@
+         liveregs i 0;
+         `	move	$25, {emit_reg i.arg.(0)}\n`;
+         liveregs i live_25;
+-        `	j	{emit_reg i.arg.(0)}\n`
++        `	j	$25\n`
+     | Lop(Itailcall_imm s) ->
+         if s = !function_name then begin
+           `	b	{emit_label !tailrec_entry_point}\n`
+@@ -277,11 +277,11 @@
+           let n = frame_size() in
+           if !contains_calls then
+             `	lw	$31, {emit_int(n - 4)}($sp)\n`;
++          `	la	$25, {emit_symbol s}\n`;	(* Rxd: put before gp restore *)
+           if !uses_gp then
+             `	lw	$gp, {emit_int(n - 8)}($sp)\n`;
+           if n > 0 then
+             `	addu	$sp, $sp, {emit_int n}\n`;
+-          `	la	$25, {emit_symbol s}\n`;
+           liveregs i live_25;
+           `	j	$25\n`
+         end
+@@ -305,8 +305,13 @@
+         begin match chunk with
+           Double_u ->
+             (* Destination is not 8-aligned, hence cannot use l.d *)
++            if big_endian then begin
+             `	ldl	$24, {emit_addressing addr i.arg 0}\n`;
+-            `	ldr	$24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`;
++              `	ldr	$24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`
++            end else begin
++              `	ldl	$24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`;
++              `	ldr	$24, {emit_addressing addr i.arg 0}\n`
++            end;
+             `	dmtc1	$24, {emit_reg dest}\n`
+         | Single ->
+             `	l.s	{emit_reg dest}, {emit_addressing addr i.arg 0}\n`;
+@@ -328,8 +333,13 @@
+           Double_u ->
+             (* Destination is not 8-aligned, hence cannot use l.d *)
+             `	dmfc1	$24, {emit_reg src}\n`;
++            if big_endian then begin
+             `	sdl	$24, {emit_addressing addr i.arg 1}\n`;
+             `	sdr	$24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`
++            end else begin
++              `	sdl	$24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`;
++              `	sdr	$24, {emit_addressing addr i.arg 1}\n`
++            end
+         | Single ->
+             `	cvt.s.d	$f31, {emit_reg src}\n`;
+             `	s.s	$f31, {emit_addressing addr i.arg 1}\n`
+@@ -552,6 +562,7 @@
+   (* There are really two groups of registers:
+       $sp and $30 always point to stack locations
+       $2 - $21 never point to stack locations. *)
++  if Config.system = "irix" then begin
+   `	.noalias $2,$sp;  .noalias $2,$30;  .noalias $3,$sp;  .noalias $3,$30\n`;
+   `	.noalias $4,$sp;  .noalias $4,$30;  .noalias $5,$sp;  .noalias $5,$30\n`;
+   `	.noalias $6,$sp;  .noalias $6,$30;  .noalias $7,$sp;  .noalias $7,$30\n`;
+@@ -561,7 +572,8 @@
+   `	.noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`;
+   `	.noalias $16,$sp; .noalias $16,$30; .noalias $17,$sp; .noalias $17,$30\n`;
+   `	.noalias $18,$sp; .noalias $18,$30; .noalias $19,$sp; .noalias $19,$30\n`;
+-  `	.noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`;
++    `	.noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`
++  end;
+   let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
+   `	.data\n`;
+   `	.globl	{emit_symbol lbl_begin}\n`;
+diff -bur ocaml-3.11.1/asmrun/mips.s my_ocaml/asmrun/mips.s
+--- asmrun/mips.s	2004-07-13 14:18:53.000000000 +0200
++++ asmrun/mips.s	2009-08-20 09:34:36.000000000 +0200
+@@ -187,7 +187,7 @@
+         sw      $30, caml_exception_pointer
+     /* Call C function */
+         move    $25, $24
+-        jal     $24
++        jal     $25	/* Rxd: $24 replaced by $25 to avoid this "Warning: MIPS PIC call to register other than $25" ? */
+     /* Reload return address, alloc ptr, alloc limit */
+         lw      $31, 0($16)     /* caml_last_return_address */
+         lw      $22, 0($17)     /* caml_young_ptr */
+@@ -254,7 +254,7 @@
+         sw      $0, caml_last_return_address
+     /* Call the Caml code */
+         move    $25, $24
+-        jal     $24
++        jal     $25	/* Rxd: 24 replaced by 25 */
+ $104:
+     /* Pop the trap frame, restoring caml_exception_pointer */
+         lw      $24, 0($sp)
+@@ -384,3 +384,8 @@
+         .word   $104            /* return address into callback */
+         .half   -1              /* negative frame size => use callback link */
+         .half   0               /* no roots here */
++
++#if defined(SYS_linux)
++    /* Mark stack as non-executable, PR#4564 */
++        .section .note.GNU-stack,"",%progbits
++#endif
+diff -bur ocaml-3.11.1/configure my_ocaml/configure
+--- configure	2009-05-20 17:33:09.000000000 +0200
++++ configure	2009-08-23 10:55:44.000000000 +0200
+@@ -40,7 +40,7 @@
+ verbose=no
+ withcurses=yes
+ withsharedlibs=yes
+-gcc_warnings="-Wall"
++gcc_warnings="-W -Wall"
+ partialld="ld -r"
+ 
+ # Try to turn internationalization off, can cause config.guess to malfunction!
+@@ -292,6 +292,9 @@
+     # (For those who want to force "cc -64")
+     # Turn off warning "unused library"
+     bytecclinkopts="-Wl,-woff,84";;
++  gcc*,mips64el-*)
++    bytecccompopts=""
++    bytecclinkopts="-fno-defer-pop $gcc_warnings -Wl,-O1 -Wl,--as-needed";;
+   *,alpha*-*-unicos*)
+     # For the Cray T3E
+     bytecccompopts="-DUMK";;
+@@ -468,6 +471,8 @@
+         echo "64-bit integers must be doubleword-aligned."
+         echo "#define ARCH_ALIGN_INT64" >> m.h
+       fi;;
++    mips64el-*)
++    	echo "#define ARCH_ALIGN_INT64" >> m.h;;
+     *)
+       sh ./runtest int64align.c
+       case $? in
+@@ -636,6 +641,7 @@
+                                 fi;;
+   i[3456]86-*-gnu*)             arch=i386; system=gnu;;
+   mips-*-irix6*)                arch=mips; system=irix;;
++  mips*-gnu*)                   arch=mips; system=gnu;;
+   hppa1.1-*-hpux*)              arch=hppa; system=hpux;;
+   hppa2.0*-*-hpux*)             arch=hppa; system=hpux;;
+   hppa*-*-linux*)               arch=hppa; system=linux;;
+@@ -672,7 +678,7 @@
+ if test -z "$ccoption"; then
+   case "$arch,$system,$cc" in
+     alpha,digital,gcc*) nativecc=cc;;
+-    mips,*,gcc*) nativecc=cc;;
++    mips,irix,gcc*) nativecc=cc;;
+     *) nativecc="$bytecc";;
+   esac
+ else
+@@ -687,6 +693,9 @@
+   alpha,cc*,digital,*) nativecccompopts=-std1;;
+   mips,cc*,irix,*)     nativecccompopts=-n32
+                        nativecclinkopts="-n32 -Wl,-woff,84";;
++  mips,gcc*,gnu,mips64el-*)
++                       nativecccompopts="$gcc_warnings -fPIC"
++                       nativecclinkopts="--as-needed";;
+   *,*,nextstep,*)      nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
+                        nativecclinkopts="-posix";;
+   *,*,rhapsody,*darwin[1-5].*)
+@@ -725,6 +734,8 @@
+                     aspp='gcc -c -Wa,-xexplicit';;
+   mips,*,irix)      as='as -n32 -O2 -nocpp -g0'
+                     aspp='as -n32 -O2';;
++  mips,*,gnu)       as='as -KPIC'
++                    aspp='gcc -c -fPIC';;	# got bus error without fPIC ?
+   power,*,elf)      as='as -u -m ppc'
+                     aspp='gcc -c';;
+   power,*,bsd)      as='as'
+@@ -756,6 +767,7 @@
+     case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
+   amd64,*,linux) profiling='prof';;
+   amd64,*,gnu) profiling='prof';;
++  mips,*,gnu) profiling='prof';;
+   *) profiling='noprof';;
+ esac
+ 
+diff -bur ocaml-3.11.1/asmcomp/mips/proc.ml my_ocaml/asmcomp/mips/proc.ml
+--- asmcomp/mips/proc.ml	2007-10-30 13:37:16.000000000 +0100
++++ asmcomp/mips/proc.ml	2010-03-18 08:08:06.000000000 +0100
+@@ -114,7 +114,7 @@
+           incr int
+         end else begin
+           loc.(i) <- stack_slot (make_stack !ofs) ty;
+-          ofs := !ofs + size_int
++          ofs := !ofs + 8
+         end
+     | Float ->
+         if !float <= last_float then begin
+@@ -143,7 +143,7 @@
+    or float regs $f12...$f19.  Each argument "consumes" both one slot
+    in the int register file and one slot in the float register file.
+    Extra arguments are passed on stack, in a 64-bits slot, right-justified
+-   (i.e. at +4 from natural address). *)   
++   (i.e. at +4 from natural address for big endians). *)   
+ 
+ let loc_external_arguments arg =
+   let loc = Array.create (Array.length arg) Reg.dummy in
+@@ -158,7 +158,7 @@
+     end else begin
+       begin match arg.(i).typ with
+         Float -> loc.(i) <- stack_slot (Outgoing !ofs) Float
+-      | ty    -> loc.(i) <- stack_slot (Outgoing (!ofs + 4)) ty
++      | ty    -> loc.(i) <- stack_slot (Outgoing (!ofs + (if big_endian then 4 else 0))) ty
+       end;
+       ofs := !ofs + 8
+     end
+ 
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch b/nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch
new file mode 100644
index 000000000000..d153fb67d419
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch
@@ -0,0 +1,45 @@
+Author: Vincent Laporte <Vincent.Laporte@gmail.com>
+Date:   Sun Feb 1 11:19:50 2015 +0100
+
+    ocamlbuild: use ocamlfind to discover camlp4 path
+    
+    and default to `+camlp4`
+
+diff --git a/ocamlbuild/ocaml_specific.ml b/ocamlbuild/ocaml_specific.ml
+index b902810..a73b7a5 100644
+--- a/ocamlbuild/ocaml_specific.ml
++++ b/ocamlbuild/ocaml_specific.ml
+@@ -698,15 +698,25 @@ ocaml_lib ~extern:true ~tag_name:"use_toplevel" "toplevellib";;
+ ocaml_lib ~extern:true ~dir:"+ocamldoc" "ocamldoc";;
+ ocaml_lib ~extern:true ~dir:"+ocamlbuild" ~tag_name:"use_ocamlbuild" "ocamlbuildlib";;
+ 
+-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4" "camlp4lib";;
+-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_old_camlp4" "camlp4";;
+-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4_full" "camlp4fulllib";;
++let camlp4dir =
++  Findlib.(
++    try
++      if sys_command "sh -c 'ocamlfind list >/dev/null' 2>/dev/null" != 0
++      then raise (Findlib_error Cannot_run_ocamlfind);
++      (query "camlp4").location
++    with Findlib_error _ ->
++      "+camlp4"
++  );;
++
++ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4" "camlp4lib";;
++ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_old_camlp4" "camlp4";;
++ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4_full" "camlp4fulllib";;
+ flag ["ocaml"; "compile"; "use_camlp4_full"]
+-     (S[A"-I"; A"+camlp4/Camlp4Parsers";
+-        A"-I"; A"+camlp4/Camlp4Printers";
+-        A"-I"; A"+camlp4/Camlp4Filters"]);;
+-flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A"+camlp4/Camlp4Bin.cmo");;
+-flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A"+camlp4/Camlp4Bin.cmx");;
++     (S[A"-I"; A(camlp4dir^"/Camlp4Parsers");
++        A"-I"; A(camlp4dir^"/Camlp4Printers");
++        A"-I"; A(camlp4dir^"/Camlp4Filters")]);;
++flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A(camlp4dir^"/Camlp4Bin.cmo"));;
++flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A(camlp4dir^"/Camlp4Bin.cmx"));;
+ 
+ flag ["ocaml"; "debug"; "compile"; "byte"] (A "-g");;
+ flag ["ocaml"; "debug"; "link"; "byte"; "program"] (A "-g");;