File u-boot-a10-olinuxino-lime.spec of Package u-boot-rpi2

# spec file for package u-boot-a10-olinuxino-lime
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2010 Texas Instruments Inc by Nishanth Menon
# Copyright (c) 2007-2010 by Silvan Calarco <>
# 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

%define x_loader 0
%define origen_spl 0
%define sunxi_spl 1
%define arndale_spl 0
%define cuboxi_spl 0
%define udoo_spl 0

# archive_version differs from version for RC version only
%define archive_version 2016.03

Name:           u-boot-a10-olinuxino-lime
Version:        2016.03
Release:        0
Summary:        The u-boot firmware for the a10-olinuxino-lime arm platform
License:        GPL-2.0
Group:          System/Boot
Source2:        arndale-bl1.img
Source300:      u-boot-rpmlintrc
# Fix exynos KVM support
Patch1:         u-boot-exynos.patch
# Add EFI support. Will be upstream in the next version of u-boot.
Patch3:         efi.patch
Patch4:         efi2.patch
# Set default environment slightly different for EFI, so it finds our dtbs
Patch5:         efi-default-env.patch
# Move omap3 to distro boot method
Patch6:         omap3-Move-to-distro-bootcmd.patch
# efi: Run memory node fixups in device tree
Patch7:         efi_loader-Call-fdt-preparation-functions.patch
# Allow grub2 to find its config file
Patch8:         efi_loader-Pass-proper-device-path-in-on-boot.patch
# Fix Raspberry Pi 1 build
Patch9:         efi_loader-Provide-icache-flush-stub.patch
# Ensure we mark the device tree as reserved
Patch11:        efi-map-fdt-as-reserved.patch
Patch12:        rpi3.patch
Patch13:        rpi2-gop.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# Arndale board need DTC >= 1.4
BuildRequires:  bc
BuildRequires:  dtc >= 1.4.0
%if "%{name}" == "u-boot-qemu-ppce500"
# Owns /usr/share/qemu directory
BuildRequires:  qemu
Provides:       qemu-ppc:%{_datadir}/qemu/u-boot.e500
%if "%{name}" == "u-boot-rpi" || "%{name}" == "u-boot-rpi2"
# Owns /boot/vc directory
BuildRequires:  raspberrypi-firmware
Provides:       u-boot-loader
Conflicts:      otherproviders(u-boot-loader)
%if %x_loader == 1
Obsoletes:      x-loader-a10-olinuxino-lime
Provides:       x-loader-a10-olinuxino-lime
ExclusiveArch:  armv7l armv7hl

Das U-Boot (or just "U-Boot" for short) is Open Source Firmware for Embedded PowerPC, ARM, MIPS and x86 processors.
This package contains the firmware for the a10-olinuxino-lime arm platform.

%package doc
Summary:        Documentation for the u-boot Firmware
Group:          Documentation/Other

%description doc
Das U-Boot (or just "U-Boot" for short) is Open Source Firmware for Embedded PowerPC, ARM, MIPS and x86 processors.
This package contains documentation for u-boot firmware

%setup -q -n u-boot-%{archive_version}
%patch1 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch11 -p1
%patch13 -p1

make %{?jobs:-j %jobs} CROSS_COMPILE= CFLAGS="$RPM_OPT_FLAGS" A10-OLinuXino-Lime_defconfig
%if "%{name}" == "u-boot-snow" || "%{name}" == "u-boot-spring"
# Chromebook ARM (snow) and HP Chromebook 11 (spring) need a uImage format
export TEXT_START=$(awk '$NF == "_start" { printf "0x"$1 }'
./tools/mkimage -A arm -O linux -T kernel -C none -a $TEXT_START -e $TEXT_START -n uboot -d u-boot-dtb.bin u-boot.img

export NO_BRP_STRIP_DEBUG=true
%define uboot_dir /boot
%if "%{name}" == "u-boot-rpi" || "%{name}" == "u-boot-rpi2"
%define uboot_dir /boot/vc
%if "%{name}" == "u-boot-qemu-ppce500"
%define uboot_dir %{_datadir}/qemu
%if "%{name}" == "u-boot-jetson-tk1"
# tegra-uboot-flasher needs several intermediate files, under their original name.
for f in u-boot u-boot.dtb u-boot-dtb-tegra.bin u-boot-nodtb-tegra.bin; do
    install -D -m 0644 $f %{buildroot}/boot/$f
# Some times u-boot needs a dtb to configure itself appended to the binary.
# In that case prefer the one with a working dtb already appended.
if [ -f u-boot-dtb-tegra.bin ]; then
    install -D -m 0644 u-boot-dtb-tegra.img %{buildroot}%{uboot_dir}/u-boot.img
elif [ -f u-boot-dtb.img ]; then
    install -D -m 0644 u-boot-dtb.img %{buildroot}%{uboot_dir}/u-boot.img
    install -D -m 0644 u-boot.img %{buildroot}%{uboot_dir}/u-boot.img
%if "%{name}" == "u-boot-qemu-ppce500"
mv %{buildroot}%{uboot_dir}/u-boot.img %{buildroot}%{uboot_dir}/u-boot.e500
%if %x_loader == 1
install -D -m 0755 MLO %{buildroot}/boot/MLO
%if %origen_spl == 1
install -D -m 0755 spl/origen-spl.bin %{buildroot}/boot/origen-spl.bin
%if %arndale_spl == 1
install -D -m 0755 spl/arndale-spl.bin %{buildroot}/boot/arndale-spl.bin
install -D -m 0755 %{SOURCE2} %{buildroot}/boot/arndale-bl1.img
%if %sunxi_spl == 1
install -D -m 0755 spl/sunxi-spl.bin %{buildroot}/boot/sunxi-spl.bin
install -D -m 0755 u-boot-sunxi-with-spl.bin %{buildroot}/boot/u-boot-sunxi-with-spl.bin 
%if %cuboxi_spl == 1
install -D -m 0755 SPL %{buildroot}/boot/cuboxi-spl.bin
%if %udoo_spl == 1
install -D -m 0755 SPL %{buildroot}/boot/udoo_spl.bin

%doc Licenses/gpl-2.0.txt README

%files doc
# Generic documents
%doc doc/README.JFFS2 doc/README.JFFS2_NAND doc/README.commands
%doc doc/README.autoboot doc/README.commands doc/README.console doc/README.dns
%doc doc/README.hwconfig doc/README.nand doc/README.NetConsole doc/README.serial_multi
%doc doc/README.SNTP doc/README.standalone doc/README.update doc/README.usb
%doc doc/ doc/README.VLAN doc/README.silent doc/README.POST
# Copy some useful kermit scripts as well
%doc tools/kermit/dot.kermrc tools/kermit/flash_param tools/kermit/send_cmd tools/kermit/send_image
# Now any h/w dependent Documentation
%doc doc/README.ARM-memory-map