From 173d3d0c944e7ff3b991880b2ab6b9998693d39d Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Tue, 7 Aug 2012 15:36:07 -0500
Subject: ocaml 3.12.1

---
 abs/extra/ocaml/PKGBUILD                      | 54 ++++++++++++++++------
 abs/extra/ocaml/fix-ocaml-binutils-2.21.patch | 66 +++++++++++++++++++++++++++
 abs/extra/ocaml/ocaml-3.12.1-3.src.tar.gz     |  1 +
 3 files changed, 108 insertions(+), 13 deletions(-)
 create mode 100644 abs/extra/ocaml/fix-ocaml-binutils-2.21.patch
 create mode 120000 abs/extra/ocaml/ocaml-3.12.1-3.src.tar.gz

diff --git a/abs/extra/ocaml/PKGBUILD b/abs/extra/ocaml/PKGBUILD
index 7b0cd86..7ba798b 100644
--- a/abs/extra/ocaml/PKGBUILD
+++ b/abs/extra/ocaml/PKGBUILD
@@ -1,9 +1,10 @@
-# $Id: PKGBUILD 88099 2010-08-19 13:05:24Z tpowa $
+# $Id: PKGBUILD 143814 2011-11-29 13:33:35Z stephane $
 # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
 
-pkgname=ocaml	
-pkgver=3.12.0
-pkgrel=1
+pkgbase='ocaml'
+pkgname=('ocaml' 'ocaml-compiler-libs')
+pkgver=3.12.1
+pkgrel=3
 pkgdesc="A functional language with OO extensions"
 arch=('i686' 'x86_64')
 license=('LGPL2' 'custom: QPL-1.0')
@@ -11,19 +12,46 @@ url="http://caml.inria.fr/"
 depends=('gdbm')
 makedepends=('tk' 'ncurses>=5.6-7' 'libx11')
 optdepends=('ncurses: advanced ncurses features' 'tk: advanced tk features')
