]> git.pld-linux.org Git - packages/ocaml-csexp.git/blame - ocaml-csexp.spec
- new
[packages/ocaml-csexp.git] / ocaml-csexp.spec
CommitLineData
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
16Summary: Parsing and printing of S-expressions in canonical form
17Name: ocaml-%{module}
18Version: 1.4.0
19Release: 1
20License: MIT
21Source0: https://github.com/ocaml-dune/csexp/releases/download/%{version}/%{module}-%{version}.tbz
22# Source0-md5: d6b5866be24bf8730c127eedca4dc447
23URL: https://github.com/ocaml-dune/csexp
24# Depend on Stdlib.Result instead of ocaml-result.
25Patch0: %{name}-result.patch
26BuildRequires: ocaml >= 4.02.3
27%if %{with dune}
28BuildRequires: ocaml-dune >= 1.11
29BuildRequires: ocaml-odoc
30BuildRequires: ocaml-result-devel >= 1.5
31%endif
32BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
33
34%description
35This project provides minimal support for parsing and printing
36S-expressions in canonical form, which is a very simple and canonical
37binary encoding of S-expressions.
38
39%package devel
40Summary: Development files for %{name}
41Requires: %{name} = %{version}-%{release}
42%if %{with dune}
43Requires: ocaml-result-devel
44%endif
45
46%description devel
47The %{name}-devel package contains libraries and signature files for
48developing 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}
58dune build %{?_smp_mflags} --display=verbose @install
59dune build %{?_smp_mflags} @doc
60%else
61OFLAGS="-strict-sequence -strict-formats -short-paths -keep-locs -g -opaque"
62OCFLAGS="$OFLAGS -bin-annot"
63cd src
64ocamlc $OCFLAGS -output-obj csexp.mli
65ocamlc $OCFLAGS -a -o csexp.cma csexp.ml
66%if %{with ocaml_opt}
67ocamlopt $OFLAGS -ccopt "%{rpmcflags}" -cclib "%{rpmldflags}" -a \
68 -o csexp.cmxa csexp.ml
69ocamlopt $OFLAGS -ccopt "%{rpmcflags}" -cclib "%{rpmldflags}" -shared \
70 -o csexp.cmxs csexp.ml
71%endif
72%endif
73
74%install
75rm -rf $RPM_BUILD_ROOT
76%if %{with dune}
77dune install --destdir=$RPM_BUILD_ROOT
78
79# We do not want the dune markers
80find _build/default/_doc/_html -name .dune-keep -delete
81
82# We do not want the ml files
83find $RPM_BUILD_ROOT%{_libdir}/ocaml -name \*.ml -delete
84
85# We install the documentation with the doc macro
86rm -fr $RPM_BUILD_ROOT%{_prefix}/doc
87%else
88# Install without dune. See comment at the top.
89install -d $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
90cp -p src/csexp.{cma,cmi,cmt,cmti,mli} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
91%if %{with ocaml_opt}
92cp -p src/csexp.{a,cmx,cmxa,cmxs} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
93%endif
94
95cp -p csexp.opam $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/opam
96
97cat >> $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/META << EOF
98version = "%{version}"
99description = "Parsing and printing of S-expressions in canonical form"
100archive(byte) = "csexp.cma"
101%ifarch %{ocaml_native_compiler}
102archive(native) = "csexp.cmxa"
103%endif
104plugin(byte) = "csexp.cma"
105%ifarch %{ocaml_native_compiler}
106plugin(native) = "csexp.cmxs"
107%endif
108EOF
109
110cat >> $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))))
133EOF
134%endif
135
136%clean
137rm -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
This page took 0.073437 seconds and 4 git commands to generate.