Blob Blame History Raw
%ifnarch %{ocaml_native_compiler}
%global debug_package %{nil}
%endif

%global srcname merlin
%global ocamlver 412

Name:           ocaml-%{srcname}
Version:        4.3.1
Release:        2%{?dist}
Summary:        Context sensitive completion for OCaml

# The entire source is MIT except:
# - QPL: src/ocaml/driver/pparse.ml{,i}
# - QPL: src/ocaml/preprocess/lexer_ident.mll
# - QPL: src/ocaml/preprocess/lexer_raw.ml{i,l}
# - LGPLv2 with exceptions: src/ocaml/preprocess/parser_raw.mly
# - LGPLv2 with exceptions: upstream/ocaml_411/parsing/parser.mly
# - LGPLv2 with exceptions: upstream/ocaml_412/parsing/parser.mly
#
# The final license is due to the linking exception on the LGPLv2 files.
License:        MIT and QPL
URL:            https://ocaml.github.io/%{srcname}/
Source0:        https://github.com/ocaml/%{srcname}/releases/download/v%{version}-%{ocamlver}/%{srcname}-v%{version}-%{ocamlver}.tbz

# Original .gitignore is not packaged in the tarball so we have to
# provide in order for the patches below to apply.
Source1:        gitignore

# The entirety of this pull request which fixes everything for OCaml 4.13:
# https://github.com/ocaml/merlin/pull/1381/commits
Patch0001:      0001-Add-OCaml-4.13-upstream-sources.patch
Patch0002:      0002-Bump-OCaml-version-to-4.13-in-opam-file.patch
Patch0003:      0003-Add-local-switch-to-gitignore.patch
Patch0004:      0004-Update-Ast_helper.patch
Patch0005:      0005-Update-Ast_iterator.patch
Patch0006:      0006-Update-Ast_mapper.patch
Patch0007:      0007-Update-Builtin_attributes.patch
Patch0008:      0008-doublecheck-Update-Lexer_raw.patch
Patch0009:      0009-Update-lexer_raw-mli.patch
Patch0010:      0010-Update-Location.patch
Patch0011:      0011-Update-Longident.patch
Patch0012:      0012-doublecheck-Update-parser.mly.patch
Patch0013:      0013-Remove-dune-files-from-upstream-code.patch
Patch0014:      0014-Update-Parsetree.patch
Patch0015:      0015-Update-Gen_config.patch
Patch0016:      0016-Update-Pprintast.patch
Patch0017:      0017-Update-Printast.patch
Patch0018:      0018-doublecheck-Do-not-use-Clflags.unsafe.patch
Patch0019:      0019-Update-parser-artifacts-and-Menhir-lib.patch
Patch0020:      0020-Update-Load_path.patch
Patch0021:      0021-Update-Warnings.patch
Patch0022:      0022-Fix-Load_path.patch
Patch0023:      0023-Update-Types.patch
Patch0024:      0024-Fix-new-omitted-labels.patch
Patch0025:      0025-Update-Btype.patch
Patch0026:      0026-Update-Ctype.patch
Patch0027:      0027-Update-Datarepr.patch
Patch0028:      0028-Update-Env.patch
Patch0029:      0029-Update-Includeclass.patch
Patch0030:      0030-Update-Include_core.patch
Patch0031:      0031-Update-Includemod.patch
Patch0032:      0032-Update-Mtype.patch
Patch0033:      0033-Add-new-Diffing-module.patch
Patch0034:      0034-Update-Oprint.patch
Patch0035:      0035-Update-Outcometree.patch
Patch0036:      0036-Update-Typedtree.patch
Patch0037:      0037-Update-parmatch.patch
Patch0038:      0038-Update-Path.patch
Patch0039:      0039-Update-Patterns.patch
Patch0040:      0040-Update-Predef.patch
Patch0041:      0041-Update-primitive.patch
Patch0042:      0042-Update-Printpat.patch
Patch0043:      0043-Add-new-module-Signature_group.patch
Patch0044:      0044-Update-Includemod.patch
Patch0045:      0045-doublecheck-Update-Printtyp.patch
Patch0046:      0046-Update-Printtyped.patch
Patch0047:      0047-Update-Rec_check.patch
Patch0048:      0048-Update-Subst.patch
Patch0049:      0049-Update-Tast_iterator.patch
Patch0050:      0050-Update-Tast_mapper.patch
Patch0051:      0051-Update-Typeclass.patch
Patch0052:      0052-Update-Typecore.patch
Patch0053:      0053-Update-Typedecl.patch
Patch0054:      0054-Update-Typemod.patch
Patch0055:      0055-Update-Typeopt.patch
Patch0056:      0056-Update-Typeexp.patch
Patch0057:      0057-Update-Untypeast.patch
Patch0058:      0058-Fix-Typecore-patches.patch
Patch0059:      0059-Add-new-Includemod_errorprinter-module.patch
Patch0060:      0060-Fix-Includemod.patch
Patch0061:      0061-doublecheck-Fix-Browse_raw.patch
Patch0062:      0062-doublecheck-Fix-Merlin-specifics.patch
Patch0063:      0063-Bump-magic-numbers.patch
Patch0064:      0064-Fix-various-analysis-issues-with-the-new-compiler-AP.patch
Patch0065:      0065-Promote-obviously-correct-changes-in-tests.patch
Patch0066:      0066-Fix-untyping-issue.-See-ocaml-ocaml-10593.patch
Patch0067:      0067-Disable-new-missing-mli-warning-in-tests.patch
Patch0068:      0068-Use-Clflags.fast.patch
Patch0069:      0069-Update-generated-parser.patch
%if 0
Patch0070:      0070-wip-Update-Github-actions.patch
Patch0071:      0071-Windows-CI.patch
%endif
Patch0072:      0072-Parser-remove-one-last-raise.patch
Patch0073:      0073-Deactivate-short-path-until-they-are-fixed.patch

