Bump all spec releases for mass rebuild to mingw32-gcc 4.4
[fedora-mingw.git] / ocaml / mingw32-ocaml.spec
1 # Built-in strip corrupts binaries, so use the mingw32 strip instead:
2 %define __strip %{_mingw32_strip}
3 %define __objdump %{_mingw32_objdump}
4
5 %define debug_package %{nil}
6
7 %define otherlibraries win32unix str num dynlink bigarray systhreads win32graph
8
9 Name:           mingw32-ocaml
10 Version:        3.11.0
11 Release:        0.16.beta1%{?dist}
12 Summary:        Objective Caml MinGW cross-compiler and programming environment
13
14 License:        QPL and (LGPLv2+ with exceptions)
15 Group:          Development/Libraries
16
17 URL:            http://caml.inria.fr/
18 Source0:        http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-%{version}+beta1.tar.bz2
19
20 # This is installed as config/Makefile when we cross-compile.
21 Source1000:     Makefile-fedora-mingw.in
22 Source1001:     README.Fedora
23
24 # XXX We should apply any Fedora native patches here.
25
26 # For patch description, see the top of each patch file.
27 # Start numbering at 1000 since these are MinGW-specific patches.
28 Patch1000:      mingw32-ocaml-3.11.0+beta1-combined-Makefile.patch
29 Patch1001:      mingw32-ocaml-3.11.0+beta1-disable-cmxs.patch
30 Patch1002:      mingw32-ocaml-3.11.0+beta1-filename-win32-dirsep.patch
31 Patch1003:      mingw32-ocaml-3.11.0+beta1-i386-profiling.patch
32 Patch1004:      mingw32-ocaml-3.11.0+beta1-no-stdlib-dir.patch
33 Patch1005:      mingw32-ocaml-3.11.0+beta1-win32-fixes.patch
34 Patch1006:      mingw32-ocaml-3.11.0+beta1-win32unix-path.patch
35
36 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
37 # Is it noarch? (XXX)
38 # Answer: yes and no.  In theory it should be, but because we install
39 # Windows binaries in %{_libdir}, the path is different if built on
40 # 32 and 64 bit platforms.  We should probably install the binaries
41 # in /usr/share.
42 BuildArch:      noarch
43
44 BuildRequires:  mingw32-filesystem >= 30
45 BuildRequires:  mingw32-gcc
46 BuildRequires:  mingw32-binutils
47 BuildRequires:  mingw32-flexdll
48
49 # These are required so we can use gcc -m32 and link to 32 bit X11:
50 BuildRequires:  /lib/libgcc_s.so.1
51 BuildRequires:  /usr/lib/crt1.o
52 BuildRequires:  /usr/lib/libX11.so
53
54 # We need the native Fedora OCaml package (of the precise matching
55 # version) for several reasons:
56 # (a) We need /usr/bin/ocamlrun (the bytecode interpreter) in order
57 # to run our bytecodes such as i686-pc-mingw32-ocamlopt.  Eventually
58 # shipping native versions of the cross-compiler binaries should
59 # resolve this.
60 # (b) We need camlp4 preprocessor, and because of the way this works
61 # it has to be the camlp4 from the identical version.
62 Requires:       ocaml-runtime = %{version}
63 Requires:       ocaml-camlp4-devel = %{version}
64
65 # The built program will try to run the cross-compiler and flexdll, so
66 # these must be runtime requires.
67 Requires:       mingw32-gcc
68 Requires:       mingw32-binutils
69 Requires:       mingw32-flexdll
70
71 # i686-pc-mingw32-ocamlmklib tries to run ocamlopt which is probably a
72 # bug, but requires this (XXX).
73 Requires:       ocaml
74
75
76 %description
77 Objective Caml is a high-level, strongly-typed, functional and
78 object-oriented programming language from the ML family of languages.
79
80 This package is an OCaml cross-compiler which runs natively on Fedora
81 and produces Windows native executables.
82
83
84 %prep
85 %setup -q -n ocaml-%{version}+beta1
86
87 %patch1000 -p1
88 %patch1001 -p1
89 %patch1002 -p1
90 %patch1003 -p1
91 %patch1004 -p1
92 %patch1005 -p1
93 %patch1006 -p0
94
95
96 %build
97 # Don't run out of memory.
98 ulimit -s unlimited
99
100 # Build native ocamlrun and ocamlc which contain the
101 # filename-win32-dirsep patch.
102 #
103 # Note that we must build a 32 bit compiler, even on 64 bit build
104 # architectures, because this compiler will try to do strength
105 # reduction optimizations using its internal int type, and that must
106 # match Windows' int type.  (That's what -cc and -host are for).
107 ./configure \
108   -no-tk \
109   -bindir %{_bindir} \
110   -libdir %{_libdir}/ocaml \
111   -mandir %{_mandir}/man1 \
112   -cc "gcc -m32" -host i386-pc-linux -x11lib /usr/lib -verbose
113 make world
114
115 # Now move the working ocamlrun, ocamlc into the boot/ directory,
116 # overwriting the binary versions which ship with the compiler with
117 # ones that contain the above filename-win32-dirsep patch.
118 make coreboot
119
120 # Now replace the compiler configuration (config/{s.h,m.h,Makefile})
121 # with ones as they would be on a 32 bit Windows system.
122 pushd config
123
124 # config/m.h can just be copied from config/m-nt.h which ships.
125 rm -f m.h
126 cp m-nt.h m.h
127
128 # config/s.h can just be copied from config/s-nt.h which ships.
129 rm -f s.h
130 cp s-nt.h s.h
131
132 # config/Makefile is a custom one which we supply.
133 rm -f Makefile
134 sed \
135   -e 's,@prefix@,%{_prefix},g' \
136   -e 's,@bindir@,%{_bindir},g' \
137   -e 's,@libdir@,%{_libdir},g' \
138   -e 's,@target@,%{_mingw32_target},g' \
139   -e 's,@otherlibraries@,%{otherlibraries},g' \
140   < %{SOURCE1000} > Makefile
141
142 popd
143
144 # We're going to build in otherlibs/win32unix and otherlibs/win32graph
145 # directories, but since they would normally only be built under
146 # Windows, they only have the Makefile.nt files.  Just symlink
147 # Makefile -> Makefile.nt for these cases.
148 for d in otherlibs/win32unix otherlibs/win32graph; do
149   ln -s Makefile.nt $d/Makefile
150 done
151
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
155 # generator.
156 make partialclean
157
158 # Just rebuild some small bits that we need for the following
159 # 'make opt' to work.  Note that 'make all' fails here.
160 make -C byterun libcamlrun.a
161 make ocaml ocamlc
162 make -C stdlib
163 make -C tools ocamlmklib
164
165 # Build ocamlopt
166 make opt
167
168 cp %{SOURCE1001} .
169
170
171 %install
172 rm -rf $RPM_BUILD_ROOT
173
174 mkdir -p $RPM_BUILD_ROOT%{_bindir}
175 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
176 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/threads
177 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/stublibs
178
179 # This is the equivalent of 'make install installopt', but
180 # we only want to install the parts which are really necessary
181 # for the cross-compiler.  eg. We don't need any of the native
182 # tools like ocamllex or ocamldoc.
183 %define makevars BINDIR=$RPM_BUILD_ROOT%{_bindir} LIBDIR=$RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
184 make %{makevars} -C byterun install
185 make %{makevars} -C stdlib install
186 for i in %{otherlibraries}; do
187   make %{makevars} -C otherlibs/$i install
188 done
189 make %{makevars} -C tools install
190 make %{makevars} installopt
191
192 install -m 0755 ocamlc $RPM_BUILD_ROOT%{_bindir}
193
194 cp config/Makefile \
195    $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/Makefile.config
196
197 # Rename all the binaries to target-binary.
198 pushd $RPM_BUILD_ROOT%{_bindir}
199 for f in ocamlc ocamlcp ocamldep ocamlmklib ocamlmktop ocamlopt ocamlprof; do
200   mv $f %{_mingw32_target}-$f
201 done
202 popd
203
204 # Don't install ocamlrun, use native one.
205 rm $RPM_BUILD_ROOT%{_bindir}/ocamlrun
206
207
208 %clean
209 rm -rf $RPM_BUILD_ROOT
210
211
212 %files
213 %defattr(-,root,root)
214 %doc README.Fedora
215 %{_bindir}/%{_mingw32_target}-ocamlc
216 %{_bindir}/%{_mingw32_target}-ocamlcp
217 %{_bindir}/%{_mingw32_target}-ocamldep
218 %{_bindir}/%{_mingw32_target}-ocamlmklib
219 %{_bindir}/%{_mingw32_target}-ocamlmktop
220 %{_bindir}/%{_mingw32_target}-ocamlprof
221 %{_bindir}/%{_mingw32_target}-ocamlopt
222 %{_libdir}/%{_mingw32_target}-ocaml/
223
224
225 %changelog
226 * Fri Feb 20 2009 Richard W.M. Jones <rjones@redhat.com> - 3.11.0-0.16.beta1
227 - Rebuild for mingw32-gcc 4.4
228
229 * Sun Nov 23 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0-0.15.beta1
230 - Use the proper package naming convention, since '+' etc shouldn't be
231   in the name, as per Fedora packaging guidelines.  Note that this won't
232   upgrade smoothly, but we don't care because these packages aren't
233   officially released yet.  You'll just have to uninstall the old
234   package and install the new one.
235 - Don't ship our own ocamlrun, use the native one instead.
236 - Require camlp4 utilities.
237
238 * Mon Nov 17 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-14
239 - Added README.Fedora.
240
241 * Sun Nov 16 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-13
242 - Build the native compiler as 32 bits even on a 64 bit build
243   architecture (because the target, Windows, is 32 bit).  The
244   compiler does strength reduction and other optimizations
245   internally so we must ensure it uses the same int type.
246 - Requires libX11-devel.i386 and libgcc.i386.
247 - Allow the normal dependency generators to run because this
248   is a native package.
249 - Use mingw32 strip to avoid corrupting binaries.
250
251 * Sun Nov 16 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-8
252 - Install ocamlc.
253
254 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-7
255 - Further requirements.
256
257 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-6
258 - Install tools, particularly ocamlmklib.
259
260 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-5
261 - +Requires mingw32-flexdll and the cross-compiler.
262
263 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-4
264 - Initial RPM release.