File optee-armada7k8k.spec of Package optee-os

#
# spec file for package optee-armada7k8k
#
# Copyright (c) 2019 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/
#


%define platform armada7k8k

%if "%{platform}" == "qemu-armv7a"
%define is_32bit 1
%else
%define is_32bit 0
%endif

Name:           optee-%{platform}
Version:        3.5.0
Release:        0
%define srcversion 3.5.0
Summary:        Trusted Execution Environment
License:        BSD-2-Clause AND BSD-3-Clause
Group:          System/Boot
Url:            https://github.com/OP-TEE/optee_os
Source:         https://github.com/OP-TEE/optee_os/archive/%{srcversion}.tar.gz#/optee_os-%{srcversion}.tar.gz
#!BuildIgnore: gcc-PIE
%if ! %{is_32bit}
BuildRequires:  cross-arm-none-gcc%{gcc_version}
%endif
BuildRequires:  fdupes
BuildRequires:  python
BuildRequires:  python-pycrypto
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{is_32bit}
ExclusiveArch:  armv7hl
%else
ExclusiveArch:  aarch64
%endif

%description
A Trusted Execution Environment (TEE) as companion to a non-secure OS
on Arm Cortex-A cores using the TrustZone technology.
For a general overview of OP-TEE, please see the Notice.md file.

%package devel
Summary:        Trusted Execution Environment -- development files
# No Requires needed, since this is about firmware
Group:          Development/Sources

%description devel
A Trusted Execution Environment (TEE) as companion to a non-secure OS
on Arm Cortex-A cores using the TrustZone technology.
For a general overview of OP-TEE, please see the Notice.md file.

This sub-package contains development files.

%if ! %{is_32bit}
%package devel-32bit
Summary:        Trusted Execution Environment -- development files
# No Requires needed, since this is about firmware
Group:          Development/Sources

%description devel-32bit
A Trusted Execution Environment (TEE) as companion to a non-secure OS
on Arm Cortex-A cores using the TrustZone technology.
For a general overview of OP-TEE, please see the Notice.md file.

This sub-package contains 32-bit development files.
%endif

%prep
%setup -q -n optee_os-%{srcversion}

%build
make %{?_smp_mflags} V=1 O=out NOWERROR=1 \
%if %{is_32bit}
     ARCH=arm \
     CROSS_COMPILE= \
%else
     ARCH=arm CFG_ARM64_core=y \
     CROSS_COMPILE32=arm-none-eabi- \
     CROSS_COMPILE64= \
%endif
%if "%{platform}" == "qemu-armv7a" || "%{platform}" == "qemu-armv8a"
     PLATFORM=vexpress \
%if "%{platform}" == "qemu-armv8a"
     PLATFORM_FLAVOR=qemu_armv8a \
%else
     PLATFORM_FLAVOR=qemu_virt \
%endif
%else
%if "%{platform}" == "hikey" || "%{platform}" == "hikey960"
     PLATFORM=hikey \
%if "%{platform}" == "hikey960"
     PLATFORM_FLAVOR=hikey960 \
%else
     PLATFORM_FLAVOR=hikey \
%endif
%else
%if "%{platform}" == "armada3700" || "%{platform}" == "armada7k8k"
     PLATFORM=marvell \
%if "%{platform}" == "armada3700"
     PLATFORM_FLAVOR=armada3700 \
%else
     PLATFORM_FLAVOR=armada7k8k \
%endif
%else
     PLATFORM=%{platform} \
%endif # marvell
%endif # hikey
%endif # qemu
     all

%install
export NO_BRP_STRIP_DEBUG=true
export NO_DEBUGINFO_STRIP_DEBUG=true
install -D -m 0644 out/core/tee-pager.bin %{buildroot}/boot/tee-pager.bin
install -D -m 0644 out/core/tee.bin %{buildroot}/boot/tee.bin
install -D -m 0644 out/core/tee-header_v2.bin %{buildroot}/boot/tee-header_v2.bin
install -D -m 0644 out/core/tee-pager_v2.bin %{buildroot}/boot/tee-pager_v2.bin
install -D -m 0644 out/core/tee-pageable_v2.bin %{buildroot}/boot/tee-pageable_v2.bin
%fdupes %{buildroot}/boot

for f in out/export-ta_arm*/scripts/*.py; do
  sed -i 's|^#!/usr/bin/env python|#!/usr/bin/python|' $f
done
mkdir -p %{buildroot}%{_usrsrc}/optee
cp -a -Rf out/export-ta_arm32 %{buildroot}%{_usrsrc}/optee/ta_arm32
%fdupes %{buildroot}%{_usrsrc}/optee/ta_arm32
%if ! %{is_32bit}
cp -a -Rf out/export-ta_arm64 %{buildroot}%{_usrsrc}/optee/ta_arm64
%fdupes %{buildroot}%{_usrsrc}/optee/ta_arm64
%endif

%files
%defattr(-,root,root)
%license LICENSE
%doc CHANGELOG.md MAINTAINERS README.md
/boot/tee-pager.bin
/boot/tee.bin
/boot/tee-header_v2.bin
/boot/tee-pager_v2.bin
/boot/tee-pageable_v2.bin

%files devel
%defattr(-,root,root)
%dir %{_usrsrc}/optee/
%if %{is_32bit}
%{_usrsrc}/optee/ta_arm32/
%else
%{_usrsrc}/optee/ta_arm64/
%endif

%if ! %{is_32bit}
%files devel-32bit
%defattr(-,root,root)
%dir %{_usrsrc}/optee/
%{_usrsrc}/optee/ta_arm32/
%endif

%changelog