# Fix the tests to work with /usr/lib64 as well as /usr/lib
Patch0074:      0074-Use-usr-lib64-for-Fedora.patch

# On i386, we get extra output about text relocations
# See https://github.com/ocaml/ocaml/issues/9800
# This would only be applied on i686, but RPM makes this hard
# and anyway we're ignoring test results.  XXX Fix this when
# OCaml 4.13 support is upstream.
#%%ifarch %%{ix86}
%if 0
Patch0075:      0075-On-i386-we-get-extra-output-about-text-relocations.patch
%endif

BuildRequires:  emacs
BuildRequires:  emacs-auto-complete
BuildRequires:  emacs-company-mode
BuildRequires:  emacs-iedit
BuildRequires:  emacs-tuareg
BuildRequires:  jq
BuildRequires:  ocaml >= 4.12
BuildRequires:  ocaml-biniou-devel
BuildRequires:  ocaml-caml-mode
BuildRequires:  ocaml-csexp-devel >= 1.2.3
BuildRequires:  ocaml-dune >= 2.9.0
BuildRequires:  ocaml-easy-format-devel
BuildRequires:  ocaml-findlib-devel >= 1.6.0
BuildRequires:  ocaml-menhir
BuildRequires:  ocaml-odoc
BuildRequires:  ocaml-result-devel >= 1.5
BuildRequires:  ocaml-source
BuildRequires:  ocaml-yojson-devel >= 1.6.0
BuildRequires:  vim-enhanced
# Using git to apply the patches.
BuildRequires:  git

Requires:       dot-merlin-reader%{?_isa} = %{version}-%{release}

Recommends:     ocaml-source

%global _desc %{expand:
Merlin is an assistant for editing OCaml code.  It aims to provide the
features available in modern IDEs: error reporting, auto completion,
source browsing and much more.}

%description %_desc

You should also install a package that integrates with your editor of
choice, such as emacs-merlin or vim-merlin.

%package     -n dot-merlin-reader
Summary:        Merlin configuration file reader

%description -n dot-merlin-reader
This package contains a helper process that reads .merlin files and gives
the normalized content to merlin.

%package     -n emacs-merlin
Summary:        Context sensitive completion for OCaml in Emacs
BuildArch:      noarch
Requires:       ocaml-merlin = %{version}-%{release}
Requires:       emacs(bin) >= %{?_emacs_version}%{!?_emacs_version:0}
Requires:       emacs-caml-mode

Recommends:     emacs-auto-complete
Recommends:     emacs-company-mode
Recommends:     emacs-iedit
Recommends:     emacs-tuareg

%description -n emacs-merlin %_desc

This package contains the Emacs interface to merlin.

%package     -n vim-merlin
Summary:        Context sensitive completion for OCaml in Vim
BuildArch:      noarch
Requires:       ocaml-merlin = %{version}-%{release}
Requires:       vim-filesystem

%description -n vim-merlin %_desc

This package contains the Vim interface to merlin.

%prep
%autosetup -n %{srcname}-v%{version}-%{ocamlver} -N
cp %{SOURCE1} .gitignore
git init
git config user.email foo@example.com
git config user.name foo
git add .
git commit -a -q -m "%{version} baseline"
git am %{patches}


%build
dune build %{_smp_mflags}
dune build %{_smp_mflags} @doc

%install
dune install --destdir=%{buildroot}

# We do not want the dune markers
find _build/default/_doc/_html -name .dune-keep -delete

