Added mingw32-ocaml-curses.
[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:        6%{?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
58 %description
59 Objective Caml is a high-level, strongly-typed, functional and
60 object-oriented programming language from the ML family of languages.
61
62 This package is an OCaml cross-compiler which runs natively on Fedora
63 and produces Windows native executables.
64
65
66 %prep
67 %setup -q -n ocaml-%{version}
68
69 %patch1000 -p1
70 %patch1001 -p1
71 %patch1002 -p1
72 %patch1003 -p1
73 %patch1004 -p1
74 %patch1005 -p1
75 %patch1006 -p0
76
77
78 %build
79 # Build native ocamlrun and ocamlc which contain the filename-win32-dirsep
80 # patch.
81 ./configure \
82   -no-tk \
83   -bindir %{_bindir} \
84   -libdir %{_libdir}/ocaml \
85   -mandir %{_mandir}/man1
86 make world
87
88 # Now move the working ocamlrun, ocamlc into the boot/ directory,
89 # overwriting the binary versions which ship with the compiler with
90 # ones that contain the above filename-win32-dirsep patch.
91 make coreboot
92
93 # Now replace the compiler configuration (config/{s.h,m.h,Makefile})
94 # with ones as they would be on a 32 bit Windows system.
95 pushd config
96
97 # config/m.h can just be copied from config/m-nt.h which ships.
98 rm -f m.h
99 cp m-nt.h m.h
100
101 # config/s.h can just be copied from config/s-nt.h which ships.
102 rm -f s.h
103 cp s-nt.h s.h
104
105 # config/Makefile is a custom one which we supply.
106 rm -f Makefile
107 sed \
108   -e 's,@prefix@,%{_prefix},g' \
109   -e 's,@bindir@,%{_bindir},g' \
110   -e 's,@libdir@,%{_libdir},g' \
111   -e 's,@target@,%{_mingw32_target},g' \
112   -e 's,@otherlibraries@,%{otherlibraries},g' \
113   < %{SOURCE1000} > Makefile
114
115 popd
116
117 # We're going to build in otherlibs/win32unix and otherlibs/win32graph
118 # directories, but since they would normally only be built under
119 # Windows, they only have the Makefile.nt files.  Just symlink
120 # Makefile -> Makefile.nt for these cases.
121 for d in otherlibs/win32unix otherlibs/win32graph; do
122   ln -s Makefile.nt $d/Makefile
123 done
124
125 # Now clean the temporary files from the previous build.  This
126 # will also cause asmcomp/arch.ml (etc) to be linked to the 32 bit
127 # i386 versions, essentially causing ocamlopt to use the Win/i386 code
128 # generator.
129 make partialclean
130
131 # Just rebuild some small bits that we need for the following
132 # 'make opt' to work.  Note that 'make all' fails here.
133 make -C byterun libcamlrun.a
134 make ocaml ocamlc
135 make -C stdlib
136 make -C tools ocamlmklib
137
138 # Build ocamlopt
139 make opt
140
141
142 %install
143 rm -rf $RPM_BUILD_ROOT
144
145 mkdir -p $RPM_BUILD_ROOT%{_bindir}
146 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
147 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/threads
148 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/stublibs
149
150 # This is the equivalent of 'make install installopt', but
151 # we only want to install the parts which are really necessary
152 # for the cross-compiler.  eg. We don't need any of the native
153 # tools like ocamllex or ocamldoc.
154 %define makevars BINDIR=$RPM_BUILD_ROOT%{_bindir} LIBDIR=$RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
155 make %{makevars} -C byterun install
156 make %{makevars} -C stdlib install
157 for i in %{otherlibraries}; do
158   make %{makevars} -C otherlibs/$i install
159 done
160 make %{makevars} -C tools install
161 make %{makevars} installopt
162
163 cp config/Makefile \
164    $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/Makefile.config
165
166 # For bytecode binaries, change the bang-path to point to the locally
167 # installed ocamlrun.
168 pushd $RPM_BUILD_ROOT%{_bindir}
169 for f in ocamlcp ocamldep ocamlmklib ocamlopt ocamlprof; do
170   mv $f $f.old
171   echo '#!%{_bindir}/%{_mingw32_target}-ocamlrun' > $f
172   tail -n +2 $f.old >> $f
173   chmod +x $f
174   rm $f.old
175 done
176 popd
177
178 # Rename all the binaries to target-binary.
179 pushd $RPM_BUILD_ROOT%{_bindir}
180 for f in ocamlcp ocamldep ocamlmklib ocamlmktop ocamlopt ocamlprof ocamlrun; do
181   mv $f %{_mingw32_target}-$f
182 done
183 popd
184
185
186 %clean
187 rm -rf $RPM_BUILD_ROOT
188
189
190 %files
191 %defattr(-,root,root)
192 %{_bindir}/%{_mingw32_target}-ocamlcp
193 %{_bindir}/%{_mingw32_target}-ocamldep
194 %{_bindir}/%{_mingw32_target}-ocamlmklib
195 %{_bindir}/%{_mingw32_target}-ocamlmktop
196 %{_bindir}/%{_mingw32_target}-ocamlprof
197 %{_bindir}/%{_mingw32_target}-ocamlopt
198 %{_bindir}/%{_mingw32_target}-ocamlrun
199 %{_libdir}/%{_mingw32_target}-ocaml/
200
201
202 %changelog
203 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-6
204 - Install tools, particularly ocamlmklib.
205
206 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-5
207 - +Requires mingw32-flexdll and the cross-compiler.
208
209 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-4
210 - Initial RPM release.