#
# spec file for package libressl
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

%undefine _missing_build_ids_terminate_build
%define _ssldir          /etc/pki/tls
%global _hardened_build 1

Name:           libressl
Version:        3.8.1
Release:        1%{dist}
Summary:        An SSL/TLS protocol implementation
License:        OpenSSL
Group:          Development/Libraries/C and C++
Url:            http://libressl.org/

Source:         http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/%{name}-%{version}.tar.gz
Patch1:         libressl-rename-config-file.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?rhel} < 8
BuildRequires:  devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-build devtoolset-8-binutils
%else
BuildRequires:  gcc gcc-c++
%endif
%if %{?rhel} < 7
BuildRequires: autoconf2.69
%else
BuildRequires:  autoconf
%endif
BuildRequires:  pkgconfig
Requires:      %{name}-libs = %{version}-%{release}


%description
LibreSSL is an open-source implementation of the Secure Sockets Layer
(SSL) and Transport Layer Security (TLS) protocols. It derives from
OpenSSL, with the aim of refactoring the OpenSSL code so as to
provide a more secure implementation.

%package libs
Summary:        LibreSSL libraries
Group:          Development/Libraries/C and C++


%description libs

LibreSSL is an open-source implementation of the Secure Sockets Layer
(SSL) and Transport Layer Security (TLS) protocols. It derives from
OpenSSL, with the aim of refactoring the OpenSSL code so as to
provide a more secure implementation.

This subpackage contains libraries for applications
that want to make use of libressl.

%package devel
Summary:        Development files for LibreSSL, an SSL/TLS protocol implementation
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}-%{release}
Conflicts:      openssl-devel
Conflicts:      openssl3-devel

%description devel
LibreSSL is an open-source implementation of the Secure Sockets Layer
(SSL) and Transport Layer Security (TLS) protocols. It derives from
OpenSSL, with the aim of refactoring the OpenSSL code so as to
provide a more secure implementation.

This subpackage contains libraries and header files for developing
applications that want to make use of libressl.


%prep
%setup -q -n %{name}-%{version}
%patch1 -p1 -b .config


%build
%if 0%{?rhel} < 8
# We build using the devtoolset-8 compilers
%enable_devtoolset8
%endif
%if %{?rhel} < 7
. /etc/profile.d/modules.sh
module load autoconf
%endif

autoreconf -vfi

# Some smart people broke disable-static
%configure \
    --with-openssldir=%{_ssldir} \
    --libdir=%{_libdir}/libressl \
    --includedir=%{_includedir}/libressl \
    --program-suffix "-libre"

sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool


make %{?_smp_mflags}

%install
%make_install

rm -f %{buildroot}/etc/pki/tls/cert.pem
rm -f %{buildroot}/%{_libdir}/libressl/*.a
rm -f %{buildroot}/%{_libdir}/libressl/*.la
mkdir -p %{buildroot}/%{_sysconfdir}/ld.so.conf.d
echo '%{_libdir}/libressl' > %{buildroot}/%{_sysconfdir}/ld.so.conf.d/libressl.conf
find %{buildroot}/%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) -exec chmod 755 {} +

mv %{buildroot}%{_libdir}/libressl/pkgconfig %{buildroot}%{_libdir}/pkgconfig
pushd %{buildroot}%{_libdir}/libressl
for lib in ssl tls crypto
do
    ln -sf %{_libdir}/libressl/$(readlink lib${lib}.so) %{buildroot}%{_libdir}/lib${lib}.so
done


%post  libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig


%files
%defattr(-,root,root)
%config %{_sysconfdir}/ld.so.conf.d/libressl.conf
%{_bindir}/*-libre
%{_mandir}/man1/*.1*
%{_mandir}/man5/*.*
%{_mandir}/man8/*.*
%doc COPYING VERSION README.md

%files libs
%attr(0644,root,root) %config(noreplace) %{_ssldir}/libressl.cnf
%attr(0644,root,root) %config(noreplace) %{_ssldir}/x509v3.cnf
%{_libdir}/libressl/lib*.so*
%doc COPYING VERSION

%files devel
%defattr(-,root,root)
%{_includedir}/libressl/
%{_libdir}/libcrypto.so
%{_libdir}/libssl.so
%{_libdir}/libtls.so
%{_libdir}/pkgconfig/*.pc
%{_mandir}/man3/*

%changelog
* Tue Oct  3 2023 Raven <raven@sysadmins.ws> - 3.8.1-1
- update to 3.8.1
* Thu Mar 14 2019 Raven <raven@sysadmins.ws> - 2.8.3-1
- update to 2.8.3

* Tue Nov  6 2018 Raven <raven@sysadmins.ws> - 2.8.2-1
- update to 2.8.2

* Wed Aug  1 2018 Raven <raven@sysadmins.ws> - 2.6.5-1
- update to new upstream release 2.6.5

* Fri May  5 2017 Raven <raven@sysadmins.ws> - 2.5.4-1
- initial release