# We do not want the ml files
find %{buildroot}%{_libdir}/ocaml -name \*.ml -delete

# We install the documentation with the doc macro
rm -fr %{buildroot}%{_prefix}/doc

# Reinstall vim files to Fedora default location
mkdir -p %{buildroot}%{vimfiles_root}
mv %{buildroot}%{_datadir}/%{srcname}/vim/* %{buildroot}%{vimfiles_root}
rm -fr %{buildroot}%{_datadir}/%{srcname}

# Generate the autoload file for the Emacs interface and byte compile
cd %{buildroot}%{_emacs_sitelispdir}
emacs -batch --no-init-file --no-site-file \
  --eval "(progn (setq generated-autoload-file \"$PWD/merlin-autoloads.el\" backup-inhibited t) (update-directory-autoloads \".\"))"
mkdir -p %{buildroot}%{_emacs_sitestartdir}
mv merlin-autoloads.el %{buildroot}%{_emacs_sitestartdir}
%_emacs_bytecompile *.el
cd -

%check
# Tests partially fail with the OCaml 4.13 patches.  Hopefully
# will be fix by the time of the next release.
dune runtest ||:

%files
%doc featuremap.* CHANGES.md README.md
%license LICENSE
%{_bindir}/ocamlmerlin
%{_bindir}/ocamlmerlin-server
%{_libdir}/ocaml/%{srcname}/

%files -n dot-merlin-reader
%license LICENSE
%{_bindir}/dot-merlin-reader
%{_libdir}/ocaml/dot-merlin-reader/

%files -n emacs-merlin
%{_emacs_sitelispdir}/merlin*
%{_emacs_sitestartdir}/merlin-autoloads.el

%files -n vim-merlin
%{vimfiles_root}/*/*

%changelog
* Mon Oct 04 2021 Richard W.M. Jones <rjones@redhat.com> - 4.3.1-2
- OCaml 4.13.1 build

* Tue Jul 27 2021 Jerry James <loganjerry@gmail.com> - 4.3.1-1
- Version 4.3
- Drop upstreamed -emacs patch

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Apr 13 2021 Jerry James <loganjerry@gmail.com> - 4.2-1
- Version 4.2
- Drop upstreamed -iedit patch
- Add -emacs patch to fix various Emacs issues
- Add -textrel patch to fix FTBFS on i386

* Fri Mar 26 2021 Jerry James <loganjerry@gmail.com> - 4.1-2
- Fix tests on 64-bit systems with the -test-lib64 patch
- Add -emacs-iedit patch to adapt to recent iedit changes
- Build with auto-complete, company-mode, and caml-mode support
- Add subpackages: dot-merlin-reader, emacs-merlin, and vim-merlin
- Generate autoloads for the Emacs interface

* Mon Mar  1 2021 Richard W.M. Jones <rjones@redhat.com> - 4.1-1
- New upstream version 4.1.
- OCaml 4.12.0 build

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.7-0.4.preview1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Tue Sep 01 2020 Richard W.M. Jones <rjones@redhat.com> - 3.3.7-0.3.preview1
- OCaml 4.11.1 rebuild

* Fri Aug 21 2020 Richard W.M. Jones <rjones@redhat.com> - 3.3.7-0.2.preview1
- OCaml 4.11.0 rebuild

* Fri Aug  7 2020 Robin Lee <cheeselee@fedoraproject.org> - 3.3.7-0.1.preview1
- Update to 3.3.7-preview1

* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.4-3
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Sat Apr 18 2020 Robin Lee <cheeselee@fedoraproject.org> - 3.3.4-1
- Update to 3.3.4 final

* Tue Mar  3 2020 Robin Lee <cheeselee@fedoraproject.org> - 3.3.4-0.1.preview1
- Update to 3.3.4-preview1, supports OCaml 4.10 (BZ#1799817, BZ#1809312)

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Sun Dec  1 2019 Robin Lee <cheeselee@fedoraproject.org> - 3.3.3-1
- Release 3.3.3 (RHBZ#1778280)
- Fix Release tag (RHBZ#1777835)

* Sat Aug  3 2019 Robin Lee <cheeselee@fedoraproject.org> - 3.3.2-1
- Update to 3.3.2

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri Jun 28 2019 Robin Lee <cheeselee@fedoraproject.org> - 3.3.1-1
- Update to 3.3.1 (BZ#1703452)

* Sun Mar 31 2019 Robin Lee <cheeselee@fedoraproject.org> - 3.2.2-2
- Fix ocaml library path

* Fri Mar  1 2019 Robin Lee <cheeselee@fedoraproject.org> - 3.2.2-1
- Initial packaging