-source=(http://caml.inria.fr/distrib/ocaml-3.12/$pkgname-$pkgver.tar.gz)
+source=(http://caml.inria.fr/distrib/ocaml-3.12/${pkgname}-${pkgver}.tar.gz)
+md5sums=('814a047085f0f901ab7d8e3a4b7a9e65')
 options=('!makeflags' '!emptydirs')
 
 build() {
-  cd $srcdir/$pkgname-$pkgver
+  cd "${srcdir}/${pkgname}-${pkgver}"
   ./configure -prefix /usr 
-  make world.opt || return 1
-  make PREFIX=$pkgdir/usr MANDIR=$pkgdir/usr/share/man install || return 1
+  make world.opt
+}
+
+package_ocaml() {
+  cd "${srcdir}/${pkgbase}-${pkgver}"
+  make PREFIX="${pkgdir}/usr" MANDIR="${pkgdir}/usr/share/man" install
    
-# Save >10MB with this one, makepkg only strips debug symbols.
- find ${startdir}/pkg/usr/lib -type f -name '*.so.*' -exec strip --strip-unneeded {} \;
+  # Save >10MB with this one, makepkg only strips debug symbols.
+  #find "${pkgdir}/usr/lib" -type f -name '*.so.*' -exec strip --strip-unneeded {} \;
+
+  # install license
+  install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+  install -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
+
+package_ocaml-compiler-libs() {
+pkgdesc="Several modules used internally by the OCaml compiler"
+license=('custom: QPL-1.0')
+depends=('ocaml')
+optdepends=()
+
+  cd "${srcdir}/${pkgbase}-${pkgver}"
+
+  # Install compiler libraries
+  local compiler_libs="${pkgdir}/usr/lib/ocaml/compiler-libs"
+  mkdir -p "$compiler_libs"/{parsing,typing,utils}
+  cp parsing/*.{cmi,cmo,cmx,ml,mli,mll,o} "$compiler_libs"/parsing
+  cp typing/*.{cmi,cmo,cmx,ml,mli,o} "$compiler_libs"/typing
+  cp utils/*.{cmi,cmo,cmx,ml,mli,o} "$compiler_libs"/utils
+  # duplicated by installation
+  rm -f "$compiler_libs"/typing/outcometree.{cmi,mli}
 
-# install license
-install -D -m 644 $startdir/src/$pkgname-$pkgver/LICENSE $startdir/pkg/usr/share/licenses/ocaml/LICENSE
+  # install license
+  install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+  install -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/"
 }
-md5sums=('3ba7cc65123c3579f14e7c726d3ee782')
diff --git a/abs/extra/ocaml/fix-ocaml-binutils-2.21.patch b/abs/extra/ocaml/fix-ocaml-binutils-2.21.patch
new file mode 100644
index 0000000..fa7664c
--- /dev/null
+++ b/abs/extra/ocaml/fix-ocaml-binutils-2.21.patch
@@ -0,0 +1,66 @@
+From: Stephane Glondu <steph@glondu.net>
+Date: Tue, 8 Mar 2011 21:17:40 +0100
+Subject: [PATCH] Fix ocamlopt w.r.t. binutils 2.21
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Bug: http://caml.inria.fr/mantis/view.php?id=5237
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=617404
+Authors: Eric Cooper, spiralvoice
+Reviewed-by: Stéphane Glondu <steph@glondu.net>
+---
+ asmcomp/amd64/emit.mlp |   13 +++++++------
+ asmcomp/i386/emit.mlp  |    6 +++---
+ 2 files changed, 10 insertions(+), 9 deletions(-)
+
+diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp
+index 4a3f844..525c6e6 100644
+--- a/asmcomp/amd64/emit.mlp
++++ b/asmcomp/amd64/emit.mlp
+@@ -679,17 +679,18 @@ let fundecl fundecl =
+   emit_all true fundecl.fun_body;
+   List.iter emit_call_gc !call_gc_sites;
+   emit_call_bound_errors ();
++  begin match Config.system with
++    "linux" | "gnu" ->
++      `	.type	{emit_symbol fundecl.fun_name},@function\n`;
++      `	.size	{emit_symbol fundecl.fun_name},.-{emit_symbol fundecl.fun_name}\n`
++    | _ -> ()
++  end;
+   if !float_constants <> [] then begin
+     if macosx
+     then `	.literal8\n`
+     else `	.section	.rodata.cst8,\"a\",@progbits\n`;
+     List.iter emit_float_constant !float_constants
+-  end;
+-  match Config.system with
+-    "linux" | "gnu" ->
+-      `	.type	{emit_symbol fundecl.fun_name},@function\n`;
+-      `	.size	{emit_symbol fundecl.fun_name},.-{emit_symbol fundecl.fun_name}\n`
+-  | _ -> ()
++  end
+ 
+ (* Emission of data *)
+ 
+diff --git a/asmcomp/i386/emit.mlp b/asmcomp/i386/emit.mlp
+index 2992f29..0b1252c 100644
+--- a/asmcomp/i386/emit.mlp
++++ b/asmcomp/i386/emit.mlp
+@@ -905,12 +905,12 @@ let fundecl fundecl =
+   emit_all true fundecl.fun_body;
+   List.iter emit_call_gc !call_gc_sites;
+   emit_call_bound_errors ();
+-  List.iter emit_float_constant !float_constants;
+-  match Config.system with
++  begin match Config.system with
+     "linux_elf" | "bsd_elf" | "gnu" ->
+       `	.type	{emit_symbol fundecl.fun_name},@function\n`;
+       `	.size	{emit_symbol fundecl.fun_name},.-{emit_symbol fundecl.fun_name}\n`
+-  | _ -> ()
++  | _ -> () end;
++  List.iter emit_float_constant !float_constants
+ 
+ 
+ (* Emission of data *)
+-- 
diff --git a/abs/extra/ocaml/ocaml-3.12.1-3.src.tar.gz b/abs/extra/ocaml/ocaml-3.12.1-3.src.tar.gz
new file mode 120000
index 0000000..140a1a6
--- /dev/null
+++ b/abs/extra/ocaml/ocaml-3.12.1-3.src.tar.gz
@@ -0,0 +1 @@
+/data/pkg_repo/src_packages/ocaml-3.12.1-3.src.tar.gz
\ No newline at end of file
-- 
cgit v0.12

