5593c8
# vim:filetype=spec
5593c8
# Modules always contain just 32-bit code
5593c8
%global _libdir %{_exec_prefix}/lib
5593c8
%global _binaries_in_noarch_packages_terminate_build 0
5593c8
#%%undefine _missing_build_ids_terminate_build
5593c8
%{expand:%%{!?buildsubdir:%%global buildsubdir grub-%{tarversion}}}
5593c8
%{expand:%%{!?_licensedir:%%global license %%%%doc}}
5593c8
5593c8
%global _configure ../configure
5593c8
5593c8
%if %{?_with_ccache: 1}%{?!_with_ccache: 0}
fd0330
%global ccpath /usr/%{_lib}/ccache/gcc
5593c8
%else
fd0330
%global ccpath %{__cc}
5593c8
%endif
5593c8
fd0330
# gnulib actively ignores CFLAGS because it's terrible
fd0330
%global cc_equals "CC=%{ccpath} -fPIE -Wl,-z,noexecstack"
fd0330
5593c8
%global cflags_sed						\\\
5593c8
	sed							\\\
5593c8
		-e 's/-O. //g'					\\\
5593c8
		-e 's/-fplugin=annobin //g'			\\\
5593c8
		-e 's,-specs=[[:alnum:]/_-]*annobin[[:alnum:]_-]* ,,g' \\\
5593c8
		-e 's/-fstack-protector[[:alpha:]-]\\+//g'	\\\
5593c8
		-e 's/-Wp,-D_FORTIFY_SOURCE=[[:digit:]]\\+//g'	\\\
5593c8
		-e 's/--param=ssp-buffer-size=4//g'		\\\
5593c8
		-e 's/-mregparm=3/-mregparm=4/g'		\\\
5593c8
		-e 's/-fexceptions//g'				\\\
5593c8
		-e 's/-fcf-protection//g'			\\\
5593c8
		-e 's/-fasynchronous-unwind-tables//g'		\\\
5593c8
		-e 's/^/ -fno-strict-aliasing /'		\\\
5593c8
		%{nil}
5593c8
5593c8
%global host_cflags %{expand:%%(echo %{build_cflags} %{?_hardening_cflags} | %{cflags_sed})}
5593c8
%global legacy_host_cflags					\\\
5593c8
	%{expand:%%(echo %{host_cflags} |			\\\
5593c8
	%{cflags_sed}						\\\
5593c8
		-e 's/-m64//g'					\\\
5593c8
		-e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g'	\\\
5593c8
	)}
5593c8
%global efi_host_cflags %{expand:%%(echo %{host_cflags})}
5593c8
5593c8
%global target_cflags %{expand:%%(echo %{build_cflags} | %{cflags_sed})}
5593c8
%global legacy_target_cflags					\\\
5593c8
	%{expand:%%(echo %{target_cflags} | 			\\\
5593c8
	%{cflags_sed}						\\\
5593c8
		-e 's/-m64//g'					\\\
5593c8
		-e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g'	\\\
5593c8
	)}
5593c8
%global efi_target_cflags %{expand:%%(echo %{target_cflags})}
5593c8
5593c8
%global ldflags_sed						\\\
5593c8
	sed							\\\
5593c8
		-e 's,-specs=[[:alnum:]/_-]*annobin[[:alnum:]_-]* ,,g' \\\
5593c8
		-e 's/^$//'					\\\
5593c8
		%{nil}
5593c8
5593c8
%global host_ldflags %{expand:%%(echo %{build_ldflags} %{?_hardening_ldflags} | %{ldflags_sed})}
5593c8
%global legacy_host_ldflags					\\\
5593c8
	%{expand:%%(echo %{host_ldflags} |			\\\
5593c8
	%{ldflags_sed}						\\\
5593c8
	)}
5593c8
%global efi_host_ldflags %{expand:%%(echo %{host_ldflags})}
5593c8
5593c8
%global target_ldflags %{expand:%%(echo %{build_ldflags} -static | %{ldflags_sed})}
5593c8
%global legacy_target_ldflags					\\\
5593c8
	%{expand:%%(echo %{target_ldflags} | 			\\\
5593c8
	%{ldflags_sed}						\\\
5593c8
	)}
