File u-boot.spec of Package u-boot

#
# spec file for package u-boot
#
# Copyright (c) 2024 Siemens AG
#
# 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 target @BUILD_FLAVOR@

%if "%{target}" == "tools"
%define tools_only 1
%define defconfig defconfig syncconfig
%else
%if "%target" == "qemuarm64"
%define is_armv8 1
%define defconfig qemu_arm64_defconfig
%else
%if "%target" == "qemux86"
%define is_x86 1
%define defconfig qemu-x86_defconfig
%else
ExclusiveArch:  do_not_build
BuildRequires:  no-target-defined
%endif
%endif
%endif

%if %{?is_armv8}
ExclusiveArch:  aarch64
%endif
%if %{?is_x86}
ExclusiveArch:  %ix86
%endif

%bcond_with crosscompile

Name:           u-boot-%target
Version:        2024.10
Release:        0
%if 0%{?tools_only}
Summary:        The U-Boot firmware for the %target platform
%else
Summary:        The U-Boot tools
%endif
License:        GPL-2.0-only
Group:          System/Boot
URL:            http://www.denx.de/wiki/U-Boot
Source:         http://ftp.denx.de/pub/u-boot/u-boot-%{version}.tar.bz2
Source1:        http://ftp.denx.de/pub/u-boot/u-boot-%{version}.tar.bz2.sig
#
BuildRequires:  bc
BuildRequires:  bison
# Arndale board needs DTC >= 1.4
BuildRequires:  flex
BuildRequires:  pkgconfig
BuildRequires:  swig
BuildRequires:  python3-setuptools
%if 0%{?debian}
BuildRequires: device-tree-compiler
BuildRequires: libssl-dev
BuildRequires: libgnutls28-dev
BuildRequires: uuid-dev
BuildRequires: libpython3-dev
%else
BuildRequires:  dtc >= 1.4.0
# gnutls/gnutls.h required for tools/mkeficapsule.c
BuildRequires:  pkgconfig(gnutls)
# u-boot-clearfog (tools/kwbimage.c) needs openssl to build
BuildRequires:  pkgconfig(openssl)
# uuid/uuid.h required for tools/mkeficapsule.c
BuildRequires:  pkgconfig(uuid)
BuildRequires:  python3-devel
%endif


%description
Das U-Boot (or just "U-Boot" for short) is Open Source Firmware
for Embedded PowerPC, ARM, MIPS and x86 processors.
%if 0%{?tools_only}
This package contains tools that creates kernel bootable images for U-Boot.
%else
This package contains the firmware for the %target platform.
%endif

%prep
%autosetup -n u-boot-%{version}

%build
echo "target: %{_target_cpu} host: %{_host_cpu}"
%if %{with crosscompile}
export CROSS_COMPILE="%{_target_cpu}-linux-gnu-"
%endif
make %{?_smp_mflags} HOSTCFLAGS="%{optflags}" %{?defconfig}%{!?defconfig:%{target}_defconfig}
%if 0%{?tools_only}
make %{?_smp_mflags} CFLAGS="%{optflags}" tools-only NO_SDL=y
%else
make %{?_smp_mflags} HOSTCFLAGS="%{optflags}" all
%endif

%install
%if 0%{?tools_only}
for i in mkenvimage gen_ethaddr_crc dumpimage fit_info fit_check_sign fdtgrep ifwitool mkimage; do
	install -D -m 755 "tools/$i" "%{buildroot}%{_bindir}/$i"
done
install -D -m 0644 doc/mkimage.1 %{buildroot}%{_mandir}/man1/mkimage.1
%else
install -D -m 644 u-boot.bin %{buildroot}%{_prefix}/lib/u-boot/u-boot-%{target}.bin
%endif

%files
%if 0%{?tools_only}
%{_bindir}/*
%{_mandir}/man?/*
%else
%{_prefix}/lib/u-boot
%endif

%changelog

openSUSE Build Service is sponsored by