Added ocaml-findlib for cross-compiler environment.
[fedora-mingw.git] / ocaml / mingw32-ocaml.spec
1 %define __strip %{_mingw32_strip}
2 %define __objdump %{_mingw32_objdump}
3 %define _use_internal_dependency_generator 0
4 %define __find_requires %{_mingw32_findrequires}
5 %define __find_provides %{_mingw32_findprovides}
6
7 %define debug_package %{nil}
8
9 %define otherlibraries win32unix str num dynlink bigarray systhreads win32graph
10
11 Name:           mingw32-ocaml
12 Version:        3.11.0+beta1
13 Release:        7%{?dist}
14 Summary:        Objective Caml MinGW cross-compiler and programming environment
15
16 License:        QPL and (LGPLv2+ with exceptions)
17 Group:          Development/Libraries
18
19 URL:            http://caml.inria.fr/
20 Source0:        http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-%{version}.tar.bz2
21
22 # This is installed as config/Makefile when we cross-compile.
23 Source1000:     Makefile-fedora-mingw.in
24
25 # XXX We should apply any Fedora native patches here.
26
27 # For patch description, see the top of each patch file.
28 # Start numbering at 1000 since these are MinGW-specific patches.
29 Patch1000:      mingw32-ocaml-3.11.0+beta1-combined-Makefile.patch
30 Patch1001:      mingw32-ocaml-3.11.0+beta1-disable-cmxs.patch
31 Patch1002:      mingw32-ocaml-3.11.0+beta1-filename-win32-dirsep.patch
32 Patch1003:      mingw32-ocaml-3.11.0+beta1-i386-profiling.patch
33 Patch1004:      mingw32-ocaml-3.11.0+beta1-no-stdlib-dir.patch
34 Patch1005:      mingw32-ocaml-3.11.0+beta1-win32-fixes.patch
35 Patch1006:      mingw32-ocaml-3.11.0+beta1-win32unix-path.patch
36
37 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
38 # Is it noarch? (XXX)
39 BuildArch:      noarch
40
41 BuildRequires:  mingw32-filesystem >= 30
42 BuildRequires:  mingw32-gcc
43 BuildRequires:  mingw32-binutils
44 BuildRequires:  mingw32-flexdll
45
46 # While we still ship bytecode, this requires a /usr/bin/ocamlrun from
47 # the _identical_ native package.  We don't have that at the moment,
48 # which is why this is commented out.
49 #Requires:       ocaml-runtime = %{version}
50
51 # The built program will try to run the cross-compiler and flexdll, so
52 # these must be runtime requires.
53 Requires:       mingw32-gcc
54 Requires:       mingw32-binutils
55 Requires:       mingw32-flexdll
56
57 # i686-pc-mingw32-ocamlmklib tries to run ocamlopt which is probably a
58 # bug, but requires this (XXX).
59 Requires:       ocaml
60
61
62 %description
63 Objective Caml is a high-level, strongly-typed, functional and
64 object-oriented programming language from the ML family of languages.
65
66 This package is an OCaml cross-compiler which runs natively on Fedora
67 and produces Windows native executables.
68
69
70 %prep
71 %setup -q -n ocaml-%{version}
72
73 %patch1000 -p1
74 %patch1001 -p1
75 %patch1002 -p1
76 %patch1003 -p1
77 %patch1004 -p1
78 %patch1005 -p1
79 %patch1006 -p0
80
81
82 %build
83 # Don't run out of memory.
84 ulimit -s unlimited
85
86 # Build native ocamlrun and ocamlc which contain the filename-win32-dirsep
87 # patch.
88 ./configure \
89   -no-tk \
90   -bindir %{_bindir} \
91   -libdir %{_libdir}/ocaml \
92   -mandir %{_mandir}/man1
93 make world
94
95 # Now move the working ocamlrun, ocamlc into the boot/ directory,
96 # overwriting the binary versions which ship with the compiler with
97 # ones that contain the above filename-win32-dirsep patch.
98 make coreboot
99
100 # Now replace the compiler configuration (config/{s.h,m.h,Makefile})
101 # with ones as they would be on a 32 bit Windows system.
102 pushd config
103
104 # config/m.h can just be copied from config/m-nt.h which ships.
105 rm -f m.h
106 cp m-nt.h m.h
107
108 # config/s.h can just be copied from config/s-nt.h which ships.
109 rm -f s.h
110 cp s-nt.h s.h
111
112 # config/Makefile is a custom one which we supply.
113 rm -f Makefile
114 sed \
115   -e 's,@prefix@,%{_prefix},g' \
116   -e 's,@bindir@,%{_bindir},g' \
117   -e 's,@libdir@,%{_libdir},g' \
118   -e 's,@target@,%{_mingw32_target},g' \
119   -e 's,@otherlibraries@,%{otherlibraries},g' \
120   < %{SOURCE1000} > Makefile
121
122 popd
123
124 # We're going to build in otherlibs/win32unix and otherlibs/win32graph
125 # directories, but since they would normally only be built under
126 # Windows, they only have the Makefile.nt files.  Just symlink
127 # Makefile -> Makefile.nt for these cases.
128 for d in otherlibs/win32unix otherlibs/win32graph; do
129   ln -s Makefile.nt $d/Makefile
130 done
131
132 # Now clean the temporary files from the previous build.  This
133 # will also cause asmcomp/arch.ml (etc) to be linked to the 32 bit
134 # i386 versions, essentially causing ocamlopt to use the Win/i386 code
135 # generator.
136 make partialclean
137
138 # Just rebuild some small bits that we need for the following
139 # 'make opt' to work.  Note that 'make all' fails here.
140 make -C byterun libcamlrun.a
141 make ocaml ocamlc
142 make -C stdlib
143 make -C tools ocamlmklib
144
145 # Build ocamlopt
146 make opt
147
148
149 %install
150 rm -rf $RPM_BUILD_ROOT
151
152 mkdir -p $RPM_BUILD_ROOT%{_bindir}
153 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
154 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/threads
155 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/stublibs
156
157 # This is the equivalent of 'make install installopt', but
158 # we only want to install the parts which are really necessary
159 # for the cross-compiler.  eg. We don't need any of the native
160 # tools like ocamllex or ocamldoc.
161 %define makevars BINDIR=$RPM_BUILD_ROOT%{_bindir} LIBDIR=$RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
162 make %{makevars} -C byterun install
163 make %{makevars} -C stdlib install
164 for i in %{otherlibraries}; do
165   make %{makevars} -C otherlibs/$i install
166 done
167 make %{makevars} -C tools install
168 make %{makevars} installopt
169
170 cp config/Makefile \
171    $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/Makefile.config
172
173 # For bytecode binaries, change the bang-path to point to the locally
174 # installed ocamlrun.
175 pushd $RPM_BUILD_ROOT%{_bindir}
176 for f in ocamlcp ocamldep ocamlmklib ocamlopt ocamlprof; do
177   mv $f $f.old
178   echo '#!%{_bindir}/%{_mingw32_target}-ocamlrun' > $f
179   tail -n +2 $f.old >> $f
180   chmod +x $f
181   rm $f.old
182 done
183 popd
184
185 # Rename all the binaries to target-binary.
186 pushd $RPM_BUILD_ROOT%{_bindir}
187 for f in ocamlcp ocamldep ocamlmklib ocamlmktop ocamlopt ocamlprof ocamlrun; do
188   mv $f %{_mingw32_target}-$f
189 done
190 popd
191
192
193 %clean
194 rm -rf $RPM_BUILD_ROOT
195
196
197 %files
198 %defattr(-,root,root)
199 %{_bindir}/%{_mingw32_target}-ocamlcp
200 %{_bindir}/%{_mingw32_target}-ocamldep
201 %{_bindir}/%{_mingw32_target}-ocamlmklib
202 %{_bindir}/%{_mingw32_target}-ocamlmktop
203 %{_bindir}/%{_mingw32_target}-ocamlprof
204 %{_bindir}/%{_mingw32_target}-ocamlopt
205 %{_bindir}/%{_mingw32_target}-ocamlrun
206 %{_libdir}/%{_mingw32_target}-ocaml/
207
208
209 %changelog
210 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-7
211 - Further requirements.
212
213 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-6
214 - Install tools, particularly ocamlmklib.
215
216 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-5
217 - +Requires mingw32-flexdll and the cross-compiler.
218
219 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-4
220 - Initial RPM release.