Adding some OCaml test programs.
[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 Name:           mingw32-ocaml
10 Version:        3.11.0+beta1
11 Release:        3%{?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}.tar.bz2
19
20 # This is installed as config/Makefile when we cross-compile.
21 Source1000:     Makefile-fedora-mingw.in
22
23 # XXX We should apply any Fedora native patches here.
24
25 # For patch description, see the top of each patch file.
26 # Start numbering at 1000 since these are MinGW-specific patches.
27 Patch1000:      mingw32-ocaml-3.11.0+beta1-combined-Makefile.patch
28 Patch1001:      mingw32-ocaml-3.11.0+beta1-disable-cmxs.patch
29 Patch1002:      mingw32-ocaml-3.11.0+beta1-filename-win32-dirsep.patch
30 Patch1003:      mingw32-ocaml-3.11.0+beta1-i386-profiling.patch
31 Patch1004:      mingw32-ocaml-3.11.0+beta1-no-stdlib-dir.patch
32 Patch1005:      mingw32-ocaml-3.11.0+beta1-win32-fixes.patch
33 Patch1006:      mingw32-ocaml-3.11.0+beta1-win32unix-path.patch
34
35 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
36 # Is it noarch? (XXX)
37 BuildArch:      noarch
38
39 BuildRequires:  mingw32-filesystem >= 30
40 BuildRequires:  mingw32-gcc
41 BuildRequires:  mingw32-binutils
42 BuildRequires:  mingw32-flexdll
43
44 # While we still ship bytecode, this requires a /usr/bin/ocamlrun from
45 # the _identical_ native package.  We don't have that at the moment,
46 # which is why this is commented out.
47 #Requires:       ocaml-runtime = %{version}
48
49
50 %description
51 Objective Caml is a high-level, strongly-typed, functional and
52 object-oriented programming language from the ML family of languages.
53
54 This package is an OCaml cross-compiler which runs natively on Fedora
55 and produces Windows native executables.
56
57
58 %prep
59 %setup -q -n ocaml-%{version}
60
61 %patch1000 -p1
62 %patch1001 -p1
63 %patch1002 -p1
64 %patch1003 -p1
65 %patch1004 -p1
66 %patch1005 -p1
67 %patch1006 -p0
68
69
70 %build
71 # Build native ocamlrun and ocamlc which contain the filename-win32-dirsep
72 # patch.
73 ./configure \
74   -no-tk \
75   -bindir %{_bindir} \
76   -libdir %{_libdir}/ocaml \
77   -mandir %{_mandir}/man1
78 make world
79
80 # Now move the working ocamlrun, ocamlc into the boot/ directory,
81 # overwriting the binary versions which ship with the compiler with
82 # ones that contain the above filename-win32-dirsep patch.
83 make coreboot
84
85 # Now replace the compiler configuration (config/{s.h,m.h,Makefile})
86 # with ones as they would be on a 32 bit Windows system.
87 pushd config
88
89 # config/m.h can just be copied from config/m-nt.h which ships.
90 rm -f m.h
91 cp m-nt.h m.h
92
93 # config/s.h can just be copied from config/s-nt.h which ships.
94 rm -f s.h
95 cp s-nt.h s.h
96
97 # config/Makefile is a custom one which we supply.
98 rm -f Makefile
99 sed \
100   -e 's,@prefix@,%{_prefix},g' \
101   -e 's,@bindir@,%{_bindir},g' \
102   -e 's,@libdir@,%{_libdir},g' \
103   -e 's,@target@,%{_mingw32_target},g' \
104   < %{SOURCE1000} > Makefile
105
106 popd
107
108 # We're going to build in otherlibs/win32unix and otherlibs/win32graph
109 # directories, but since they would normally only be built under
110 # Windows, they only have the Makefile.nt files.  Just symlink
111 # Makefile -> Makefile.nt for these cases.
112 for d in otherlibs/win32unix otherlibs/win32graph; do
113   ln -s Makefile.nt $d/Makefile
114 done
115
116 # Now clean the temporary files from the previous build.  This
117 # will also cause asmcomp/arch.ml (etc) to be linked to the 32 bit
118 # i386 versions, essentially causing ocamlopt to use the Win/i386 code
119 # generator.
120 make partialclean
121
122 # Just rebuild some small bits that we need for the following
123 # 'make opt' to work.  Note that 'make all' fails here.
124 make -C byterun libcamlrun.a
125 make ocaml ocamlc
126 make -C stdlib
127 make -C tools ocamlmklib
128
129 # Build ocamlopt
130 make opt
131
132
133 %install
134 rm -rf $RPM_BUILD_ROOT
135
136 mkdir -p $RPM_BUILD_ROOT%{_bindir}
137 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
138 mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/threads
139
140 # This is the equivalent of 'make install installopt', but
141 # we only want to install the parts which are really necessary
142 # for the cross-compiler.  eg. We don't need any of the native
143 # tools like ocamllex or ocamldoc.
144 %define makevars BINDIR=$RPM_BUILD_ROOT%{_bindir} LIBDIR=$RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml
145 make %{makevars} -C byterun install
146 make %{makevars} -C stdlib install
147 make %{makevars} installopt
148
149 cp config/Makefile \
150    $RPM_BUILD_ROOT%{_libdir}/%{_mingw32_target}-ocaml/Makefile.config
151
152 # Rename the binaries so they don't clash with base OCaml package.
153 mv $RPM_BUILD_ROOT%{_bindir}/ocamlrun \
154   $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlrun
155 echo '#!%{_bindir}/%{_mingw32_target}-ocamlrun' \
156   > $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlopt
157 tail -n +2 $RPM_BUILD_ROOT%{_bindir}/ocamlopt \
158   >> $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlopt
159 chmod 0755 $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlopt
160 rm $RPM_BUILD_ROOT%{_bindir}/ocamlopt
161
162
163 %clean
164 rm -rf $RPM_BUILD_ROOT
165
166
167 %files
168 %defattr(-,root,root)
169 %{_bindir}/%{_mingw32_target}-ocamlrun
170 %{_bindir}/%{_mingw32_target}-ocamlopt
171 %{_libdir}/%{_mingw32_target}-ocaml/
172
173
174 %changelog
175 * Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-3
176 - Initial RPM release.