# Tests are disabled as they require x86_64 libraries to run %bcond tests 0 %global forgeurl0 https://github.com/ptitSeb/box64 %global forgeurl1 https://github.com/mstorsjo/llvm-mingw %global forgever1 20250613 %global forgetag1 22.04 %global common_description %{expand: Box64 lets you run x86_64 Linux programs (such as games) on non-x86_64 Linux systems, like ARM (host system needs to be 64-bit little-endian).} Name: box64 Version: 0.4.0 Release: 2 Summary: Linux userspace x86_64 emulator with a twist, targeted at ARM64 License: MIT URL: https://box86.org Source0: %{forgeurl0}/archive/main/%{name}-main.tar.gz Source1: %{forgeurl1}/releases/download/%{forgever1}/llvm-mingw-%{forgever1}-ucrt-ubuntu-%{forgetag1}-aarch64.tar.xz BuildRequires: cmake BuildRequires: gcc BuildRequires: make BuildRequires: perl-podlators BuildRequires: systemd-rpm-macros # box64 only supports these architectures ExclusiveArch: aarch64 riscv64 ppc64le %{x86_64} Requires: %{name}-data = %{version}-%{release} # These should not be pulled in on x86_64 as they can cause a loop and prevent # any binary from successfully executing (#2344770) %ifnarch %{x86_64} Recommends: %{name}-binfmts = %{version}-%{release} %endif %ifarch aarch64 Requires(post): %{_sbindir}/update-alternatives Requires(postun): %{_sbindir}/update-alternatives %endif %description %{common_description} %package data Summary: Common files for %{name} BuildArch: noarch %description data %{common_description} This package provides common data files for box64. %ifnarch %{x86_64} %package binfmts Summary: binfmt_misc handler configurations for box64 %description binfmts %{common_description} This package provides binfmt_misc handler configurations to use box64 to execute x86_64 binaries. %package wow Summary: A highly experimantal library containing wow64 for 32bits Windows applications %description wow %{common_description} This package provides wowbox64 DLL which is used to run 32bits Windows applications in a wine prefix. %endif %ifarch aarch64 %package tegrax1 Summary: %{summary} Requires: %{name}-data = %{version}-%{release} Requires(post): %{_sbindir}/update-alternatives Requires(postun): %{_sbindir}/update-alternatives %description tegrax1 %{common_description} This package contains a version of box64 targeting Nvidia Tegra X1 systems. %endif %prep %autosetup -p1 -n %{name}-main # Remove prebuilt libraries rm -r x64lib # Fix encoding sed -i 's/\r$//' docs/*.md # Fix install paths sed -i 's:/etc/binfmt.d:%{_binfmtdir}:g' CMakeLists.txt tar xf %{SOURCE1} -C %{_buildrootdir} %build %global common_flags -DNOGIT=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBOX32=ON -DBOX32_BINFMT=ON %ifarch aarch64 %global common_flags -DARM_DYNAREC=ON %{common_flags} # Nvidia Tegra X1 %cmake %{common_flags} -DTEGRAX1=ON %cmake_build cp -p %{__cmake_builddir}/%{name} %{name}.tegrax1 rm -r %{__cmake_builddir} %endif %cmake %{common_flags} -DNO_LIB_INSTALL=ON \ %ifarch aarch64 -DARM64=ON %endif %ifarch riscv64 -DRV64=ON %endif %ifarch ppc64le -DPPC64LE=ON %endif %ifarch %{x86_64} -DLD80BITS=ON \ -DNOALIGN=ON %endif %cmake_build export CC=%{_buildrootdir}/llvm-mingw-%{forgever1}-ucrt-ubuntu-%{forgetag1}-aarch64/bin/clang export CXX=%{_buildrootdir}/llvm-mingw-%{forgever1}-ucrt-ubuntu-%{forgetag1}-aarch64/bin/clang++ export PATH="%{_buildrootdir}/llvm-mingw-%{forgever1}-ucrt-ubuntu-%{forgetag1}-aarch64/bin/:$PATH" # CFLAGS, CXXFLAGS and LDFLAGS need to be reset in order to compile wowbox64 export CFLAGS= export CXXFLAGS= export LDFLAGS= # wow64 mkdir -p build cd build cmake -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWOW64=ON .. make -j4 wowbox64 cd .. cp build/wowbox64-prefix/src/wowbox64-build/wowbox64.dll . rm -r build # Build manpage pod2man --stderr docs/%{name}.pod > docs/%{name}.1 %install %ifarch %{x86_64} # Install manually as cmake_install doesn't seem to work on x86_64 install -Dpm0755 -t %{buildroot}%{_bindir} %{__cmake_builddir}/%{name} install -Ddpm0755 %{buildroot}%{_binfmtdir} sed 's:${CMAKE_INSTALL_PREFIX}/bin/${BOX64}:%{_bindir}/%{name}:' \ < system/box32.conf.cmake > system/box32.conf sed 's:${CMAKE_INSTALL_PREFIX}/bin/${BOX64}:%{_bindir}/%{name}:' \ < system/box64.conf.cmake > system/box64.conf install -Dpm0644 -t %{buildroot}%{_sysconfdir} system/box64.box64rc %else %cmake_install %endif # Install manpage install -Dpm0644 -t %{buildroot}%{_mandir}/man1 docs/%{name}.1 %ifarch aarch64 mv %{buildroot}%{_bindir}/%{name} %{buildroot}%{_bindir}/%{name}.aarch64 touch %{buildroot}%{_bindir}/%{name} chmod +x %{buildroot}%{_bindir}/%{name} install -Dpm0755 -t %{buildroot}%{_bindir} \ %{name}.tegrax1 # Install wowbox64.dll to libdir install -Dpm0755 -t %{buildroot}%{_datarootdir}/box64/ \ wowbox64.dll %post %{_sbindir}/update-alternatives --install %{_bindir}/%{name} \ %{name} %{_bindir}/%{name}.aarch64 20 %postun if [ $1 -eq 0 ] ; then %{_sbindir}/update-alternatives --remove %{name} %{_bindir}/%{name}.aarch64 fi %post tegrax1 %{_sbindir}/update-alternatives --install %{_bindir}/%{name} \ %{name} %{_bindir}/%{name}.tegrax1 10 %postun tegrax1 if [ $1 -eq 0 ] ; then %{_sbindir}/update-alternatives --remove %{name} %{_bindir}/%{name}.tegrax1 fi %endif %if %{with tests} %check %ctest %endif %files %ifarch aarch64 %ghost %{_bindir}/%{name} %{_bindir}/%{name}.aarch64 %else %{_bindir}/%{name} %endif %ifarch aarch64 %files tegrax1 %ghost %{_bindir}/%{name} %{_bindir}/%{name}.tegrax1 %endif %files data %license LICENSE %doc README.md %doc %lang(cn) README_CN.md %doc %lang(uk) README_UK.md %doc docs/*.md docs/img %{_mandir}/man1/box64.1* %config(noreplace) %{_sysconfdir}/box64.box64rc %ifnarch %{x86_64} %files binfmts %{_binfmtdir}/box32.conf %{_binfmtdir}/box64.conf %files wow %{_datarootdir}/box64/wowbox64.dll %endif %changelog %autochangelog