5593c8
%global efi_target_ldflags %{expand:%%(echo %{target_ldflags})}
5593c8
5593c8
%global with_efi_arch 0
5593c8
%global with_legacy_arch 0
5593c8
%global with_emu_arch 1
5593c8
%global emuarch %{_arch}
5593c8
%global grubefiarch %{nil}
5593c8
%global grublegacyarch %{nil}
5593c8
%global grubelfname %{nil}
5593c8
5593c8
# sparc is always compiled 64 bit
5593c8
%ifarch %{sparc}
5593c8
%global target_cpu_name sparc64
5593c8
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
5593c8
%global legacy_target_cpu_name %{_arch}
5593c8
%global legacy_package_arch ieee1275
5593c8
%global platform ieee1275
5593c8
%endif
5593c8
# ppc is always compiled 64 bit
5593c8
%ifarch ppc ppc64 ppc64le
5593c8
# GRUB emu fails to build on ppc64le
5593c8
%global with_emu_arch 0
5593c8
%global target_cpu_name %{_arch}
5593c8
%global legacy_target_cpu_name powerpc
5593c8
%global legacy_package_arch %{_arch}
5593c8
%global legacy_grub_dir powerpc-ieee1275
5593c8
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
5593c8
%global platform ieee1275
5593c8
%endif
5593c8
5593c8
5593c8
%global efi_only aarch64 %{arm} riscv64
5593c8
%global efi_arch x86_64 ia64 %{efi_only}
5593c8
%ifarch %{efi_arch}
5593c8
%global with_efi_arch 1
5593c8
%else
5593c8
%global with_efi_arch 0
5593c8
%endif
5593c8
%ifarch %{efi_only}
5593c8
%global with_efi_only 1
5593c8
%else
5593c8
%global with_efi_only 0
5593c8
%endif
5593c8
%{!?with_efi_arch:%global without_efi_arch 0}
5593c8
%{?with_efi_arch:%global without_efi_arch 1}
5593c8
%{!?with_efi_only:%global without_efi_only 0}
5593c8
%{?with_efi_only:%global without_efi_only 1}
5593c8
5593c8
%ifarch %{efi_arch}
5593c8
%global efi_modules " efi_netfs efifwsetup efinet lsefi lsefimmap connectefi "
5593c8
%endif
5593c8
5593c8
%ifarch x86_64 %{ix86}
5593c8
%global platform_modules " backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard "
5593c8
%endif
5593c8
5593c8
%ifarch ppc64le
fd0330
%global platform_modules " appendedsig ofnet tpm "
5593c8
%endif
5593c8
5593c8
%ifarch aarch64 %{arm} riscv64
5593c8
%global platform_modules " "
5593c8
%endif
5593c8
5593c8
%ifarch aarch64 %{arm} riscv64
5593c8
%global legacy_provides -l
5593c8
%endif
5593c8
5593c8
%ifarch %{ix86}
5593c8
%global efiarch ia32
5593c8
%global target_cpu_name i386
5593c8
%global grub_target_name i386-efi
5593c8
%global package_arch efi-ia32
5593c8
5593c8
%global legacy_target_cpu_name i386
5593c8
%global legacy_package_arch pc
5593c8
%global platform pc
5593c8
%endif
5593c8
5593c8
%ifarch x86_64
5593c8
%global efiarch x64
5593c8
%global target_cpu_name %{_arch}
5593c8
%global grub_target_name %{_arch}-efi
5593c8
%global package_arch efi-x64
5593c8
5593c8
%global legacy_target_cpu_name i386
5593c8
%global legacy_package_arch pc
5593c8
%global platform pc
5593c8
%endif
5593c8
5593c8
%ifarch aarch64
5593c8
%global emuarch arm64
5593c8
%global efiarch aa64
5593c8
%global target_cpu_name aarch64
5593c8
%global grub_target_name arm64-efi
5593c8
%global package_arch efi-aa64
5593c8
%endif
5593c8
5593c8
%ifarch riscv64
5593c8
%global emuarch riscv64
5593c8
%global efiarch riscv64
5593c8
%global target_cpu_name riscv64
5593c8
%global grub_target_name riscv64-efi
5593c8
%global package_arch efi-riscv64
5593c8
%endif
5593c8
5593c8
%ifarch %{arm}
5593c8
%global efiarch arm
5593c8
%global target_cpu_name arm
5593c8
%global grub_target_name arm-efi
5593c8
%global package_arch efi-arm
5593c8
%global efi_target_cflags						\\\
5593c8
	%{expand:%%(echo %{optflags} |					\\\
5593c8
	%{cflags_sed}							\\\
5593c8
		-e 's/-march=armv7-a[[:alnum:]+-]*/&+nofp/g'		\\\
5593c8
		-e 's/-mfpu=[[:alnum:]-]\\+//g'				\\\
5593c8
		-e 's/-mfloat-abi=[[:alpha:]]\\+/-mfloat-abi=soft/g'	\\\
5593c8
	)}
5593c8
%endif
5593c8
5593c8
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
5593c8
5593c8
%ifarch %{efi_arch}
5593c8
%global with_efi_arch 1
5593c8
%global grubefiname grub%{efiarch}.efi
5593c8
%global grubeficdname gcd%{efiarch}.efi
5593c8
%global grubefiarch %{target_cpu_name}-efi
5593c8
%ifarch %{ix86}
5593c8
%global with_efi_modules 0
5593c8
%global without_efi_modules 1
5593c8
%else
5593c8
%global with_efi_modules 1
5593c8
%global without_efi_modules 0
5593c8
%endif
5593c8
%endif
5593c8
5593c8
%ifnarch %{efi_only}
5593c8
%global with_legacy_arch 1
5593c8
%global grublegacyarch %{legacy_target_cpu_name}-%{platform}
5593c8
%global moduledir %{legacy_target_cpu_name}-%{platform}
5593c8
%global grubelfname core.elf
5593c8
%endif
5593c8
5593c8
%global evr %{epoch}:%{version}-%{release}
5593c8
5593c8
%ifarch x86_64
5593c8
%global with_efi_common 1
5593c8
%global with_legacy_modules 0
5593c8
%global with_legacy_common 0
5593c8
%else
5593c8
%global with_efi_common 0
5593c8
%global with_legacy_common 1
5593c8
%global with_legacy_modules 1
5593c8
%endif
5593c8
5593c8
%define define_legacy_variant()						\
5593c8
%{expand:%%package %%{1}}						\
5593c8
Summary:	Bootloader with support for Linux, Multiboot, and more	\
5593c8
Provides:	%{name} = %{evr}					\
5593c8
Obsoletes:	%{name} < %{evr}					\
5593c8
Requires:	%{name}-common = %{evr}					\
5593c8
Requires:	%{name}-tools-minimal = %{evr}				\
5593c8
Requires:	%{name}-%{1}-modules = %{evr}				\
5593c8
Requires:	gettext which file					\
5593c8
Requires:	%{name}-tools = %{evr}					\
5593c8
Requires(pre):	dracut							\
5593c8
Requires(post): dracut							\
5593c8
%{expand:%%description %%{1}}						\
5593c8
%{desc}									\
5593c8
This subpackage provides support for %{1} systems.			\
5593c8
									\
5593c8
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\
5593c8
%{expand:%%if 0%%{with_legacy_modules}					\
5593c8
%%package %%{1}-modules							\
5593c8
Summary:	Modules used to build custom grub images		\
5593c8
BuildArch:	noarch							\
5593c8
Requires:	%%{name}-common = %%{evr}				\
5593c8
%%description %%{1}-modules						\
5593c8
%%{desc}								\
5593c8
This subpackage provides support for rebuilding your own grub.efi.	\
5593c8
%%endif									\
5593c8
}									\
5593c8
									\
5593c8
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\
5593c8
%{expand:%%package %%{1}-tools}						\
5593c8
Summary:	Support tools for GRUB.					\
5593c8
Requires:	gettext os-prober which file system-logos		\
5593c8
Requires:	%{name}-common = %{evr}					\
5593c8
Requires:	%{name}-tools-minimal = %{evr}				\
5593c8
Requires:	os-prober >= 1.58-11					\
5593c8
Requires:	gettext which file					\
5593c8
									\
5593c8
%{expand:%%description %%{1}-tools}					\
5593c8
%{desc}									\
5593c8
This subpackage provides tools for support of %%{1} platforms.		\
5593c8
%{nil}
5593c8
5593c8
%define define_efi_variant(o)						\
5593c8
%{expand:%%package %{1}}						\
5593c8
Summary:	GRUB for EFI systems.					\
5593c8
Requires:	efi-filesystem						\
5593c8
Requires:	%{name}-common = %{evr}					\
5593c8
Requires:	%{name}-tools-minimal >= %{evr}				\
5593c8
Requires:	%{name}-tools = %{evr}					\
5593c8
Provides:	%{name}-efi = %{evr}					\
5593c8
%{?legacy_provides:Provides:	%{name} = %{evr}}			\
5593c8
%{-o:Obsoletes:	%{name}-efi < %{evr}}					\
5593c8
									\
