New Documentation Submission: crosscompile.html
Ken Bantoft <[email protected]> Thu, 20 Feb 2003 23:01:53 -0500 (EST)
| Newsgroups | gmane.network.freeswan.devel |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hi Claudia, Since my patch to enable cross compiling FreeS/WAN was accepted, the correct thing to do is to document cross compiling :) So here's the documentation for it, pre-formatted for inclusion in FreeS/WAN - I'm hoping it makes it in for 2.00 since the other changes are slated for the next rc/pre release. I've proofed it once, but it could certainly use another set of eyes on it if you have the time. - -- Ken Bantoft The Unoffical FreeS/WAN Site: [email protected] http://www.freeswan.ca PGP Key: finger [email protected] I'd rather run Unix than Windows or MacOS any day, because Unix sucks less. -- jwz -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia Charset: noconv iQCVAwUBPlWks1iWUusaxGxpAQHB8QP/RnvEImc7nIVl1KnlH9qiLMoJL8aZv/uP cEYPCnay2h/0bC2j5JkSiIS5QLaFseDUua76wWZXZ6GCeSHPSNizHcWRTBoLkf90 VwVKUTaafBeEkLNaTSe79rJ0w9sqtlgBBuaAOKKu211jPlV95WbsJxHfp8iTS297 noOU5SV8bpw= =J6eW -----END PGP SIGNATURE-----
crosscompile.html
(text/html, 4.3 KB)
<HTML>
<HEAD>
<TITLE>Cross Compiling FreeS/WAN</TITLE>
<meta name="keywords" content="Linux, IPSEC, VPN, Security, FreeSWAN, cross, compile">
<!--
Written by Ken Bantoft <[email protected]> for the Linux FreeS/WAN project
Freely distributable under the GNU General Public License
More information at www.freeswan.org
Feedback to [email protected]
CVS information:
RCS ID: $Id: crosscompile.html,v 1.0 2003/02/20 00:00:00 ken Exp $
Last changed: $Date: 2003/02/20 00:00:00 $
Revision number: $Revision: 1.0 $
CVS revision numbers do not correspond to FreeS/WAN release numbers.
-->
</HEAD>
<BODY>
<H1><A NAME="guide"></A>Linux FreeS/WAN Cross Compiling Guide</H1>
<H2><A NAME="overview"></A>Overview</H2>
<P>
This document provides general instructions on how to cross compile
FreeS/WAN,
that is - compile it for another architecture (eg: StrongARM)</P>
<OL>
<LI><A HREF="#setup">Setting up your environment</A>.</LI>
<LI><A HREF="#building">Building</A>.</LI>
<LI><A HREF="#common">Common Problems</A>.</LI>
</OL>
<H2><A NAME="setup"></A>Setting up your Environment</H2>
<H3>Enviroment Variables</H3>
<P>There are a number of environment variables you can set to help facilitate
cross compiling FreeS/WAN. All examples will are using the bash shell.
</P>
<P>The following is an example of the how to set the environment variables if
you were cross compiling using the Embedix ARM toolchain, to build for an embedded
device like the Sharp Zaurus. Set these while you are in the FreeS/WAN directory.
It is often simpler to put the entire list into a script (eg: cross-setup.sh), and
then "source cross-setup.sh" or similar.
<pre>
export ARCH=arm
export CC=/opt/Embedix/tools/bin/arm-linux-gcc
export LD=/opt/Embedix/tools/bin/arm-linux-ld
export RANLIB=/opt/Embedix/tools/bin/arm-linux-ranlib
export AR=/opt/Embedix/tools/bin/arm-linux-ar
export AS=/opt/Embedix/tools/bin/arm-linux-as
export STRIP=/opt/Embedix/tools/bin/arm-linux-strip
export KERNELSRC=/zaurus/kernel-2.4.6
export LD_LIBRARY_PATH=/opt/Embedix/tools/lib/gcc-lib/arm-linux/2.95.2/
export PATH=$PATH:/opt/Embedix/tools/bin
export DESTDIR=/zaurus/binaries
</pre>
In the example above, we setup all of the usual gcc + bin-utils programs,
as well as setting the LD_LIBRARY_PATH to our cross-compiled system libraries,
and DESTDIR to our output directory.
</P>
<H3>Kernel Source</H3>
<P>Place a copy of the kernel source, setup for your target device somewhere on
your filesystem and set KERNELSRC= to this directory. You will need to prepare
your kernel source treefirst, by running "make menuconfig && make dep && make
modules". Once this is done, you can move on to building FreeS/WAN</P>
<H2><A NAME="building"></A>Building</H2>
<H3>The Make Process</H3>
<P>There are two parts to building FreeS/WAN - the userland programs and utilities,
and the ipsec.o kernel module. Each can be built seperatly, making debugging the
build process simpler.
</P>
<P>Step 1 is to run "make programs". This will build the required libs
(libfreeswan.a) as well as all of the userland tools (pluto, whack, etc...).
Provided your environment variables are set correctly, you should see the output
using your specified gcc (arm-linux-gcc for our example), ld, as, ar and
ranlib.</P>
<P>If this completes successfully, you can run "make install" to install a copy of
all of the binaries, man pages and other documentation to DESTDIR.</P>
<P>Step 2 is to build the ipsec.o module. This is done with "make oldmod", which
should change into the KERNELSRC directory and then compile and link the required
files to generate an ipsec.o file. If this is successful, you will end up with an
ipsec.o file in your FreeS/WAN directory, under linux/net/ipsec/.</P>
<P>Remember to install this to /lib/modules/$kernelversion/kernel/net/ipsec/ on
your target machine.</P>
<H2><A NAME="common"></A>Common Problems Building</H2>
<P>Here is a list of common problems/errors you may run into when cross compiling
FreeS/WAN.</P>
<UL>
<LI>gmp.h, libgmp not found, error with -lgmp. All of these refer to the GNU Math
Precision Library. You will need to have already built this for your target
system. Place libgmp.so in LD_LIBRARY_PATH, and ensure the headers are in your
include path as well.
</UL>
<P><BR><BR>
</P>
</BODY>
</HTML>