There is a package I build from source, following this recipe:
echo "deb-src http://archive.ubuntu.com/ubuntu focal main" >> /etc/apt/sources.list
echo "deb-src http://archive.ubuntu.com/ubuntu focal-updates main" >> /etc/apt/sources.list
apt update
apt source package
apt build-dep -y package
cd package/
dpkg-buildpackage
I want to cross-compile this package on an aarch64 host for an amd64 target. What parts might be necessary to modify?
For example, I could start with:
# basically, set up the apt repos for both amd64 and aarch64
sed -i '/^deb / {p; s/^deb /deb [arch=arm64] /}' /etc/apt/sources.list
sed -i 's,^deb http://ports.ubuntu.com/ubuntu-ports/,deb [arch=amd64] http://archive.ubuntu.com/ubuntu/,' /etc/apt/sources.list
echo "deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu focal main" >> /etc/apt/sources.list
echo "deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu focal-updates main" >> /etc/apt/sources.list
dpkg --add-architecture amd64
apt update
# install the cross compiler
apt install -y gcc-x86-64-linux-gnu
apt source package:amd64
apt build-dep -y package:amd64
cd package/
dpkg-buildpackage --target-arch=amd64
But this seems to be incomplete. For instance, if I am building the Linux kernel, dpkg-buildpackage complains that I'm missing dependencies like libudev-dev, and it invokes make ARCH=arm64 CROSS_COMPILE= which is for the host architecture, not the target.