Compile Manually

Version 7 (Ilario Gelmetti, 08/02/2014 07:10 pm)

1 1 Gioacchino Mazzurco
h1. Compile Manually
2 2 Ilario Gelmetti
3 7 Ilario Gelmetti
h2. Using lime-build
4 7 Ilario Gelmetti
5 7 Ilario Gelmetti
*Resources needed:*
6 7 Ilario Gelmetti
7 7 Ilario Gelmetti
Probably a Linux based operating system.
8 7 Ilario Gelmetti
9 7 Ilario Gelmetti
Some tools for the compilation process, on Debian:
10 7 Ilario Gelmetti
11 7 Ilario Gelmetti
<pre>
12 7 Ilario Gelmetti
apt-get install git build-essential libncurses5-dev zlib1g-dev gawk subversion
13 7 Ilario Gelmetti
</pre>
14 7 Ilario Gelmetti
15 7 Ilario Gelmetti
About 9 GB of disk space.
16 7 Ilario Gelmetti
17 7 Ilario Gelmetti
About 3 hours of compilation time.
18 7 Ilario Gelmetti
19 7 Ilario Gelmetti
*Download* the *lime-build* source:
20 7 Ilario Gelmetti
21 7 Ilario Gelmetti
<pre>
22 7 Ilario Gelmetti
git clone https://github.com/libre-mesh/lime-build.git
23 7 Ilario Gelmetti
</pre>
24 7 Ilario Gelmetti
25 7 Ilario Gelmetti
Have a look at the list of devices supported by lime-build:
26 7 Ilario Gelmetti
27 7 Ilario Gelmetti
<pre>
28 7 Ilario Gelmetti
make list_targets
29 7 Ilario Gelmetti
</pre>
30 7 Ilario Gelmetti
31 7 Ilario Gelmetti
if you see your device you can continue with this guide, otherwise you have to use the instructions in the section "Starting from a new compilation of OpenWrt".
32 7 Ilario Gelmetti
33 7 Ilario Gelmetti
Compile specifying the target device in T= and roughly the number of CPU cores plus one in J=. That is, for compiling on a dual core computer the image for Ubiquiti NanoStation M5:
34 7 Ilario Gelmetti
35 7 Ilario Gelmetti
<pre>
36 7 Ilario Gelmetti
make J=3 T=nsm5 build
37 7 Ilario Gelmetti
</pre>
38 7 Ilario Gelmetti
39 7 Ilario Gelmetti
You'll find the compiled images in the directory images.
40 7 Ilario Gelmetti
41 7 Ilario Gelmetti
Other options for lime-build are documented here: [[https://github.com/libre-mesh/lime-build/blob/master/README.md]]
42 7 Ilario Gelmetti
43 7 Ilario Gelmetti
44 7 Ilario Gelmetti
45 7 Ilario Gelmetti
46 5 Ilario Gelmetti
h2. Starting from a new compilation of OpenWrt
47 2 Ilario Gelmetti
48 2 Ilario Gelmetti
*Resources needed:*
49 2 Ilario Gelmetti
50 2 Ilario Gelmetti
Probably a Linux based operating system.
51 2 Ilario Gelmetti
52 2 Ilario Gelmetti
Some tools for the compilation process, on Debian:
53 2 Ilario Gelmetti
54 4 Gioacchino Mazzurco
<pre>
55 4 Gioacchino Mazzurco
apt-get install git build-essential libncurses5-dev zlib1g-dev gawk subversion
56 4 Gioacchino Mazzurco
</pre>
57 2 Ilario Gelmetti
58 2 Ilario Gelmetti
About 9 GB of disk space.
59 2 Ilario Gelmetti
60 2 Ilario Gelmetti
About 3 hours of compilation time.
61 2 Ilario Gelmetti
62 1 Gioacchino Mazzurco
*Download trunk version of OpenWrt* (Attitude Adjustment isn't supported by Libre-Mesh).
63 1 Gioacchino Mazzurco
64 4 Gioacchino Mazzurco
<pre>
65 4 Gioacchino Mazzurco
git clone git://git.openwrt.org/openwrt.git
66 4 Gioacchino Mazzurco
</pre>
67 1 Gioacchino Mazzurco
68 1 Gioacchino Mazzurco
*Add our repositories* to the default ones.
69 4 Gioacchino Mazzurco
70 4 Gioacchino Mazzurco
<pre>
71 4 Gioacchino Mazzurco
cd openwrt
72 2 Ilario Gelmetti
cp feeds.conf.default feeds.conf
73 2 Ilario Gelmetti
echo "src-git libremap git://github.com/libremap/libremap-agent-openwrt.git" >> feeds.conf
74 4 Gioacchino Mazzurco
echo "src-git lime https://github.com/libre-mesh/lime-packages.git" >> feeds.conf
75 4 Gioacchino Mazzurco
</pre>
76 1 Gioacchino Mazzurco
77 2 Ilario Gelmetti
If you want to use a specific branch of lime-packages specify it adding ;nameofthebranch at the end of the last line. For example:
78 1 Gioacchino Mazzurco
79 4 Gioacchino Mazzurco
<pre>
80 4 Gioacchino Mazzurco
src-git lime https://github.com/libre-mesh/lime-packages.git;develop
81 4 Gioacchino Mazzurco
</pre>
82 2 Ilario Gelmetti
83 2 Ilario Gelmetti
Download all these packages and put sources in the right place.
84 1 Gioacchino Mazzurco
85 4 Gioacchino Mazzurco
<pre>
86 4 Gioacchino Mazzurco
scripts/feeds update -a
87 4 Gioacchino Mazzurco
scripts/feeds install -a
88 4 Gioacchino Mazzurco
</pre>
89 2 Ilario Gelmetti
90 2 Ilario Gelmetti
Then enter the OpenWrt *configuration* menu.
91 2 Ilario Gelmetti
92 4 Gioacchino Mazzurco
<pre>
93 4 Gioacchino Mazzurco
make menuconfig
94 4 Gioacchino Mazzurco
</pre>
95 1 Gioacchino Mazzurco
96 1 Gioacchino Mazzurco
Go in "Base system" and *deselect "dnsmasq"* (this is the IPv4 version which conflicts with Libre-Mesh, the IPv6 version will be automatically selected).
97 1 Gioacchino Mazzurco
98 2 Ilario Gelmetti
Exit from "Base system" end *enter in "LiMe", select what you want* (for example everything or everything except reghack and lime-full), exit.
99 2 Ilario Gelmetti
100 1 Gioacchino Mazzurco
If you need to compile images only for one type of devices you could specify the type in the menu "Target system" and "Target profile", otherwise keep the default and images for each profile will be produced. Exit and save.
101 1 Gioacchino Mazzurco
102 6 Ilario Gelmetti
Launch the *compilation*. The make -j [number] makes the compiler use multiple cores. If you have more than 2 cores, change to the appropriate number. 
103 2 Ilario Gelmetti
104 4 Gioacchino Mazzurco
<pre>
105 6 Ilario Gelmetti
make -j 3
106 4 Gioacchino Mazzurco
</pre>
107 1 Gioacchino Mazzurco
108 6 Ilario Gelmetti
But if you encounter some errors (maybe related to network connectivity problems) it's better to clean up with
109 2 Ilario Gelmetti
110 4 Gioacchino Mazzurco
<pre>
111 6 Ilario Gelmetti
make clean
112 4 Gioacchino Mazzurco
</pre>
113 2 Ilario Gelmetti
114 6 Ilario Gelmetti
and compile without the -j option.
115 1 Gioacchino Mazzurco
116 1 Gioacchino Mazzurco
<pre>
117 6 Ilario Gelmetti
make
118 4 Gioacchino Mazzurco
</pre>
119 2 Ilario Gelmetti
120 2 Ilario Gelmetti
Flash on your devices and enjoy!
121 1 Gioacchino Mazzurco
122 1 Gioacchino Mazzurco
123 6 Ilario Gelmetti
124 6 Ilario Gelmetti
125 5 Ilario Gelmetti
h2. Updating a previous compilation of Libre-Mesh
126 5 Ilario Gelmetti
127 5 Ilario Gelmetti
Enter the base directory of the previous compiled image, for example
128 5 Ilario Gelmetti
129 5 Ilario Gelmetti
<pre>
130 5 Ilario Gelmetti
cd ~/openwrt
131 5 Ilario Gelmetti
</pre>
132 5 Ilario Gelmetti
133 5 Ilario Gelmetti
Remove the unnecessary previously compiled files.
134 5 Ilario Gelmetti
135 5 Ilario Gelmetti
<pre>
136 5 Ilario Gelmetti
make clean
137 5 Ilario Gelmetti
</pre>
138 5 Ilario Gelmetti
139 5 Ilario Gelmetti
Update the OpenWrt source code.
140 5 Ilario Gelmetti
141 5 Ilario Gelmetti
<pre>
142 5 Ilario Gelmetti
git pull
143 5 Ilario Gelmetti
</pre>
144 5 Ilario Gelmetti
145 5 Ilario Gelmetti
Update the Libre-Mesh package source code.
146 5 Ilario Gelmetti
147 5 Ilario Gelmetti
<pre>
148 5 Ilario Gelmetti
scripts/feeds update -a
149 5 Ilario Gelmetti
scripts/feeds install -a
150 5 Ilario Gelmetti
</pre>
151 5 Ilario Gelmetti
152 6 Ilario Gelmetti
Launch the compilation. The make -j [number] makes the compiler use multiple cores. If you have more than 2 cores, change to the appropriate number. 
153 5 Ilario Gelmetti
154 5 Ilario Gelmetti
<pre>
155 6 Ilario Gelmetti
make -j 3
156 5 Ilario Gelmetti
</pre>
157 5 Ilario Gelmetti
158 6 Ilario Gelmetti
If you encounter some errors try compiling without the -j option or cleaning completely the installation environment
159 5 Ilario Gelmetti
160 5 Ilario Gelmetti
<pre>
161 5 Ilario Gelmetti
make clean
162 5 Ilario Gelmetti
make dirclean
163 5 Ilario Gelmetti
rm -rf feeds/*
164 5 Ilario Gelmetti
</pre>
165 5 Ilario Gelmetti
166 5 Ilario Gelmetti
and restart from the top of this section about updating.