1 # Maintainer: Baptiste Jonglez <zerstorer@free.fr>
2 # Original patches by Richard W.M. Jones (Fedora) for OCaml 3.11, see http://git.annexia.org/?p=fedora-mingw.git;a=tree;f=ocaml;hb=HEAD
3 # Additional work by Romain Beauxis (Debian) for OCaml 3.12, see http://packages.debian.org/experimental/mingw32-ocaml
4 # This have been tested on small projects (using 'graphics' and 'unix' libs).
5 # Please report any issue (e.g. using camlp4 or any other lib)
7 # TODO: fix deps that are not really needed
8 # TODO: get to know ocamlfind, if needed
9 # TODO: provide a link to a blog post explaining how to use it
14 pkgdesc="MinGW cross-compiler for Objective Caml (ocaml) that allows building windows (win32) binaries"
15 arch=('i686' 'x86_64')
16 url="http://caml.inria.fr/"
17 license=('LGPL2' 'custom: QPL-1.0')
19 makedepends=('mingw32-gcc' 'mingw32-binutils' 'mingw32-flexdll' 'libx11')
20 # we need to be able to compile in 32-bit, make sure you have enabled multilib repo
21 [ "$CARCH" = "x86_64" ] && makedepends=('mingw32-gcc' 'mingw32-binutils' 'mingw32-flexdll' 'libx11' 'lib32-libx11' 'gcc-multilib')
22 # according to the fedora package, we need mingw32-gcc to use the ocaml cross-compiler (not sure why though)
23 depends=('ocaml' 'mingw32-gcc' 'mingw32-binutils' 'mingw32-flexdll') #'ocaml-findlib')
24 source=( "http://caml.inria.fr/pub/distrib/ocaml-3.12/${_pkgname}-${pkgver}.tar.bz2"
26 "mingw32-ocaml-disable-cmxs.patch"
27 "mingw32-ocaml-i386-profiling.patch"
28 "mingw32-ocaml-win32unix-path.patch"
29 "mingw32-ocaml-combined-Makefile.patch"
30 "mingw32-ocaml-filename-win32-dirsep.patch"
31 "mingw32-ocaml-no-stdlib-dir.patch"
32 "mingw32-ocaml-fix-opt-link-opts.patch.in"
33 "mingw32-ocaml-fix-ocamlrun-path.patch"
34 "mingw32-ocaml-run-ranlib-on-threads.patch"
35 "mingw32-ocaml-force-os-type.patch"
36 "mingw32-ocaml-win32-compat.patch"
37 "mingw32-ocaml-hardcode-mingw32-include.patch.in" )
38 md5sums=('bd92c8970767f412bc1e9a6c625b5ccf'
39 'fdae6e8282d065b0e80edb38f1506354'
40 '001ea1e8b81bb4a4420bfbcf046653c3'
41 '5c9f0850503985bbc6ae913fd2c6a8ad'
42 '244527f3c3dd5a830a6ea280e56282b6'
43 '26c233c3828081cb156b1fad79f9e274'
44 '9cea24b470b3162862869705392b5e99'
45 'dfbdd7218ed132624bfb3130a7a8f001'
46 '157be2ee3a45ba6674c8af49650a05c9'
47 '5eb6a569bce7b0b466b03c6d73fc7624'
48 '350640941c1780811d79462f2fb12fa7'
49 'e7f94edbd44aa7f433862a2a78574bb0'
50 'c7a672fa1811eba87b2c72757757e819'
51 '232fc847aa8122895c5d14e2632ba4b9')
53 mingw32prefix="i486-mingw32"
54 otherlibraries="win32unix str num dynlink bigarray systhreads win32graph"
55 libdir="/usr/lib/${mingw32prefix}-ocaml"
56 mingw32libdir="/usr/${mingw32prefix}/lib"
59 patches=("mingw32-ocaml-combined-Makefile.patch"
60 "mingw32-ocaml-disable-cmxs.patch"
61 "mingw32-ocaml-filename-win32-dirsep.patch"
62 "mingw32-ocaml-i386-profiling.patch"
63 "mingw32-ocaml-no-stdlib-dir.patch"
64 "mingw32-ocaml-win32-compat.patch"
65 "mingw32-ocaml-win32unix-path.patch"
66 "mingw32-ocaml-run-ranlib-on-threads.patch"
67 "mingw32-ocaml-force-os-type.patch"
68 "mingw32-ocaml-fix-ocamlrun-path.patch")
70 patches_in=("mingw32-ocaml-hardcode-mingw32-include.patch"
71 "mingw32-ocaml-fix-opt-link-opts.patch")
75 for i in ${patches[@]}
77 echo "[*] Applying patch ${i}..."
81 for i in ${patches_in[@]}
83 # We replace everything as needed
85 -e "s,@mingw32libdir@,${mingw32libdir},g" \
87 echo "[*] Applying parametrized patch ${i}..."
91 cd "$srcdir/$_pkgname-$pkgver"
94 # Build native ocamlrun and ocamlc which contain the
95 # filename-win32-dirsep patch.
97 # Note that we must build a 32 bit compiler, even on 64 bit build
98 # architectures, because this compiler will try to do strength
99 # reduction optimizations using its internal int type, and that must
100 # match Windows' int type. (That's what -cc and -host are for).
105 -mandir /usr/share/man/man1 \
107 -host i386-pc-linux \
113 # Now move the working ocamlrun, ocamlc into the boot/ directory,
114 # overwriting the binary versions which ship with the compiler with
115 # ones that contain the above filename-win32-dirsep patch.
118 # Now replace the compiler configuration (config/{s.h,m.h,Makefile})
119 # with ones as they would be on a 32 bit Windows system.
122 # config/m.h can just be copied from config/m-nt.h which ships.
126 # config/s.h can just be copied from config/s-nt.h which ships.
130 # config/Makefile is a custom one which we supply.
133 -e "s,@prefix@,/usr,g" \
134 -e "s,@bindir@,/usr/bin,g" \
135 -e "s,@libdir@,$libdir,g" \
136 -e "s,@target@,${mingw32prefix},g" \
137 -e "s,@otherlibraries@,${otherlibraries},g" \
138 -e "s,@flexdir@,/usr/lib/flexdll,g" \
139 < "$srcdir/Makefile-mingw32.in" > Makefile
143 # We're going to build in otherlibs/win32unix and otherlibs/win32graph
144 # directories, but since they would normally only be built under
145 # Windows, they only have the Makefile.nt files. Just symlink
146 # Makefile -> Makefile.nt for these cases.
147 for i in win32unix win32graph bigarray systhreads
149 ln -sf Makefile.nt otherlibs/$i/Makefile
152 # Now clean the temporary files from the previous build. This
153 # will also cause asmcomp/arch.ml (etc) to be linked to the 32 bit
154 # i386 versions, essentially causing ocamlopt to use the Win/i386 code
158 # We need to remove any .o object to ensure their future
162 # Just rebuild some small bits that we need for the following
163 # 'make opt' to work. Note that 'make all' fails here.
164 make -C byterun libcamlrun.a
167 make -C tools ocamlmklib
172 # Now build otherlibs for ocamlopt
173 for i in $otherlibraries
175 make -C otherlibs/$i clean
176 make -C otherlibs/$i all
177 make -C otherlibs/$i allopt
186 cd "$srcdir/$_pkgname-$pkgver"
189 mkdir -p "$pkgdir/usr/bin"
190 mkdir -p "$pkgdir/$libdir"
191 mkdir -p "$pkgdir/$libdir/threads"
192 mkdir -p "$pkgdir/$libdir/stublibs"
194 # This is the equivalent of 'make install installopt', but
195 # we only want to install the parts which are really necessary
196 # for the cross-compiler. eg. We don't need any of the native
197 # tools like ocamllex or ocamldoc.
198 makearg="BINDIR=$pkgdir/usr/bin LIBDIR=$pkgdir/$libdir"
199 make $makearg -C byterun install
200 make $makearg -C stdlib install
201 for i in $otherlibraries
203 make $makearg -C otherlibs/$i install
205 make $makearg -C tools install
206 make $makearg installopt
208 install -m 0755 ocamlc "$pkgdir/usr/bin"
211 "$pkgdir/$libdir/Makefile.config"
213 for i in mkcamlp4 camlp4o camlp4r camlp4
215 install -m 0755 "_build/camlp4/$i.native" "$pkgdir/usr/bin/$i"
219 toplevel/topstart.cmo \
220 typing/outcometree.cmi typing/outcometree.mli \
221 toplevel/toploop.cmi toplevel/toploop.mli \
222 toplevel/topdirs.cmi toplevel/topdirs.mli \
223 toplevel/topmain.cmi toplevel/topmain.mli \
226 # Rename all the binaries to target-binary.
227 pushd $pkgdir/usr/bin
228 for f in ocamlc ocamlcp ocamldep ocamlmklib ocamlmktop ocamlopt ocamlprof ocamlobjinfo mkcamlp4 camlp4o camlp4r camlp4
230 mv $f ${mingw32prefix}-$f
234 # Don't install ocamlrun, use native one.
235 rm $pkgdir/usr/bin/ocamlrun
238 # vim:set ts=2 sw=2 et: