Summary:        Building EFI Applications Using the GNU Toolchain
Name:           gnu-efi
Version:        3.0.13
Release:        1%{?_dist_release}
Group:          system
Vendor:         Project Vine
Distribution:   Vine Linux

License:        BSD
URL:            https://sourceforge.net/projects/gnu-efi/
Source0:        https://downloads.sourceforge.net/project/gnu-efi/%{name}-%{version}.tar.bz2

%global efidir  vine

%ifarch x86_64
%global efiarch x86_64
%endif
%ifarch %{ix86}
%global efiarch ia32
%endif

%description
Develop EFI applications for ARM-64, ARM-32, x86_64, IA-64 (IPF),
and IA-32 (x86) platforms using the GNU toolchain and the EFI
development environment.


%package        devel
Summary:        Development tools for %{name}
Summary(ja):    %{name} の開発環境
Group:          programming
Requires:       %{name} = %{version}-%{release}

%description    devel
Header files and libraries for building a extension library for the %{name}.


%package        utils
Summary:        Utilities for EFI systems
Group:          admin-tools

%description utils
This package contains utilties for debugging and developing EFI systems.


%prep
%setup -q


%build
make LIBDIR=%{_libdir}
make apps
%ifarch x86_64
setarch linux32 -B \
    make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib
setarch linux32 -B \
    make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib apps
%endif


%install
rm -rf $RPM_BUILD_ROOT
make install INSTALLROOT=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir}


mkdir -p $RPM_BUILD_ROOT%{_libdir}/gnuefi
mv $RPM_BUILD_ROOT%{_libdir}/*.lds $RPM_BUILD_ROOT%{_libdir}/*.o $RPM_BUILD_ROOT%{_libdir}/gnuefi

mkdir -p $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/
mv %{efiarch}/apps/{route80h.efi,modelist.efi} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/

%ifarch x86_64
setarch linux32 -B \
    make ARCH=ia32 INSTALLROOT=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib install

mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/gnuefi
mv $RPM_BUILD_ROOT%{_prefix}/lib/*.lds $RPM_BUILD_ROOT%{_prefix}/lib/*.o $RPM_BUILD_ROOT%{_prefix}/lib/gnuefi
%endif

find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'


%files
%doc README.gnuefi README.efilib README.elilo ChangeLog
%defattr(-,root,root,-)
%{_prefix}/lib/*
%{_libdir}/*

%files devel
%defattr(-,root,root,-)
%{_includedir}/efi

%files utils
%dir /boot/efi/EFI/%{efidir}/
%attr(0644,root,root) /boot/efi/EFI/%{efidir}/*.efi


%changelog
* Wed Mar 24 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.0.13-1
- new upstream release.
- dropped ldconfig scriptlet.
- dropped Patch0: fixed in upstream.

* Sun Aug 16 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.2-1
- initial build based on fedora
