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