File openssl.spec of Package openssl

#
# spec file for package openssl
#
# Copyright (c) 2025 SUSE LLC
#
# 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 sover 3

# For MAGEIA Only; This MACRO is non-existing there
%if 0%{?mageia}
%define _mandir %{_datadir}/man/
%endif
#


Name:           openssl
Version:        3.5.0
Release:        0
Summary:        Toolkit for secure SSL/TLS, cryptography, and certificate management

License:        Apache-2.0
URL:            https://www.openssl.org/
Source0:        https://github.com/openssl/openssl/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz

BuildRequires:  fdupes
BuildRequires:  gcc  glibc
BuildRequires:  make
BuildRequires:  perl
BuildRequires:  perl(Pod::Man)
BuildRequires:  perl(Pod::ParseLink)
BuildRequires:  perl(Pod::Text)
BuildRequires:  perl(Test::Harness)
# Only for FEDORA / MAGEIA
%if 0%{?fedora} || 0%{?mageia}
BuildRequires:  perl-podlators
%endif
#
BuildRequires:  pkgconfig
# For SUSE Leap 15.6 (and older) / MAGEIA
%if 0%{?sle_version} == 150600 && 0%{?is_opensuse} || 0%{?sle_version} == 150500 && 0%{?is_opensuse} || 0%{?mageia}
BuildRequires:  pkgconfig(zlib)
#
# For SUSE TumbleWeed / FEDORA
%else
BuildRequires:  zlib-ng-compat-devel
#
%endif

Provides:       c_rehash

Conflicts:      openssl-3

%description
OpenSSL is a robust, full-featured open source toolkit that implements
the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols,
as well as a powerful general-purpose cryptography library.
It provides a rich set of cryptographic algorithms, including symmetric ciphers,
public key cryptography, cryptographic hash functions, HMAC, and digital signatures.

OpenSSL also includes command-line tools for performing cryptographic operations,
managing certificates, and debugging SSL/TLS connections,
making it an indispensable component for secure communications on the Internet and in private networks.
It is widely used for securing web servers, client-server applications, VPNs,
and a variety of system and network services. OpenSSL is designed to be standards-compliant,
highly portable, and is used as the foundation for many security-related applications and libraries.

%package devel
Summary:        Development files for OpenSSL

Requires:       %{name} = %{version}
Requires:       pkgconfig
Requires:       perl
Requires:       zlib-ng-compat-devel

Provides:       lib%{name}-devel

%description devel
The OpenSSL development package provides the libraries, header files, and other resources necessary
for building applications that leverage the OpenSSL cryptographic library and its SSL/TLS protocols.
This package includes C header files, static and shared libraries,
and development utilities required for compiling, linking,
and integrating OpenSSL support into custom software.
It is intended for developers who want to create or maintain applications that require secure communication,
data encryption, certificate management, or other cryptographic operations using OpenSSL's robust API.

%prep
%autosetup

%build
# Figure out which flags we want to use.
# Defaults
sslarch=%{_os}-%{_target_cpu}
%ifarch %ix86
sslarch=linux-elf
if ! echo %{_target} | grep -qE 'i686|i586' ; then
	sslflags="no-asm 386"
fi
%endif
%ifarch x86_64
sslarch=linux-x86_64
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch sparcv9
sslarch=linux-sparcv9
sslflags=no-asm
%endif
%ifarch sparc64
sslarch=linux64-sparcv9
sslflags=no-asm
%endif
%ifarch alpha alphaev56 alphaev6 alphaev67
sslarch=linux-alpha-gcc
%endif
%ifarch s390 sh3eb sh4eb
sslarch="linux-generic32 -DB_ENDIAN"
%endif
%ifarch s390x
sslarch="linux64-s390x"
%endif
%ifarch %{arm}
sslarch=linux-armv4
%endif
%ifarch aarch64
sslarch=linux-aarch64
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch sh3 sh4
sslarch=linux-generic32
%endif
%ifarch ppc64 ppc64p7
sslarch=linux-ppc64
%endif
%ifarch ppc64le
sslarch="linux-ppc64le"
#POWER8 support
#sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch mips mipsel
sslarch="linux-mips32 -mips32r2"
%endif
%ifarch mips64 mips64el
sslarch="linux64-mips64 -mips64r2"
%endif
%ifarch mips64el
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch riscv64
sslarch=linux64-riscv64
%endif
ktlsopt=enable-ktls
%ifarch armv7hl
ktlsopt=disable-ktls
%endif
#
./Configure                                   \
    ${sslarch}  ${sslflags}  ${ktlsopt}       \
    enable-camellia                          \
