]>
Commit | Line | Data |
---|---|---|
ba0f37a9 JR |
1 | # |
2 | # Conditional build: | |
3 | %bcond_without ocaml_opt # skip building native optimized binaries (bytecode is always built) | |
4 | %bcond_with dune # build with dune, this is off due to circular deps | |
5 | ||
6 | # not yet available on x32 (ocaml 4.02.1), update when upstream will support it | |
7 | %ifnarch %{ix86} %{x8664} %{arm} aarch64 ppc sparc sparcv9 | |
8 | %undefine with_ocaml_opt | |
9 | %endif | |
10 | ||
11 | %if %{without ocaml_opt} | |
12 | %define _enable_debug_packages 0 | |
13 | %endif | |
14 | ||
15 | %define module csexp | |
16 | Summary: Parsing and printing of S-expressions in canonical form | |
17 | Name: ocaml-%{module} | |
18 | Version: 1.4.0 | |
19 | Release: 1 | |
20 | License: MIT | |
21 | Source0: https://github.com/ocaml-dune/csexp/releases/download/%{version}/%{module}-%{version}.tbz | |
22 | # Source0-md5: d6b5866be24bf8730c127eedca4dc447 | |
23 | URL: https://github.com/ocaml-dune/csexp | |
24 | # Depend on Stdlib.Result instead of ocaml-result. | |
25 | Patch0: %{name}-result.patch | |
26 | BuildRequires: ocaml >= 4.02.3 | |
27 | %if %{with dune} | |
28 | BuildRequires: ocaml-dune >= 1.11 | |
29 | BuildRequires: ocaml-odoc | |
30 | BuildRequires: ocaml-result-devel >= 1.5 | |
31 | %endif | |
32 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
33 | ||
34 | %description | |
35 | This project provides minimal support for parsing and printing | |
36 | S-expressions in canonical form, which is a very simple and canonical | |
37 | binary encoding of S-expressions. | |
38 | ||
39 | %package devel | |
40 | Summary: Development files for %{name} | |
41 | Requires: %{name} = %{version}-%{release} | |
42 | %if %{with dune} | |
43 | Requires: ocaml-result-devel | |
44 | %endif | |
45 | ||
46 | %description devel | |
47 | The %{name}-devel package contains libraries and signature files for | |
48 | developing applications that use %{name}. | |
49 | ||
50 | %prep | |
51 | %setup -q -n %{module}-%{version} | |
52 | %if %{without dune} | |
53 | %patch0 -p1 | |
54 | %endif | |
55 | ||
56 | %build | |
57 | %if %{with dune} | |
58 | dune build %{?_smp_mflags} --display=verbose @install | |
59 | dune build %{?_smp_mflags} @doc | |
60 | %else | |
61 | OFLAGS="-strict-sequence -strict-formats -short-paths -keep-locs -g -opaque" | |
62 | OCFLAGS="$OFLAGS -bin-annot" | |
63 | cd src | |
64 | ocamlc $OCFLAGS -output-obj csexp.mli | |
65 | ocamlc $OCFLAGS -a -o csexp.cma csexp.ml | |
66 | %if %{with ocaml_opt} | |
67 | ocamlopt $OFLAGS -ccopt "%{rpmcflags}" -cclib "%{rpmldflags}" -a \ | |
68 | -o csexp.cmxa csexp.ml | |
69 | ocamlopt $OFLAGS -ccopt "%{rpmcflags}" -cclib "%{rpmldflags}" -shared \ | |
70 | -o csexp.cmxs csexp.ml | |
71 | %endif | |
72 | %endif | |
73 | ||
74 | %install | |
75 | rm -rf $RPM_BUILD_ROOT | |
76 | %if %{with dune} | |
77 | dune install --destdir=$RPM_BUILD_ROOT | |
78 | ||
79 | # We do not want the dune markers | |
80 | find _build/default/_doc/_html -name .dune-keep -delete | |
81 | ||
82 | # We do not want the ml files | |
83 | find $RPM_BUILD_ROOT%{_libdir}/ocaml -name \*.ml -delete | |
84 | ||
85 | # We install the documentation with the doc macro | |
86 | rm -fr $RPM_BUILD_ROOT%{_prefix}/doc | |
87 | %else | |
88 | # Install without dune. See comment at the top. | |
89 | install -d $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module} | |
90 | cp -p src/csexp.{cma,cmi,cmt,cmti,mli} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module} | |
91 | %if %{with ocaml_opt} | |
92 | cp -p src/csexp.{a,cmx,cmxa,cmxs} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module} | |
93 | %endif | |
94 | ||
95 | cp -p csexp.opam $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/opam | |
96 | ||
97 | cat >> $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/META << EOF | |
98 | version = "%{version}" | |
99 | description = "Parsing and printing of S-expressions in canonical form" | |
100 | archive(byte) = "csexp.cma" | |
101 | %ifarch %{ocaml_native_compiler} | |
102 | archive(native) = "csexp.cmxa" | |
103 | %endif | |
104 | plugin(byte) = "csexp.cma" | |
105 | %ifarch %{ocaml_native_compiler} | |
106 | plugin(native) = "csexp.cmxs" | |
107 | %endif | |
108 | EOF | |
109 | ||
110 | cat >> $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/dune-package << EOF | |
111 | (lang dune 2.8) | |
112 | (name csexp) | |
113 | (version %{version}) | |
114 | (library | |
115 | (name csexp) | |
116 | (kind normal) | |
117 | %if %{with ocaml_opt} | |
118 | (archives (byte csexp.cma) (native csexp.cmxa)) | |
119 | (plugins (byte csexp.cma) (native csexp.cmxs)) | |
120 | (native_archives csexp.a) | |
121 | %else | |
122 | (archives (byte csexp.cma)) | |
123 | (plugins (byte csexp.cma)) | |
124 | %endif | |
125 | (main_module_name Csexp) | |
126 | %if %{with ocaml_opt} | |
127 | (modes byte native) | |
128 | %else | |
129 | (modes byte) | |
130 | %endif | |
131 | (modules | |
132 | (singleton (name Csexp) (obj_name csexp) (visibility public) (impl) (intf)))) | |
133 | EOF | |
134 | %endif | |
135 | ||
136 | %clean | |
137 | rm -rf $RPM_BUILD_ROOT | |
138 | ||
139 | %files | |
140 | %defattr(644,root,root,755) | |
141 | %doc README.md | |
142 | %doc LICENSE.md | |
143 | %dir %{_libdir}/ocaml/%{module}/ | |
144 | %{_libdir}/ocaml/%{module}/META | |
145 | %{_libdir}/ocaml/%{module}/*.cma | |
146 | %{_libdir}/ocaml/%{module}/*.cmi | |
147 | %if %{with ocaml_opt} | |
148 | %{_libdir}/ocaml/%{module}/*.cmxs | |
149 | %endif | |
150 | ||
151 | %files devel | |
152 | %defattr(644,root,root,755) | |
153 | %{_libdir}/ocaml/%{module}/dune-package | |
154 | %{_libdir}/ocaml/%{module}/opam | |
155 | %if %{with ocaml_opt} | |
156 | %{_libdir}/ocaml/%{module}/*.a | |
157 | %{_libdir}/ocaml/%{module}/*.cmx | |
158 | %{_libdir}/ocaml/%{module}/*.cmxa | |
159 | %endif | |
160 | %{_libdir}/ocaml/%{module}/*.cmt | |
161 | %{_libdir}/ocaml/%{module}/*.cmti | |
162 | %{_libdir}/ocaml/%{module}/*.mli |