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
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
11 %if %{without ocaml_opt}
12 %define _enable_debug_packages 0
16 Summary: Parsing and printing of S-expressions in canonical form
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
28 BuildRequires: ocaml-dune >= 1.11
29 BuildRequires: ocaml-odoc
30 BuildRequires: ocaml-result-devel >= 1.5
32 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
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.
40 Summary: Development files for %{name}
41 Requires: %{name} = %{version}-%{release}
43 Requires: ocaml-result-devel
47 The %{name}-devel package contains libraries and signature files for
48 developing applications that use %{name}.
51 %setup -q -n %{module}-%{version}
58 dune build %{?_smp_mflags} --display=verbose @install
59 dune build %{?_smp_mflags} @doc
61 OFLAGS="-strict-sequence -strict-formats -short-paths -keep-locs -g -opaque"
62 OCFLAGS="$OFLAGS -bin-annot"
64 ocamlc $OCFLAGS -output-obj csexp.mli
65 ocamlc $OCFLAGS -a -o csexp.cma csexp.ml
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
75 rm -rf $RPM_BUILD_ROOT
77 dune install --destdir=$RPM_BUILD_ROOT
79 # We do not want the dune markers
80 find _build/default/_doc/_html -name .dune-keep -delete
82 # We do not want the ml files
83 find $RPM_BUILD_ROOT%{_libdir}/ocaml -name \*.ml -delete
85 # We install the documentation with the doc macro
86 rm -fr $RPM_BUILD_ROOT%{_prefix}/doc
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}
92 cp -p src/csexp.{a,cmx,cmxa,cmxs} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
95 cp -p csexp.opam $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/opam
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"
104 plugin(byte) = "csexp.cma"
105 %ifarch %{ocaml_native_compiler}
106 plugin(native) = "csexp.cmxs"
110 cat >> $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/dune-package << EOF
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)
122 (archives (byte csexp.cma))
123 (plugins (byte csexp.cma))
125 (main_module_name Csexp)
126 %if %{with ocaml_opt}
132 (singleton (name Csexp) (obj_name csexp) (visibility public) (impl) (intf))))
137 rm -rf $RPM_BUILD_ROOT
140 %defattr(644,root,root,755)
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
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
160 %{_libdir}/ocaml/%{module}/*.cmt
161 %{_libdir}/ocaml/%{module}/*.cmti
162 %{_libdir}/ocaml/%{module}/*.mli