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