Remaining workarounds Cross building Debian Building internal libraries Gradually, changes are being made to the Debian package building tools to make cross building easier in Debian. Some problems remain and emdebuild uses three main workarounds: gccross : from dpkg-cross. This script sits between $(MAKE) and the cross compiler. When the cross compiler is called, all -I and -L paths must be set for the cross packages installed by dpkg-cross so that the compiler can find the right headers and the right shared objects. In most cases, a combination of pkg-config and libtool ensure that these paths are available. Packages that build internal libraries and then link other libraries or executables against those object files will experience problems when installing the object file during the Debian package building. During the final install, object files are relinked for the package directories - except when cross building, the relinking gets confused and tries to relink against libraries in /usr/lib/ instead of /usr/$arch-triplet/lib/ and the build fails. For some years, dpkg-cross has contained a utility called gccross that rewrites the paths passed to the cross compiler. It does this by pretending to be the cross compiler and then rewriting the @ARGV before passing control to the real compiler. Since emdebian-tools (>=0.7.3), gccross is optional - packages need to opt-in to gccross support using a flag in debian/xcontrol : X-Build-Cross-Libtool: yes (or Build-Cross-Libtool: yes but hopefully this will be fixed before this field needs to become an official dpkg control field). Packages can implement their own support for cross building their internal objects by specifying -l flags to libtool: Specifying relinking path for internal objects in CDBS This example is from libqof1. ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) # internal libraries need to be redirected to cross version DEB_MAKE_INVOKE+="QOF_LIBS=-L/usr/$(DEB_HOST_GNU_TYPE)/lib -lqof" endif Specifying relinking path for internal objects via $(MAKE) For an example package, FOO using -lfoo during native relinking and passing ${FOO_LIBS} for libfoo_la_LIBADD in the upstream Makefile.am. ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) RELINK="FOO_LIBS=-L/usr/$(DEB_HOST_GNU_TYPE)/lib -lfoo" endif Upstream may need to be patched. Note that upstream needs to support a variable already - if the upstream Makefile.am hardcodes -lfoo then a patch will be needed to replace this value with a suitable variable. These problems will also be reported under the long term mass bug filing for cross building support agreed on debian-devel in November 2007. emdebian-tools (specifically emdebuild) already has outline support for debian/xcontrol and this will be enhanced with full support for the debian-xcontrol package in future releases. Using debian/xcontrol with xcontrol emdebuild initially improvised a Build-Cross-Depends: field in debian/xcontrol and this will continue to be supported until emdebian-tools is fully integrated with xcontrol from the debian-xcontrol package. For compatibility with xcontrol, use: Build-Depends: libsqlite0-dev, libglib2.0-dev, libgpewidget-dev Build-Depends-Tools: cdbs, debhelper (>= 5), autotools-dev, automake1.9, dpkg-dev (>= 1.13.19) instead of: Build-Depends: cdbs, debhelper (>= 5), autotools-dev, libsqlite0-dev, libglib2.0-dev, dpkg-dev (>= 1.13.19), libgpewidget-dev, automake1.9 Only packages that need to be installed with apt-cross are now listed in Build-Depends and packages that only need to be installed on the build machine (including all packages that are Architecture: all) go into Build-Depends-Tools. xcontrol build can then be used to integrate the two sections for normal Debian builds. Working with dpkg in a cross build Outstanding dpkg bugs and the Emdebian workarounds LD_LIBRARY_PATH : this is a workaround for dpkg-shlibdeps and when bug #453267 is fixed, this workaround will disappear from emdebuild. The basis of this workaround is to make /usr/${crossprefix}/lib/ available to dpkg-shlibdeps where ${crossprefix} is the architecture triplet; for ARM the triplet is arm-linux-gnu. PKG_CONFIG_LIBDIR : this is a workaround for dpkg-buildpackage -a and when bug #439979 is fixed, this workaround will disappear from emdebuild. The basis of this workaround is to make /usr/${crossprefix}/include/ and /usr/${crossprefix}/lib available to gcc where ${crossprefix} is the architecture triplet; for ARM the triplet is arm-linux-gnu.