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