# The naming scheme in non-Mandriva-based distros %if 0%{!?mklibname:1} %define mklibname(ds) lib%{1}%{?2:%{2}}%{-s:-static}%{-d:-devel} %endif %if 0%{!?mkrel:1} %define mkrel(c) %{1}%{?dist} %endif %if 0%{?cmake_build:1} %define buildsystem cmake %else %define buildsystem make %endif %define major 21 %define x509major 7 %define cryptomajor 16 %define libname %mklibname %{name} %{major} %define libx509 %mklibname mbedx509_ %{x509major} %define libcrypto %mklibname mbedcrypto %{cryptomajor} %define libeverest %mklibname everest %define libp256m %mklibname p256m %define develname %mklibname %{name} -d Name: mbedtls # Please stay on LTS branch 3.6.x: # https://www.trustedfirmware.org/blog/mbed-tls-3-6-0-lts Version: 3.6.2 Release: %mkrel 1 Summary: Light-weight cryptographic and SSL/TLS library Group: System/Libraries License: ASL 2.0 URL: https://www.trustedfirmware.org/projects/mbed-tls/ Source0: https://github.com/Mbed-TLS/mbedtls/releases/download/v%{version}/%{name}-%{version}.tar.bz2 BuildRequires: gcc BuildRequires: cmake BuildRequires: make # Check: BuildRequires: pkgconfig(python3) BuildRequires: python3dist(jsonschema) BuildRequires: python3dist(jinja2) BuildRequires: perl BuildRequires: perl(open) # Documentation: BuildRequires: doxygen BuildRequires: graphviz %if 0%{?fedora} BuildRequires: python3dist(breathe) BuildRequires: pandoc %endif %description mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains mbed TLS programs. %package -n %{libname} Summary: mbed TLS library Group: System/Libraries %description -n %{libname} mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains the library itself. %package -n %{libx509} Summary: mbed TLS X509 library Group: System/Libraries %description -n %{libx509} mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains mbed X509 library. %package -n %{libcrypto} Summary: mbed crypto library Group: System/Libraries %description -n %{libcrypto} mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains mbed mbedcrypto library. %if "%{buildsystem}" == "cmake" %package -n %{libeverest} Summary: mbed everest library Group: System/Libraries %description -n %{libeverest} mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains mbed everest library. %package -n %{libp256m} Summary: mbed p256m library Group: System/Libraries %description -n %{libp256m} mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains mbed p256m library. %endif %package -n %{develname} Summary: mbed TLS development files Group: Development/C Requires: %{libname} = %{version}-%{release} Requires: %{libx509} = %{version}-%{release} Requires: %{libcrypto} = %{version}-%{release} Provides: %{name}-devel = %{version}-%{release} %description -n %{develname} mbed TLS (formerly known as PolarSSL) is an SSL library written in ANSI C. mbed TLS makes it easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products with as little hassle as possible. It is designed to be readable, documented, tested, loosely coupled and portable. This package contains development files. %prep %autosetup -p1 # Enable MBEDTLS_THREADING_PTHREAD and MBEDTLS_THREADING_C flags # https://bugs.mageia.org/show_bug.cgi?id=15391#c4 sed -i -e 's|.*\(#define MBEDTLS_THREADING_C\)|\1|' \ -e 's|.*\(#define MBEDTLS_THREADING_PTHREAD\)|\1|' \ include/mbedtls/mbedtls_config.h %build %if "%{buildsystem}" == "cmake" %cmake \ -DUSE_SHARED_MBEDTLS_LIBRARY=ON \ -DMBEDTLS_FATAL_WARNINGS=OFF %cmake_build %else sed -i -e 's,^DESTDIR=.*$,DESTDIR=%{buildroot}%{_prefix},g' Makefile %make_build CFLAGS=-g SHARED=1 %endif # Use doxygen to generate API documentation. %if 0%{?fedora} cd docs && %make_build breathe_apidoc && mv _build/html . && rm -rf ../apidoc api requirements* _build && find . -path '*/*/Makefile' -exec sh -c 'cd $(dirname "{}") && %make_build html && rm -f Makefile *.md' \; || true %define develdocname docs %else %make_build apidoc && rm -rf apidoc/xml && find apidoc -name '*.md5' -exec rm -f '{}' \; %define develdocname apidoc %endif %check %if "%{buildsystem}" == "cmake" # One test fails %ctest || true %else %{__make} check PYTHON=%{__python3} %endif %install %if "%{buildsystem}" == "cmake" %cmake_install %else %make_install DESTDIR="%{buildroot}%{_prefix}" # The Makefile installs to /lib, but move to /lib64 on 64-bit systems. if test "%{buildroot}%{_prefix}/lib" != "%{buildroot}%{_libdir}"; then mv -f "%{buildroot}%{_prefix}/lib" "%{buildroot}%{_libdir}" fi %endif # prevent possible file clashes %if "%{buildsystem}" == "cmake" pushd %{buildroot}%{_bindir} for i in *; do mv ${i} %{name}_${i}; done popd %endif rm -f %{buildroot}%{_libdir}/*.a %if "%{buildsystem}" != "cmake" find %{buildroot} -name 'debug' -exec rm -rf '{}' \; %endif %files %doc ChangeLog README* %{_bindir}/%{name}_* %files -n %{libname} %license LICENSE %{_libdir}/lib%{name}.so.%{major} %if "%{buildsystem}" == "cmake" %{_libdir}/lib%{name}.so.%{version} %endif %files -n %{libx509} %{_libdir}/libmbedx509.so.%{x509major} %if "%{buildsystem}" == "cmake" %{_libdir}/libmbedx509.so.%{version} %endif %files -n %{libcrypto} %{_libdir}/libmbedcrypto.so.%{cryptomajor} %if "%{buildsystem}" == "cmake" %{_libdir}/libmbedcrypto.so.%{version} %endif %if "%{buildsystem}" == "cmake" %files -n %{libeverest} %{_libdir}/libeverest.so %files -n %{libp256m} %{_libdir}/libp256m.so %endif %files -n %{develname} %{_includedir}/%{name}/ %{_includedir}/psa/ %if "%{buildsystem}" == "cmake" %{_includedir}/everest/ %{_libdir}/pkgconfig/mbed*.pc %{_libdir}/cmake/MbedTLS/*.cmake %endif %{_libdir}/libmbed*.so %doc %{develdocname}