%ifarch x86_64 aarch64 ppc64le
    enable-ec_nistp_64_gcc_128               \
%endif
    enable-ktls                              \
    enable-pie                               \
    enable-rfc3779                           \
    enable-seed                              \
    no-afalgeng                              \
    no-atexit                                \
    no-ec2m                                  \
    no-mdc2                                  \
    shared zlib                              \
    --prefix=%{_prefix}                      \
    --libdir=%{_lib}                         \
    --openssldir=%{_sysconfdir}/ssl/         \
    %{optflags}                              \
    %{?cflags_livepatching}                  \
    -Wa,--noexecstack                        \
    -Wl,-z,relro,-z,now                      \
    -ffat-lto-objects                        \
    -fno-common                              \
    -DTERMIO                                 \
    -DPURIFY                                 \
    -D_GNU_SOURCE                            \
    -DOPENSSL_PEDANTIC_ZEROIZATION           \
   '-DSUSE_OPENSSL_RELEASE="\"%{release}\""' \
    -DOPENSSL_NO_BUF_FREELISTS               \
    $(getconf LFS_CFLAGS)                    \
    -Wall

# Show build configuration
perl configdata.pm --dump
#

make %{?_smp_mflags}

%make_build

%install
%make_install

# Rename and re-link Shared Objects from primary /.so.${version} file to RUNTIME + DEVEL files
rename so.%{sover} so.%{version} %{buildroot}/%{_libdir}/*.so.%{sover}
for lib in %{buildroot}/%{_libdir}/*.so.%{version} ; do
    chmod 755 ${lib}
    ln -fs $(basename ${lib}) %{buildroot}/%{_libdir}/$(basename ${lib} .%{version})
    ln -fs $(basename ${lib}) %{buildroot}/%{_libdir}/$(basename ${lib} .%{version}).%{sover}
done
#
# Move Non-Configuration Files from /etc/ to /usr/libexec/ Directory
mkdir -p %{buildroot}/%{_libexecdir}/%{name}/
mv    -f %{buildroot}/%{_sysconfdir}/ssl/misc/* -t %{buildroot}/%{_libexecdir}/%{name}/
#
# Fix shebang lines for Perl scripts to use directly /usr/bin/perl instead of /usr/bin/env perl
sed -i '1s|#!/usr/bin/env perl|#!/usr/bin/perl|' "%{buildroot}/%{_libexecdir}/%{name}/CA.pl"
sed -i '1s|#!/usr/bin/env perl|#!/usr/bin/perl|' "%{buildroot}/%{_libexecdir}/%{name}/tsget.pl"
sed -i '1s|#!/usr/bin/env perl|#!/usr/bin/perl|' "%{buildroot}/%{_bindir}/c_rehash"
#
# Remove the Extra `*.cnf.dist` Files
rm -f %{buildroot}/%{_sysconfdir}/ssl/{ct_log_list,openssl}.cnf.dist
#
# For SUSE Only - ${_docdir} Defines into /usr/share/doc/packages/ in SUSE
%if 0%{?suse_version} && 0%{?is_opensuse}
mkdir -p  %{buildroot}/%{_docdir}/
mv    -f "%{buildroot}/%{_datadir}/doc/%{name}/" -t %{buildroot}/%{_docdir}/
%endif
#

%check
make test

%fdupes %{buildroot}/%{_prefix}/

%post
ldconfig

%postun
ldconfig

%files
%license "LICENSE.txt"

%doc     "ACKNOWLEDGEMENTS.md" "AUTHORS.md" "CONTRIBUTING.md" "README.md" "CHANGES.md" "HACKING.md" "NEWS.md"

                   "%{_sysconfdir}/ssl/"
%config(noreplace) "%{_sysconfdir}/ssl/ct_log_list.cnf"
%config(noreplace) "%{_sysconfdir}/ssl/%{name}.cnf"

 %{_bindir}/%{name}
"%{_bindir}/c_rehash"

 %{_docdir}/%{name}/

 %{_libexecdir}/%{name}/

 %{_libdir}/lib*.so.*
"%{_libdir}/engines-3/"
"%{_libdir}/ossl-modules/"

 %{_mandir}/man1/*
 %{_mandir}/man5/*
 %{_mandir}/man7/*

%files devel
%doc  NOTES*.md "CONTRIBUTING.md" "HACKING.md"

      %{_includedir}/%{name}/

%dir "%{_libdir}/cmake/"
     "%{_libdir}/cmake/OpenSSL/"
      %{_libdir}/lib*.a
      %{_libdir}/lib*.so
      %{_libdir}/pkgconfig/*.pc

      %{_mandir}/man3/*

%changelog
openSUSE Build Service is sponsored by