5593c8
%{expand:%%description %{1}}						\
5593c8
%{desc}									\
5593c8
This subpackage provides support for %{1} systems.			\
5593c8
									\
5593c8
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%{1}-%{tarversion}}}\
5593c8
%{expand:%if 0%{?with_efi_modules}					\
5593c8
%{expand:%%package %{1}-modules}					\
5593c8
Summary:	Modules used to build custom grub.efi images		\
5593c8
BuildArch:	noarch							\
5593c8
Requires:	%{name}-common = %{evr}					\
5593c8
Provides:	%{name}-efi-modules = %{evr}				\
5593c8
Obsoletes:	%{name}-efi-modules < %{evr}				\
5593c8
%{expand:%%description %{1}-modules}					\
5593c8
%{desc}									\
5593c8
This subpackage provides support for rebuilding your own grub.efi.	\
5593c8
%endif}									\
5593c8
									\
5593c8
%{expand:%%package %{1}-cdboot}						\
5593c8
Summary:	Files used to boot removeable media with EFI		\
5593c8
Requires:	%{name}-common = %{evr}					\
5593c8
Provides:	%{name}-efi-cdboot = %{evr}				\
5593c8
%{expand:%%description %{1}-cdboot}					\
5593c8
%{desc}									\
5593c8
This subpackage provides optional components of grub used with removeable media on %{1} systems.\
5593c8
%{nil}
5593c8
5593c8
%global do_common_setup()					\
5593c8
%setup -q -n grub-%{tarversion}					\
5593c8
rm -fv docs/*.info						\
5593c8
cp %{SOURCE6} .gitignore					\
5593c8
cp %{SOURCE7} bootstrap						\
5593c8
cp %{SOURCE8} bootstrap.conf					\
5593c8
cp %{SOURCE9} ./grub-core/tests/strtoull_test.c			\
5593c8
cp %{SOURCE2} gnulib-%{gnulibversion}.tar.gz			\
5593c8
tar -zxf gnulib-%{gnulibversion}.tar.gz				\
5593c8
mv gnulib-%{gnulibversion} gnulib				\
5593c8
git init							\
5593c8
echo '![[:digit:]][[:digit:]]_*.in' > util/grub.d/.gitignore	\
5593c8
echo '!*.[[:digit:]]' > util/.gitignore				\
5593c8
echo '!config.h' > include/grub/emu/.gitignore			\
5593c8
git config user.email "%{name}-owner@fedoraproject.org"		\
5593c8
git config user.name "Fedora Ninjas"				\
5593c8
git config gc.auto 0						\
5593c8
rm -f configure							\
5593c8
git add .							\
5593c8
git commit -a -q -m "%{tarversion} baseline."			\
5593c8
#git apply --index --whitespace=nowarn %{SOURCE3}		\
5593c8
#git commit -a -q -m "%{tarversion} master."			\
5593c8
git am --whitespace=nowarn %%{patches} 
fd0330
rm -r build-aux m4						\
5593c8
./bootstrap							\
5593c8
%{nil}
5593c8
5593c8
%define do_efi_configure()					\
5593c8
%configure							\\\
5593c8
	%{cc_equals}						\\\
5593c8
	HOST_CFLAGS="%{3}"					\\\
5593c8
	HOST_CPPFLAGS="-I$(pwd)"				\\\
5593c8
	HOST_LDFLAGS="%{efi_host_ldflags}"			\\\
5593c8
	TARGET_CFLAGS="%{2}"					\\\
5593c8
	TARGET_CPPFLAGS="-I$(pwd)"				\\\
5593c8
	TARGET_LDFLAGS="%{efi_target_ldflags}"			\\\
5593c8
	--with-platform=efi					\\\
5593c8
	--with-utils=host					\\\
5593c8
	--target=%{1}						\\\
5593c8
	--with-grubdir=%{name}					\\\
5593c8
	--program-transform-name=s,grub,%{name},		\\\
5593c8
	--disable-werror || ( cat config.log ; exit 1 )		\
5593c8
git add .							\
5593c8
git commit -m "After efi configure"				\
5593c8
%{nil}
5593c8
5593c8
%define do_efi_build_modules()					\
5593c8
make %{?_smp_mflags} ascii.h widthspec.h			\
5593c8
make %{?_smp_mflags} -C grub-core				\
5593c8
%{nil}
5593c8
5593c8
%define do_efi_build_all()					\
5593c8
make %{?_smp_mflags}						\
5593c8
%{nil}
5593c8
5593c8
%define do_efi_link_utils()					\
5593c8
for x in grub-mkimage ; do					\\\
5593c8
	ln ../grub-%{1}-%{tarversion}/${x} ./ ;			\\\
5593c8
done								\
5593c8
%{nil}
5593c8
5593c8
%define do_install_protected_file()				\
5593c8
touch %{1}.conf							\
5593c8
echo %{1} > %{1}.conf						\
5593c8
install -d -m 755 ${RPM_BUILD_ROOT}/etc/dnf/protected.d/	\
5593c8
install -m 644 %{1}.conf ${RPM_BUILD_ROOT}/etc/dnf/protected.d/ \
5593c8
rm -f %{1}.conf							\
5593c8
%{nil}
5593c8
d3c3ab
%global grub_modules  " all_video boot blscfg			\\\
5593c8
			cat configfile cryptodisk		\\\
5593c8
			echo ext2 f2fs fat font			\\\
5593c8
			gcry_rijndael gcry_rsa gcry_serpent	\\\
5593c8
			gcry_sha256 gcry_twofish gcry_whirlpool	\\\
5593c8
			gfxmenu gfxterm gzio			\\\
1c6ba0
			halt http increment iso9660		\\\
5593c8
			jpeg loadenv loopback linux lvm luks	\\\
5593c8
			luks2 mdraid09 mdraid1x minicmd net	\\\
5593c8
			normal part_apple part_msdos part_gpt	\\\
5593c8
			password_pbkdf2 pgp png reboot regexp	\\\
5593c8
			search search_fs_uuid search_fs_file	\\\
5593c8
			search_label serial sleep syslinuxcfg	\\\
5593c8
			test tftp version video xfs zstd "	\
5593c8
5593c8
%ifarch x86_64 aarch64 %{arm} riscv64
5593c8
%define efi_mkimage()						\
5593c8
%{4}./grub-mkimage -O %{1} -o %{2}.orig				\\\
5593c8
	-p /EFI/%{efi_vendor} -d grub-core			\\\
5593c8
	--sbat %{4}./sbat.csv					\\\
5593c8
	${GRUB_MODULES}						\
5593c8
%{4}./grub-mkimage -O %{1} -o %{3}.orig				\\\
5593c8
	-p /EFI/BOOT -d grub-core				\\\
5593c8
	--sbat %{4}./sbat.csv					\\\
5593c8
	${GRUB_MODULES}						\
5593c8
%{expand:%%define ___pesign_client_cert %{?___pesign_client_cert}%{!?___pesign_client_cert:%{__pesign_client_cert}}} \
5593c8
%{?__pesign_client_cert:%{expand:%%define __pesign_client_cert %{___pesign_client_cert}}} \
5593c8
%{expand:%%{pesign -s -i %%{2}.orig -o %%{2} -a %%{5} -c %%{6} -n %%{7}}}	\
5593c8
%{expand:%%{pesign -s -i %%{3}.orig -o %%{3} -a %%{5} -c %%{6} -n %%{7}}}	\
5593c8
%{nil}
5593c8
%else
5593c8
%define efi_mkimage()						\
5593c8
%{4}./grub-mkimage -O %{1} -o %{2}				\\\
5593c8
	-p /EFI/%{efi_vendor} -d grub-core			\\\
5593c8
	${GRUB_MODULES}						\
5593c8
%{4}./grub-mkimage -O %{1} -o %{3}				\\\
5593c8
	-p /EFI/BOOT -d grub-core				\\\
5593c8
	${GRUB_MODULES}						\
5593c8
%{nil}
5593c8
%endif
5593c8
5593c8
%ifarch ppc64le
5593c8
%define ieee1275_mkimage()					\
5593c8
APPENDED_SIG_SIZE=0						\
5593c8
if [ -x /usr/bin/rpm-sign ]; then				\
5593c8
	touch empty.unsigned					\
5593c8
	rpm-sign --key %{4}					\\\
5593c8
		 --lkmsign empty.unsigned			\\\
5593c8
		 --output empty.signed				\
5593c8
	APPENDED_SIG_SIZE="$(stat -c '%s' empty.signed)"	\
5593c8
	rm empty.{un,}signed					\
5593c8
fi								\
5593c8
# FIXME: using this prefix is fragile, must be done properly	\
5593c8
./grub-mkimage -O %{1} -o %{2}.orig				\\\
5593c8
	-p '/grub2' -d grub-core				\\\
5593c8
	-x %{3}							\\\
5593c8
	--appended-signature-size ${APPENDED_SIG_SIZE}		\\\
5593c8
	${GRUB_MODULES}						\
5593c8
if [ -x /usr/bin/rpm-sign ]; then				\
5593c8
	truncate -s -${APPENDED_SIG_SIZE} %{2}.orig		\
5593c8
	rpm-sign --key %{4}					\\\
5593c8
		 --lkmsign %{2}.orig				\\\
5593c8
		 --output %{2}					\
5593c8
else								\
5593c8
	mv %{2}.orig %{2}					\
5593c8
fi								\
5593c8
%{nil}
5593c8
%endif
5593c8
5593c8
%define do_efi_build_images()					\
5593c8
GRUB_MODULES+=%{grub_modules}					\
5593c8
GRUB_MODULES+=%{efi_modules}					\
5593c8
GRUB_MODULES+=%{platform_modules}				\
5593c8
%{expand:%%{efi_mkimage %{1} %{2} %{3} %{4} %{5} %{6} %{7} %{8} %{9} %{10}}}	\
5593c8
%{nil}
5593c8
5593c8
%define do_ieee1275_build_images()			\
5593c8
GRUB_MODULES+=%{grub_modules}				\
5593c8
GRUB_MODULES+=%{platform_modules}			\
5593c8
cd grub-%{1}-%{tarversion}				\
5593c8
%{expand:%%ieee1275_mkimage %%{1} %%{2} %%{3} %%{4}}	\
5593c8
cd ..							\
5593c8
%{nil}
5593c8
5593c8
%define do_primary_efi_build()					\
5593c8
cd grub-%{1}-%{tarversion}					\
5593c8
%{expand:%%do_efi_configure %%{4} %%{5} %%{6}}			\
5593c8
%do_efi_build_all						\
5593c8
%{expand:%%do_efi_build_images %{grub_target_name} %{2} %{3} ./  %{7} %{8} %{9} %{10} %{11} %{12}} \
5593c8
cd ..								\
5593c8
%{nil}
5593c8
5593c8
%define do_legacy_build()					\
5593c8
cd grub-%{1}-%{tarversion}					\
5593c8
%configure							\\\
5593c8
	%{cc_equals}						\\\
5593c8
	HOST_CFLAGS="%{legacy_host_cflags}"			\\\
5593c8
	HOST_CPPFLAGS="-I$(pwd)"				\\\
5593c8
	HOST_LDFLAGS="%{legacy_host_ldflags}"			\\\
5593c8
	TARGET_CFLAGS="%{legacy_target_cflags}"			\\\
5593c8
	TARGET_CPPFLAGS="-I$(pwd)"				\\\
5593c8
	TARGET_LDFLAGS="%{legacy_target_ldflags}"		\\\
5593c8
	--with-platform=%{platform}				\\\
5593c8
	--with-utils=host					\\\
5593c8
	--target=%{_target_platform}				\\\
5593c8
	--with-grubdir=%{name}					\\\
5593c8
	--program-transform-name=s,grub,%{name},		\\\
5593c8
	--disable-werror || ( cat config.log ; exit 1 )		\
5593c8
git add .							\
5593c8
git commit -m "After legacy configure"				\
5593c8
make %{?_smp_mflags}						\
5593c8
cd ..								\
5593c8
%{nil}
5593c8
5593c8
%define do_emu_build()						\
5593c8
cd grub-emu-%{tarversion}					\
5593c8
%configure							\\\
5593c8
	%{cc_equals}						\\\
5593c8
	HOST_CFLAGS="%{legacy_host_cflags}"			\\\
5593c8
	HOST_CPPFLAGS="-I$(pwd)"				\\\
5593c8
	HOST_LDFLAGS="%{legacy_host_ldflags}"			\\\
5593c8
	--with-platform=emu					\\\
5593c8
	--with-grubdir=%{name}					\\\
5593c8
	--program-transform-name=s,grub,%{name},		\\\
5593c8
	--disable-werror || ( cat config.log ; exit 1 )		\
5593c8
git add .							\
5593c8
git commit -m "After emu configure"				\
5593c8
make %{?_smp_mflags} ascii.h widthspec.h			\
5593c8
make %{?_smp_mflags} -C grub-core/lib/gnulib			\
5593c8
make %{?_smp_mflags} -C grub-core				\
5593c8
cd ..								\
5593c8
%{nil}
5593c8
5593c8
%define do_efi_install()					\
5593c8
cd grub-%{1}-%{tarversion}					\
5593c8
make DESTDIR=$RPM_BUILD_ROOT install				\
5593c8
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
5593c8
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
5593c8
fi								\
5593c8
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
5593c8
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
5593c8
fi								\
5593c8
find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} '\;'	\
5593c8
ln -s ../boot/%{name}/grub.cfg					\\\
5593c8
	$RPM_BUILD_ROOT%{_sysconfdir}/%{name}-efi.cfg		\
5593c8
install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2}		\
5593c8
install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3}		\
5593c8
%ifarch %{arm}							\
5593c8
install -D -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_boot}/BOOTARM.EFI \
5593c8
%endif								\
5593c8
install -D -m 700 unicode.pf2					\\\
5593c8
	${RPM_BUILD_ROOT}/boot/%{name}/fonts/unicode.pf2		\
5593c8
${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv			\\\
5593c8
		${RPM_BUILD_ROOT}/boot/%{name}/grubenv create	\
5593c8
%{expand:%%do_install_protected_file %{name}-%{package_arch}}	\
5593c8
cd ..								\
5593c8
%{nil}
5593c8
5593c8
%define do_legacy_install()					\
5593c8
cd grub-%{1}-%{tarversion}					\
5593c8
make DESTDIR=$RPM_BUILD_ROOT install				\
5593c8
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
5593c8
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
5593c8
fi								\
5593c8
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
5593c8
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
5593c8
fi								\
5593c8
%{expand:%ifarch ppc64le					\
5593c8
	install -m 700 %{grubelfname} $RPM_BUILD_ROOT/%{_libdir}/grub/%{1} \
5593c8
%endif}								\
5593c8
if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/%{name}.chrp ]; then \
5593c8
	mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/%{name}.chrp	\\\
5593c8
	   $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/%{name}.chrp	\
5593c8
fi								\
5593c8
if [ %{2} -eq 0 ]; then						\
5593c8
	${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv		\\\
5593c8
		${RPM_BUILD_ROOT}/boot/%{name}/grubenv create	\
5593c8
fi								\
5593c8
%{expand:%%do_install_protected_file %{name}-%{legacy_package_arch}} \
5593c8
cd ..								\
5593c8
%{nil}
5593c8
5593c8
%define do_emu_install()					\
5593c8
cd grub-emu-%{tarversion}					\
5593c8
make DESTDIR=$RPM_BUILD_ROOT install -C grub-core		\
5593c8
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
5593c8
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
5593c8
fi								\
5593c8
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
5593c8
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
5593c8
fi								\
5593c8
if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/%{name}.chrp ]; then \
5593c8
	mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/%{name}.chrp	\\\
5593c8
	   $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp	\
5593c8
fi								\
5593c8
cd ..								\
5593c8
%{nil}
5593c8
5593c8
%define do_common_install()					\
5593c8
install -d -m 0755 						\\\
5593c8
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot		\\\
5593c8
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en		\\\
5593c8
	$RPM_BUILD_ROOT%{_infodir}/				\
5593c8
cp -a $RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot		\\\
5593c8
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en		\
5593c8
cp docs/grub.info $RPM_BUILD_ROOT%{_infodir}/%{name}.info	\
5593c8
cp docs/grub-dev.info						\\\
5593c8
	$RPM_BUILD_ROOT%{_infodir}/%{name}-dev.info		\
5593c8
install -d -m 0700 ${RPM_BUILD_ROOT}%{efi_esp_dir}/		\
5593c8
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/%{name}/		\
5593c8
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/loader/entries	\
5593c8
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/%{name}/themes/system	\
5593c8
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/default	\
5593c8
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig	\
5593c8
touch ${RPM_BUILD_ROOT}%{_sysconfdir}/default/grub		\
5593c8
ln -sf ../default/grub						\\\
5593c8
	${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/grub		\
5593c8
touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg			\
5593c8
ln -s ../boot/%{name}/grub.cfg					\\\
5593c8
	${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}.cfg		\
5593c8
%{nil}
5593c8
5593c8
%define define_legacy_variant_files()				\
5593c8
%{expand:%%files %{1}}						\
5593c8
%defattr(-,root,root,-)						\
5593c8
%config(noreplace) %{_sysconfdir}/%{name}.cfg			\
d3c3ab
%ghost %config(noreplace) %attr(0700,root,root)/boot/%{name}/grub.cfg	\
5593c8
%dir %attr(0700,root,root)/boot/loader/entries			\
5593c8
%attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/%{name}-%{1}.conf \
5593c8
%ifarch ppc64le						\
5593c8
%dir %{_libdir}/grub/%{2}/					\
5593c8
%{_libdir}/grub/%{2}/%{grubelfname}				\
5593c8
%endif								\
5593c8
								\
5593c8
%{expand:%if 0%{?with_legacy_modules}				\
5593c8
%{expand:%%files %{1}-modules}					\
5593c8
%defattr(-,root,root)						\
5593c8
%dir %{_libdir}/grub/%{2}/					\
5593c8
%{_libdir}/grub/%{2}/*						\
5593c8
%ifarch ppc64le						\
5593c8
%exclude %{_libdir}/grub/%{2}/%{grubelfname}			\
5593c8
%endif								\
5593c8
%exclude %{_libdir}/grub/%{2}/*.module				\
5593c8
%exclude %{_libdir}/grub/%{2}/{boot,boot_hybrid,cdboot,diskboot,lzma_decompress,pxeboot}.image \
5593c8
%exclude %{_libdir}/grub/%{2}/*.o				\
5593c8
%else								\
5593c8
%%exclude %%{_libdir}/grub/%%{grublegacyarch}/*			\
5593c8
%endif}								\
5593c8
%{nil}
5593c8
5593c8
%define define_efi_variant_files()				\
5593c8
%{expand:%%files %{1}}						\
5593c8
%defattr(-,root,root,-)						\
5593c8
%config(noreplace) %{_sysconfdir}/%{name}.cfg			\
5593c8
%config(noreplace) %{_sysconfdir}/%{name}-efi.cfg		\
d3c3ab
%attr(0700,root,root) %verify(not mtime) %{efi_esp_dir}/%{2}	\
5593c8
%ifarch %{arm}							\
d3c3ab
%attr(0700,root,root) %verify(not mtime) %{efi_esp_boot}/BOOTARM.EFI \
5593c8
%endif								\
5593c8
%attr(0700,root,root)/boot/%{name}/fonts			\
5593c8
%dir %attr(0700,root,root)/boot/loader/entries			\
d3c3ab
%ghost %config(noreplace) %attr(0700,root,root)/boot/%{name}/grub.cfg	\
d3c3ab
%ghost %config(noreplace) %verify(not mtime) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg	\
5593c8
%config(noreplace) %verify(not size mode md5 mtime) /boot/%{name}/grubenv	\
5593c8
%attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/%{name}-%{1}.conf \
5593c8
%{expand:%if 0%{?without_efi_modules}				\
5593c8
%exclude %{_libdir}/grub/%{6}					\
5593c8
%exclude %{_libdir}/grub/%{6}/*					\
5593c8
%endif}								\
5593c8
								\
5593c8
%{expand:%if 0%{?with_efi_modules}				\
5593c8
%{expand:%%files %{1}-modules}					\
5593c8
%defattr(-,root,root,-)						\
5593c8
%dir %{_libdir}/grub/%{6}/					\
5593c8
%{_libdir}/grub/%{6}/*						\
5593c8
%exclude %{_libdir}/grub/%{6}/*.module				\
5593c8
%endif}								\
5593c8
								\
5593c8
%{expand:%%files %{1}-cdboot}					\
5593c8
%defattr(-,root,root,-)						\
d3c3ab
%attr(0700,root,root) %verify(not mtime) %{efi_esp_dir}/%{3}	\
5593c8
%attr(0700,root,root)/boot/%{name}/fonts			\
5593c8
%{nil}