File ocaml.spec of Package ocaml
#
# spec file for package ocaml
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2010 Andrew Psaltis <ampsaltis at gmail dot com>
# Copyright (c) 2011 Andrew Psaltis <ampsaltis at gmail dot com>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define doc_version 4.03
#
%define do_opt 0
# This ensures that the find_provides/find_requires calls ocamlobjinfo correctly.
%global __ocaml_requires_opts -c -f "%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo"
%global __ocaml_provides_opts -f "%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo"
# macros to be set in prjconf:
#Macros:
#_with_ocaml_force_enable_ocaml_opt 1
#_with_ocaml_force_disable_ocaml_opt 1
#_with_ocaml_make_testsuite 1
%bcond_with ocaml_force_enable_ocaml_opt
%bcond_with ocaml_force_disable_ocaml_opt
%bcond_with ocaml_make_testsuite
%if %{with ocaml_force_enable_ocaml_opt}
%define do_opt 1
%endif
%if %{without ocaml_force_enable_ocaml_opt}
%ifarch %arm aarch64 %ix86 ppc ppc64 ppc64le s390x x86_64
%define do_opt 1
%endif
%endif
#
%if %{with ocaml_force_disable_ocaml_opt}
%define do_opt 0
%endif
Name: ocaml
Version: 4.03.0
Release: 0
Summary: The Objective Caml Compiler and Programming Environment
License: QPL-1.0 and SUSE-LGPL-2.0-with-linking-exception
Group: Development/Languages/Other
Url: http://caml.inria.fr/
#
# http://caml.inria.fr/pub/distrib/
Source0: http://caml.inria.fr/pub/distrib/ocaml-%{doc_version}/ocaml-%{version}.tar.xz
Source1: ocaml-findlib.rpm.prov_req.attr.sh
Source2: ocaml-%{doc_version}-refman-html.tar.xz
Source3: ocaml-%{doc_version}-refman.info.tar.xz
Source4: rpmlintrc
Source99: update_ocaml_deps.sh
Patch0: ocaml-3.00-camldebug_el.patch
Patch2: ocaml-3.04-ocamltags--no-site-start.patch
# FIX-UPSTREAM pass RPM_OPT_FLAGS to build
Patch4: ocaml-configure-Allow-user-defined-C-compiler-flags.patch
Patch5: ocaml-3.08.3-gcc4.patch
Patch7: ocaml-3.09-emacs_localcompile.patch
# This gets ocamlobjinfo to work with .cmxs files
BuildRequires: binutils-devel
BuildRequires: emacs-nox
BuildRequires: fdupes
BuildRequires: ncurses-devel
BuildRequires: pkg-config
BuildRequires: pkgconfig(x11)
Requires(post): %{install_info_prereq}
Requires(pre): %{install_info_prereq}
Provides: ocaml(compiler) = %{version}
Requires: ocaml(runtime) = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# ocaml autodep start for pkg: ocaml
# hardcoded rpm dependency for pre 12.1 to compensate for lack of ocaml() provides/requires
%if 0%{?suse_version} < 1210
Requires: ocaml-runtime
%endif
# ocaml autodep end for pkg: ocaml
%if %{do_opt}
Requires: gcc
Provides: ocaml(ocaml.opt) = %{version}
%endif
%description
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.
This package comprises two batch compilers (a fast bytecode compiler
and an optimizing native-code compiler), an interactive top level
system, Lex&Yacc tools, a replay debugger, and a comprehensive library.
%package rpm-macros
Summary: RPM macros for building OCaml source packages
License: QPL-1.0 and SUSE-LGPL-2.0-with-linking-exception
Group: Development/Languages/Other
%description rpm-macros
A set of helper macros to unify common code used in ocaml spec files.
%package runtime
# ocaml autodep start for pkg: ocaml-runtime
# hardcoded rpm dependency for pre 12.1 to compensate for lack of ocaml() provides/requires
%if 0%{?suse_version} < 1210
Requires: ocaml-compiler-libs
%endif
# ocaml autodep end for pkg: ocaml-runtime
Summary: The Objective Caml Compiler and Programming Environment
License: QPL-1.0
Group: Development/Languages/Other
Provides: ocaml(runtime) = %{version}-%{release}
%description runtime
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.
This package contains the runtime environment needed to run Objective
Caml bytecode.
%package source
Summary: Source code for Objective Caml libraries
License: QPL-1.0 and SUSE-LGPL-2.0-with-linking-exception
Group: Development/Languages/Other
%description source
Source code for Objective Caml libraries.
%package x11
# ocaml autodep start for pkg: ocaml-x11
# hardcoded rpm dependency for pre 12.1 to compensate for lack of ocaml() provides/requires
%if 0%{?suse_version} < 1210
Requires: ocaml-runtime
%endif
# ocaml autodep end for pkg: ocaml-x11
Summary: X11 support for Objective Caml
License: SUSE-LGPL-2.0-with-linking-exception
Group: System/Libraries
%description x11
X11 support for Objective Caml.
%package ocamldoc
# ocaml autodep start for pkg: ocaml-ocamldoc
# hardcoded rpm dependency for pre 12.1 to compensate for lack of ocaml() provides/requires
%if 0%{?suse_version} < 1210
Requires: ocaml-compiler-libs
Requires: ocaml-runtime
%endif
# ocaml autodep end for pkg: ocaml-ocamldoc
Summary: The Objective Caml Compiler and Programming Environment
License: QPL-1.0
Group: Development/Languages/Other
Requires: ocaml = %{version}
%description ocamldoc
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.
This package contains a documentation generator for Objective Caml.
%package emacs
Summary: The Objective Caml Compiler and Programming Environment
License: GPL-2.0+
Group: Development/Languages/Other
Requires: emacs
Requires: ocaml = %{version}
Provides: caml-mode
%description emacs
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.
This package provides caml-mode for emacs
%package docs
Summary: The Objective Caml Compiler and Programming Environment
License: GPL-2.0+ and QPL-1.0
Group: Development/Languages/Other
Requires: ocaml = %{version}
%description docs
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.
This package comprises two batch compilers (a fast bytecode compiler
and an optimizing native-code compiler), an interactive top level
system, Lex&Yacc tools, a replay debugger, and a comprehensive library.
%package compiler-libs
# ocaml autodep start for pkg: ocaml-compiler-libs
# hardcoded rpm dependency for pre 12.1 to compensate for lack of ocaml() provides/requires
%if 0%{?suse_version} < 1210
Requires: ocaml-runtime
%endif
# ocaml autodep end for pkg: ocaml-compiler-libs
Requires: ncurses-devel
Summary: Libraries used internal to the OCaml Compiler
License: QPL-1.0
Group: Development/Libraries/Other
%description compiler-libs
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.
This package contains several modules used internally by the OCaml
compilers. They are not needed for normal OCaml development, but may
be helpful in the development of certain applications.
%package compiler-libs-devel
# ocaml autodep start for pkg: ocaml-compiler-libs
# hardcoded rpm dependency for pre 12.1 to compensate for lack of ocaml() provides/requires
%if 0%{?suse_version} < 1210
Requires: ocaml-runtime
%endif
# ocaml autodep end for pkg: ocaml-compiler-libs
Summary: Libraries used internal to the OCaml Compiler
License: QPL-1.0
Group: Development/Libraries/Other
Requires: ocaml-compiler-libs = %{version}
%description compiler-libs-devel
The %{name}-devel package contains libraries and signature files for
developing applications that use %{name}.
%prep
: do_opt %{do_opt}
%setup -q -a 2 -a 3
%patch0 -p1
%patch2 -p1
%patch4 -p1
%patch5
%patch7
%build
%ifarch %ix86
# Default OPT flags for these architectures use -fomit-frame-pointer,
# which gets in the way of some of the profiling done within.
OUR_OPT_FLAGS="`echo '%{optflags}' | sed 's/-fomit-frame-pointer//g'`"
%else
OUR_OPT_FLAGS="%{optflags}"
%endif
CFLAGS="$OUR_OPT_FLAGS -DUSE_INTERP_RESULT" \
./configure -bindir %{_bindir} \
-libdir %{_libdir}/ocaml \
-mandir %{_mandir} \
-x11include %{_includedir} \
-x11lib %{_libdir}
%if %{do_opt}
make world.opt \
%else
make world \
%endif
BYTECCRPATH= \
NATIVECCRPATH= \
MKSHAREDLIBRPATH=
%install
make install \
DESTDIR="%{buildroot}"
export EMACS_SITE_LISP=%{_datadir}/emacs/site-lisp
install -d %{buildroot}%{_infodir} \
%{buildroot}${EMACS_SITE_LISP}
(
cd emacs
make install DESTDIR=%{buildroot} EMACSDIR=%{buildroot}${EMACS_SITE_LISP}
make install-ocamltags SCRIPTDIR=%{buildroot}${EMACS_SITE_LISP}
)
(
cd infoman; cp -f ocaml* %{buildroot}%{_infodir}
)
# fix bnc#411232
echo '(load "ocaml.el" nil t t)' >%{buildroot}${EMACS_SITE_LISP}/suse-start-ocaml.el
tee %{buildroot}${EMACS_SITE_LISP}/%{name}.el <<EOF
(autoload 'caml-mode "caml" "Caml editing mode" t)
(add-hook 'caml-mode-hook 'font-lock-mode)
(add-to-list 'auto-mode-alist '("\\\\.mli?$" . caml-mode))
EOF
export EXCLUDE_FROM_STRIP="ocamldebug ocamlbrowser"
# Install the compiler libs
install -d %{buildroot}%{_libdir}/ocaml/compiler-libs
cp -a typing/ utils/ parsing/ %{buildroot}%{_libdir}/ocaml/compiler-libs
%fdupes %{buildroot}
# rpmlint ...
chmod -v a+x %{buildroot}%{_libdir}/ocaml/camlheader
# preserve .cmxs and .so
find %{buildroot} \( \
-name '*.a' -o \
-name '*.cma' -o \
-name '*.cmi' -o \
-name '*.cmo' -o \
-name '*.cmt' -o \
-name '*.cmti' -o \
-name '*.cmx' -o \
-name '*.cmxa' -o \
-name '*.conf' -o \
-name '*.h' -o \
-name '*.hva' -o \
-name '*.ml' -o \
-name '*.mli' -o \
-name '*.mll' -o \
-name '*.mlp' -o \
-name '*.mly' -o \
-name '*.o' -o \
-name '*.sml' \
\) -type f -exec chmod -v a-x "{}" \;
mkdir -vp %{buildroot}%{_sysconfdir}/rpm
tee %{buildroot}%{_sysconfdir}/rpm/macros.%{name} <<'_EOF_'
# get rid of /usr/lib/rpm/find-debuginfo.sh
# strip kills the bytecode part of ELF binaries
%if %{do_opt}
%%ocaml_preserve_bytecode \
%%{nil}
%%ocaml_native_compiler 1
%else
%%ocaml_preserve_bytecode \
%%undefine _build_create_debug \
%%define __arch_install_post export NO_BRP_STRIP_DEBUG=true \
%%{nil}
%%ocaml_native_compiler 0
%endif
# setup.ml comes from oasis, but this is here for libs oasis depends on
#
# html goes into a separate, browsable dir
# which is also safe regarding wiping due to %%doc macro usage
%%_oasis_docdir_base %%{_datadir}/doc/ocaml
%%_oasis_docdir_dvi %%{_oasis_docdir_base}/%%{name}
%%_oasis_docdir_html %%{_oasis_docdir_base}/%%{name}
%%_oasis_docdir_pdf %%{_oasis_docdir_base}/%%{name}
%%_oasis_docdir_ps %%{_oasis_docdir_base}/%%{name}
%%oasis_docdir %%{_oasis_docdir_base}/%%{name}
#
# For now provide a convinience macro which covers also the parent dir
%%oasis_docdir_dvi %%dir %%{_oasis_docdir_base} \
%%{_oasis_docdir_dvi}
%%oasis_docdir_html %%dir %%{_oasis_docdir_base} \
%%{_oasis_docdir_html}
%%oasis_docdir_pdf %%dir %%{_oasis_docdir_base} \
%%{_oasis_docdir_pdf}
%%oasis_docdir_ps %%dir %%{_oasis_docdir_base} \
%%{_oasis_docdir_ps}
#
# various macros to unify setup/build/install
%%oasis_setup \
oasis setup
%%ocaml_oasis_configure \
ocaml setup.ml -configure \\\
--psdir %%{_oasis_docdir_ps} \\\
--pdfdir %%{_oasis_docdir_pdf} \\\
--dvidir %%{_oasis_docdir_dvi} \\\
--htmldir %%{_oasis_docdir_html} \\\
--docdir %%{oasis_docdir} \\\
--localedir %%{_datadir}/locale \\\
--datadir %%{_datadir} \\\
\\\
--bindir %%{_bindir} \\\
--mandir %%{_mandir} \\\
--destdir %%{buildroot} \\\
--datarootdir %%{_datadir} \\\
--infodir %%{_infodir} \\\
--libdir %%{_libdir} \\\
--libexecdir %%{_libexecdir} \\\
--localstatedir %%{_localstatedir} \\\
--sbindir %%{_sbindir} \\\
--prefix %%{_prefix} \\\
--sysconfdir %%{_sysconfdir} \\\
--exec-prefix %%{_exec_prefix} \\\
--sharedstatedir %%{_sharedstatedir}
#
%%ocaml_oasis_build \
ocaml setup.ml -build
%%ocaml_oasis_doc \
ocaml setup.ml -doc
%%ocaml_oasis_install \
ocaml setup.ml -install
%%ocaml_oasis_findlib_install \
export OCAMLFIND_DESTDIR=%%{buildroot}`ocamlc -where` ; \
export OCAMLFIND_LDCONF=/dev/null ; \
mkdir -p $OCAMLFIND_DESTDIR ; \
ocaml setup.ml -install
%%ocaml_oasis_test \
ocaml setup.ml -test
#
#
_EOF_
#
%if "%{?_rpmconfigdir}" == ""
%define _rpmconfigdir /usr/lib/rpm
%endif
: _rpmconfigdir %{_rpmconfigdir}
tag="ocamlfind"
mkdir -vp %{buildroot}%{_rpmconfigdir}/fileattrs
tee %{buildroot}%{_rpmconfigdir}/fileattrs/${tag}.attr <<_EOF_
%__${tag}_provides %%{_rpmconfigdir}/${tag}.sh -prov
%__${tag}_requires %%{_rpmconfigdir}/${tag}.sh -req
%__${tag}_path ^%%{_libdir}/ocaml/.*/META$|^%%{_libdir}/ocaml/META$
_EOF_
#
tee %{buildroot}%{_rpmconfigdir}/${tag}.sh < %{S:1}
%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%postun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%files
%defattr(-,root,root)
%doc Changes LICENSE
%{_rpmconfigdir}/fileattrs
%attr(755,root,root) %{_rpmconfigdir}/*.sh
%{_bindir}/*
%{_mandir}/*/*
%{_libdir}/ocaml/*.a
%if %{do_opt}
%{_libdir}/ocaml/*.cmxs
%{_libdir}/ocaml/*.cmxa
%{_libdir}/ocaml/*.cmx
%{_libdir}/ocaml/*.o
%endif
%{_libdir}/ocaml/*.mli
%{_libdir}/ocaml/libcamlrun_shared.so
%if %{do_opt}
%{_libdir}/ocaml/libasmrun_shared.so
%endif
%{_libdir}/ocaml/vmthreads/*.mli
%{_libdir}/ocaml/vmthreads/*.a
%if %{do_opt}
%{_libdir}/ocaml/threads/*.a
%{_libdir}/ocaml/threads/*.cmxa
%{_libdir}/ocaml/threads/*.cmx
%endif
%{_libdir}/ocaml/caml
%{_libdir}/ocaml/Makefile.config
%{_libdir}/ocaml/VERSION
%{_libdir}/ocaml/extract_crc
%{_libdir}/ocaml/camlheader
%{_libdir}/ocaml/camlheader_ur
%{_libdir}/ocaml/expunge
%{_libdir}/ocaml/ld.conf
%{_libdir}/ocaml/objinfo_helper
%exclude %{_libdir}/ocaml/graphicsX11.mli
%{_infodir}/*
%exclude %{_bindir}/ocamlrun
%exclude %{_bindir}/ocamldoc*
%exclude %{_libdir}/ocaml/ocamldoc
%files rpm-macros
%defattr(-,root,root,-)
%dir %{_sysconfdir}/rpm
%config %{_sysconfdir}/rpm/*
%files runtime
%defattr(-,root,root,-)
%{_bindir}/ocamlrun
%dir %{_libdir}/ocaml
%{_libdir}/ocaml/*.cmo
%{_libdir}/ocaml/*.cmi
%{_libdir}/ocaml/*.cmt
%{_libdir}/ocaml/*.cmti
%{_libdir}/ocaml/*.cma
%{_libdir}/ocaml/stublibs
%dir %{_libdir}/ocaml/vmthreads
%{_libdir}/ocaml/vmthreads/*.cmi
%{_libdir}/ocaml/vmthreads/*.cma
%dir %{_libdir}/ocaml/threads
%{_libdir}/ocaml/threads/*.cmi
%{_libdir}/ocaml/threads/*.cma
%exclude %{_libdir}/ocaml/graphicsX11.cmi
%doc LICENSE Changes
%files x11
%defattr(-,root,root,-)
%{_libdir}/ocaml/graphicsX11.cmi
%{_libdir}/ocaml/graphicsX11.mli
%files source
%defattr(-,root,root,-)
%{_libdir}/ocaml/*.ml
%files ocamldoc
%defattr(-,root,root,-)
%{_bindir}/ocamldoc*
%{_libdir}/ocaml/ocamldoc
%doc ocamldoc/Changes.txt
%files docs
%defattr(-,root,root,-)
%doc htmlman
%files emacs
%defattr(-,root,root,-)
%doc emacs/README
%dir %{_datadir}/emacs
%dir %{_datadir}/emacs/site-lisp
%{_datadir}/emacs/site-lisp/*
%files compiler-libs
%defattr(-,root,root,-)
%doc LICENSE
%{_libdir}/ocaml/compiler-libs
%if %{do_opt}
%exclude %{_libdir}/ocaml/compiler-libs/*.cmx
%exclude %{_libdir}/ocaml/compiler-libs/*.o
%exclude %{_libdir}/ocaml/compiler-libs/*/*.cmx
%exclude %{_libdir}/ocaml/compiler-libs/*/*.o
%endif
%exclude %{_libdir}/ocaml/compiler-libs/*/*.mli
%exclude %{_libdir}/ocaml/compiler-libs/*/*.ml
%files compiler-libs-devel
%defattr(-,root,root,-)
%doc LICENSE
%if %{do_opt}
%{_libdir}/ocaml/compiler-libs/*.cmx
%{_libdir}/ocaml/compiler-libs/*.o
%{_libdir}/ocaml/compiler-libs/*/*.cmx
%{_libdir}/ocaml/compiler-libs/*/*.o
%endif
%{_libdir}/ocaml/compiler-libs/*/*.ml
%{_libdir}/ocaml/compiler-libs/*/*.mli
%if %{with ocaml_make_testsuite}
%check
make %{?_smp_mflags} -C testsuite clean
if make -C testsuite all
then
: passed
else
: failed
fi
%endif
%changelog