Blob Blame History Raw
%global pre_tag beta17

Name:           jbuilder
Version:        1.0
Release:        0.7.%{pre_tag}%{?dist}
Summary:        A composable build system for OCaml

%global libname %(echo %{name} | sed -e 's/^ocaml-//')

License:        ASL 2.0
URL:            https://github.com/janestreet/jbuilder/
Source0:        https://github.com/janestreet/%{libname}/archive/%{version}+%{pre_tag}/%{libname}-%{version}-%{pre_tag}.tar.gz

# Remove a test that depends on a library that depends on jbuilder.
# Hurray for recursive dependency chains...
# Remove further tests that want 'utop' and 'odoc' to exist.
Patch0:         jbuilder-remove-unrunnable-unit-tests.patch

# Always build boot.exe using the bytecode compiler. This speeds
# up the build and fixes a build failure on ppc64.
Patch1:         https://patch-diff.githubusercontent.com/raw/ocaml/dune/pull/463.patch

BuildRequires:  ocaml >= 4.02.3
BuildRequires:  ocaml-findlib-devel

# Depend on /usr/bin/sphinx-build for python version invariance.
BuildRequires:  /usr/bin/sphinx-build

# Required by tests.
BuildRequires:  ocaml-menhir

# Jbuilder has vendored deps (ugh):
# I'm not clear on how to unbundle them.
# It seems to be unsupported upstream; the bootstrap process for jbuilder
# doesn't seem to be able to detect libraries installed systemwide.
# https://github.com/janestreet/jbuilder/issues/220
Provides:      bundled(ocaml-opam-file-format)
Provides:      bundled(ocaml-cmdliner) = 1.0.0
Provides:      bundled(ocaml-re)

%description
Jbuilder is a build system designed for OCaml/Reason projects only. It focuses
on providing the user with a consistent experience and takes care of most of
the low-level details of OCaml compilation. All you have to do is provide a
description of your project and Jbuilder will do the rest.

The scheme it implements is inspired from the one used inside Jane Street and
adapted to the open source world. It has matured over a long time and is used
daily by hundred of developers, which means that it is highly tested and
productive.

%package        doc
Summary:        HTML documentation for %{name}
Requires:       %{name} = %{version}-%{release}

BuildArch:      noarch

%description    doc
HTML documentation for jbuilder, a composable build system for OCaml.

%prep
# Eep. Upstream is (slowly) renaming jbuilder -> dune. This has already
# affected the tarball here.
%autosetup -n dune-%{version}-%{pre_tag} -p1

# The jbuilder build script figures out if the native code compiler is available
# and uses it if it is, otherwise it uses the bytecode compiler. Thus I think
# we just need to "make" here.
%make_build release
%make_build doc

%install
# jbuilder's makefile has a "make install" target. Tragically, it uses opam-install(er)
# to install itself. Even more tragically, opam now requires jbuilder to build.
# Therefore as a workaround we can just manually install things ourselves--
# jbuilder is *mostly* just a binary, making this easy.
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_libdir}/ocaml/jbuilder/
mkdir -p %{buildroot}%{_mandir}/man1

# The files to install are stored in _build as symlinks; dereference them.
cp -aL _build/install/default/bin/jbuilder %{buildroot}%{_bindir}/
cp -aL _build/install/default/lib/jbuilder/* %{buildroot}%{_libdir}/ocaml/jbuilder/
cp -aL _build/install/default/man/man1/* %{buildroot}%{_mandir}/man1

# Install documentation by way of pkgdocdir.
mkdir -p %{buildroot}%{_pkgdocdir}/
cp -ar README.md CHANGES.md doc/_build/* %{buildroot}%{_pkgdocdir}/

# Run the unit tests.
%check
make test

%files
%license LICENSE.md
%doc %{_pkgdocdir}/README.md
%doc %{_pkgdocdir}/CHANGES.md
%{_libdir}/ocaml/%{libname}
%{_bindir}/jbuilder
%{_mandir}/man1/jbuilder.1*
%{_mandir}/man1/jbuilder-build.1*
%{_mandir}/man1/jbuilder-clean.1*
%{_mandir}/man1/jbuilder-exec.1*
%{_mandir}/man1/jbuilder-external-lib-deps.1*
%{_mandir}/man1/jbuilder-install.1*
%{_mandir}/man1/jbuilder-installed-libraries.1*
%{_mandir}/man1/jbuilder-promote.1*
%{_mandir}/man1/jbuilder-rules.1*
%{_mandir}/man1/jbuilder-runtest.1*
%{_mandir}/man1/jbuilder-subst.1*
%{_mandir}/man1/jbuilder-uninstall.1*
%{_mandir}/man1/jbuilder-utop.1*

%files doc
%exclude %{_pkgdocdir}/README.md
%exclude %{_pkgdocdir}/CHANGES.md
%doc %{_pkgdocdir}/*

%changelog
* Tue Jan 30 2018 Ben Rosser <rosser.bjr@gmail.com> - 1.0-0.7.beta18
- Fix build failure on ppc64 by always using bytecode ocaml compiler to bootstrap.

* Wed Jan 24 2018 Ben Rosser <rosser.bjr@gmail.com> 1.0-0.6.beta17
- Update to latest upstream release, beta17 (#1537836).
- Remove unit tests that require external deps (that themselves require jbuilder).

* Tue Nov 14 2017 Ben Rosser <rosser.bjr@gmail.com> 1.0-0.5.beta16
- Update to latest upstream release, beta16 (#1509749).
- Add pre_tag version suffix to source flie name to avoid confusion.

* Mon Oct 23 2017 Ben Rosser <rosser.bjr@gmail.com> 1.0-0.4.beta14
- Update to latest upstream release, beta14 (#1504414).

* Mon Aug 28 2017 Ben Rosser <rosser.bjr@gmail.com> 1.0-0.3.beta12
- Update to latest upstream release, beta12.
- Fix typo in description.
- Use simpler github source URL.
- Use make_build macros when compiling.

* Tue Aug 15 2017 Ben Rosser <rosser.bjr@gmail.com> 1.0-0.2.beta11
- Update to a git snapshot so opam can be built against.
- Modernize ocaml packaging.

* Tue Aug  1 2017 Ben Rosser <rosser.bjr@gmail.com> 1.0-0.1.beta11
- Initial package.