File mosml.spec of Package mosml
#
# spec file for package mosml
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2024 Tejas Guruswamy <tejas.guruswamy@opensuse.org>
#
# 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 https://bugs.opensuse.org/
#
%define base_version    2.10.1
%bcond_without  dynlibs
Name:           mosml
Version:        2.10.1+git20220702
Release:        0
Summary:        Moscow ML implementation of Standard ML
License:        GPL-2.0-only AND SMLNJ AND NonFree
Group:          Development/Languages/Other
URL:            https://www.mosml.org
Source0:        https://github.com/kfl/mosml/archive/ver-%{base_version}.tar.gz#/mosml-ver-%{base_version}.tar.gz
Source1:        standardml.xml
Patch0:         mosml-v2.10.1_git20220702.diff
Patch1:         mosml-rpm_opt_flags.patch
Patch2:         mosml-fix_autoconf.patch
Patch3:         mosml-fix_dynlibs.patch
Requires(post): shared-mime-info
Requires(postun): shared-mime-info
#Patch4:         mosml-malloc64.patch
BuildRequires:  gmp-devel
%if %{with dynlibs}
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  gd-devel
BuildRequires:  gdbm-devel
BuildRequires:  libmysqlclient-devel
BuildRequires:  libnsl-devel
BuildRequires:  libpng-devel
BuildRequires:  mosml
BuildRequires:  mosml-devel
BuildRequires:  postgresql-devel
BuildRequires:  zlib-devel
%endif
%description
Moscow ML is a light-weight implementation of Standard ML (SML), a
strict functional language widely used in teaching and research.
Version 2.01 implements the full SML language, including SML Modules,
and much of the SML Basis Library.
%package devel
Summary:        Header files, libraries and development documentation for %{name}
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}
%description devel
This package contains the header files, static libraries and development
documentation for %{name}. If you like to develop programs using %{name},
you will need to install %{name}-devel.
%prep
%setup -q -n mosml-ver-%{base_version}
%patch -P 0 -p1
%patch -P 1
%patch -P 2
%patch -P 3
#%#ifarch x86_64
#%#patch 4
#%#endif
%build
cd src
export RPM_OPT_FLAGS="%{optflags}"
export ARCHLIB="%{_lib}"
%make_build world PREFIX=%{_prefix}
#chmod +x launch/mosmlc
#chmod +x launch/mosmllex
#chmod +x mosmlyac/mosmlyac
%if %{with dynlibs}
cd dynlibs
pushd mregex/regex-0.12
  autoreconf -fiv || true
  automake -acfv || true
popd
pushd crypt
  %make_build all PREFIX=%{_prefix}
popd
%make_build all PREFIX=%{_prefix}
%endif
%install
cd src
%make_install PREFIX=%{_prefix}
%if %{with dynlibs}
cd dynlibs
%make_install PREFIX=%{_prefix}
%endif
chmod +x %{buildroot}%{_bindir}/camlrunm
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
cat >%{buildroot}%{_sysconfdir}/ld.so.conf.d/mosml.conf <<EOF
%{_libexecdir}/mosml
EOF
install -D -m0644 %{SOURCE1} %{buildroot}%{_datadir}/mime/packages/standardml.xml
%check
cd src
pushd test
%make_build current PREFIX=%{_prefix}
%make_build cleaned
diff cleaned-result cleaned-result.ok
popd
%if %{with dynlibs}
pushd dynlibs
pushd msocket
  %make_build test PREFIX=%{_prefix}
popd
%make_build test PREFIX=%{_prefix} > result
grep -a -v "Entering directory" result | grep -a -v "Leaving directory" | grep -a -v "^Moscow ML version" > cleaned-result
grep -a -v "Entering directory" result.ok | grep -a -v "Leaving directory" | grep -a -v "^Moscow ML version" > cleaned-result.ok
diff cleaned-result cleaned-result.ok || true
popd
%endif
%post
/sbin/ldconfig
%mime_database_post
%postun
/sbin/ldconfig
%mime_database_postun
%files
%{_bindir}/camlrunm
%{_bindir}/mosmlc
%{_bindir}/mosml
%{_prefix}/lib/mosml
%doc README install.txt roadmap
%docdir %{_datadir}/doc/mosml
%{_datadir}/doc/mosml
%config %{_sysconfdir}/ld.so.conf.d/mosml.conf
%{_datadir}/mime/packages/standardml.xml
%{_datadir}/mosml
%files devel
%{_bindir}/mosmllex
%{_bindir}/mosmlyac
%{_includedir}/mosml
%changelog