Building for an Alternate Distribution
From RTEMSWiki
The RTEMS Project provides pre-built RPMs for the cross development toolset which are useable on a variety of GNU/Linux x86 distributions. The RTEMS Development Server is a Fedora Core 3 based machine but we would like the tools to be useable on earlier distributions. Redhat 7.x has been identified as the distribution which we can build binaries on and have RPMs which are compatible with later distributions. This results in the need to have an environment to build tools in which is accessible without rebooting or having a dedicated machine for tools built using into the alternate distribution. This is done using the chroot method. The prerequisite instructions for setting up the alternate distributions can be found at http://www.faqs.org/docs/Linux-mini/Multi-Distro-Dev.html.
For clarity's sake, we will ignore issues related to installing the alternate distribution and assume the distributions have already been installed and are ready to use.
On the RTEMS development server, the distributions are located in the directory /home2/distros. The listings found there should obviously identify a Linux distribution, i.e. RH9 is the RedHat 9 OS.
For example, let's say you have a source tree on the RTEMS development server and it compiles and executes test cases successfully. Now you want to try it on a RedHat 7.2 system. Here's how.
NOTE: Most of these steps must be done as the root user.
First you'll need a user account on the RedHat 7.2 distro. If you need help with that, just ask. This moves you into the RH9 OS:
# /usr/sbin/chroot /home/distros/RH72
Now move into your RedHat 72 account and setup the directory structure for your source code:
# su USERNAME # mkdir -p path/to/src/tree
There are two ways to access your source tree, by copying it or by mounting it. The latter seems to be easier due to the size of some trees. So copy if you wish, or remount your source tree from the primary (FC3) distribution to the secondary one (RH9 in this case). From a separate command prompt back on the original distribution (FC3), do the mount:
# mount --bind /home/USERNAME/path/to/src/tree /home/distros/RH72/home/USERNAME/path/to/src/tree
Now back in your RH72 environment, you should be able to see your source code for building and testing.
NOTE: Sometimes it is necessary to use newer versions of the autotools (automake and autoconf) than were included with the distribution. Specifically, these are often necessary for building tools that are newer than the distribution you are compiling for. if you do have a need for newer autotools or other build support tools, install them in a non-standard location so you do not destroy the original distribution. For example, you may install new autotools to /opt/autotools and prefix your path with that directory as follows:
# export PATH=/opt/autotools/bin:$PATH
