]> git.ipfire.org Git - people/ms/strongswan.git/blob - doc/src/crosscompile.html
(no commit message)
[people/ms/strongswan.git] / doc / src / crosscompile.html
1 <HTML>
2 <HEAD>
3 <TITLE>Cross Compiling FreeS/WAN</TITLE>
4 <meta name="keywords" content="Linux, IPSEC, VPN, Security, FreeSWAN, cross, compile">
5 <!--
6 Written by Ken Bantoft <ken@freeswan.ca> for the Linux FreeS/WAN project
7 Freely distributable under the GNU General Public License
8
9 More information at www.freeswan.org
10 Feedback to users@lists.freeswan.org
11
12 CVS information:
13 RCS ID: $Id: crosscompile.html,v 1.1 2004/03/15 20:35:24 as Exp $
14 Last changed: $Date: 2004/03/15 20:35:24 $
15 Revision number: $Revision: 1.1 $
16
17 CVS revision numbers do not correspond to FreeS/WAN release numbers.
18 -->
19
20 </HEAD>
21 <BODY>
22
23 <H1><A NAME="guide"></A>Linux FreeS/WAN Cross Compiling Guide</H1>
24
25 <H2><A NAME="overview"></A>Overview</H2>
26
27 <P>
28 This document provides general instructions on how to cross compile
29 FreeS/WAN,
30 that is - compile it for another architecture (eg: StrongARM)</P>
31 <OL>
32 <LI><A HREF="#setup">Setting up your environment</A>.</LI>
33 <LI><A HREF="#building">Building</A>.</LI>
34 <LI><A HREF="#common">Common Problems</A>.</LI>
35 </OL>
36 <H2><A NAME="setup"></A>Setting up your Environment</H2>
37 <H3>Enviroment Variables</H3>
38 <P>There are a number of environment variables you can set to help facilitate
39 cross compiling FreeS/WAN. All examples will are using the bash shell.
40 </P>
41 <P>The following is an example of the how to set the environment variables if
42 you were cross compiling using the Embedix ARM toolchain, to build for an embedded
43 device like the Sharp Zaurus. Set these while you are in the FreeS/WAN directory.
44 It is often simpler to put the entire list into a script (eg: cross-setup.sh), and
45 then "source cross-setup.sh" or similar.
46 <pre>
47 export ARCH=arm
48 export CC=/opt/Embedix/tools/bin/arm-linux-gcc
49 export LD=/opt/Embedix/tools/bin/arm-linux-ld
50 export RANLIB=/opt/Embedix/tools/bin/arm-linux-ranlib
51 export AR=/opt/Embedix/tools/bin/arm-linux-ar
52 export AS=/opt/Embedix/tools/bin/arm-linux-as
53 export STRIP=/opt/Embedix/tools/bin/arm-linux-strip
54 export KERNELSRC=/zaurus/kernel-2.4.6
55 export LD_LIBRARY_PATH=/opt/Embedix/tools/lib/gcc-lib/arm-linux/2.95.2/
56 export PATH=$PATH:/opt/Embedix/tools/bin
57 export DESTDIR=/zaurus/binaries
58 </pre>
59 In the example above, we setup all of the usual gcc + bin-utils programs,
60 as well as setting the LD_LIBRARY_PATH to our cross-compiled system libraries,
61 and DESTDIR to our output directory.
62 </P>
63
64 <H3>Kernel Source</H3>
65 <P>Place a copy of the kernel source, setup for your target device somewhere on
66 your filesystem and set KERNELSRC= to this directory. You will need to prepare
67 your kernel source treefirst, by running "make menuconfig && make dep && make
68 modules". Once this is done, you can move on to building FreeS/WAN</P>
69
70 <H2><A NAME="building"></A>Building</H2>
71 <H3>The Make Process</H3>
72 <P>There are two parts to building FreeS/WAN - the userland programs and utilities,
73 and the ipsec.o kernel module. Each can be built seperatly, making debugging the
74 build process simpler.
75 </P>
76 <P>Step 1 is to run "make programs". This will build the required libs
77 (libfreeswan.a) as well as all of the userland tools (pluto, whack, etc...).
78 Provided your environment variables are set correctly, you should see the output
79 using your specified gcc (arm-linux-gcc for our example), ld, as, ar and
80 ranlib.</P>
81 <P>If this completes successfully, you can run "make install" to install a copy of
82 all of the binaries, man pages and other documentation to DESTDIR.</P>
83 <P>Step 2 is to build the ipsec.o module. This is done with "make oldmod", which
84 should change into the KERNELSRC directory and then compile and link the required
85 files to generate an ipsec.o file. If this is successful, you will end up with an
86 ipsec.o file in your FreeS/WAN directory, under linux/net/ipsec/.</P>
87 <P>Remember to install this to /lib/modules/$kernelversion/kernel/net/ipsec/ on
88 your target machine.</P>
89
90
91
92 <H2><A NAME="common"></A>Common Problems Building</H2>
93 <P>Here is a list of common problems/errors you may run into when cross compiling
94 FreeS/WAN.</P>
95 <UL>
96 <LI>gmp.h, libgmp not found, error with -lgmp. All of these refer to the GNU Math
97 Precision Library. You will need to have already built this for your target
98 system. Place libgmp.so in LD_LIBRARY_PATH, and ensure the headers are in your
99 include path as well.
100 </UL>
101
102 <P><BR><BR>
103 </P>
104 </BODY>
105 </HTML>