Build from Source » History » Version 59
fixeria, 08/06/2019 11:24 AM
1 | 1 | neels | h1. Build from Source |
---|---|---|---|
2 | 58 | fixeria | |
3 | {{>toc}} |
||
4 | 1 | neels | |
5 | 59 | fixeria | bq. *Before you consider building from source, be aware that there are [[Binary Packages]] available for Debian + Ubuntu platforms. These are recommended for normal users.* |
6 | 1 | neels | |
7 | 5 | neels | Osmocom projects use autoconf/automake. |
8 | 2 | neels | The general pattern for building is: |
9 | 1 | neels | |
10 | <pre> |
||
11 | cd source-tree |
||
12 | autoreconf -fi |
||
13 | 50 | osmith | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" |
14 | 1 | neels | ./configure |
15 | make |
||
16 | make check |
||
17 | 46 | osmith | sudo make install |
18 | 15 | wirelesss | sudo ldconfig |
19 | 1 | neels | </pre> |
20 | |||
21 | 3 | neels | The @./configure@ step may need further configuration options, and |
22 | @./configure@ will tell you which dependencies are still missing, if any. |
||
23 | See below for project specific details and troubleshooting. |
||
24 | 1 | neels | |
25 | 6 | neels | The @make@ step may be sped up by using multiple CPU cores: |
26 | 1 | neels | |
27 | <pre> |
||
28 | make -j 8 |
||
29 | </pre> |
||
30 | |||
31 | We take care to make our builds parallelizable with @-j@, but in case |
||
32 | 41 | neels | @make -j@ fails, issuing a simple @make@ could fix the problem. |
33 | 1 | neels | |
34 | h1. Dependencies |
||
35 | |||
36 | Which libraries are needed by various Osmocom programs is best resolved during |
||
37 | the @./configure@ step described below. This script checks for any missing |
||
38 | 6 | neels | dependencies and issues corresponding error messages. |
39 | 1 | neels | |
40 | Here is a (probably incomplete) overview of dependencies between Osmocom |
||
41 | projects: |
||
42 | |||
43 | | _To build ..._ | _... you also need ..._ | |
||
44 | | osmo-bts | libosmocore, libosmo-abis, openbsc (source tree only), L1 headers depending on BTS model | |
||
45 | | osmo-pcu | libosmocore, L1 headers depending on BTS model | |
||
46 | 40 | neels | | osmo-hlr | libosmocore, libosmo-abis | |
47 | | osmo-mgw | libosmocore, libosmo-abis, libosmo-netif | |
||
48 | | osmo-msc | libosmocore, libosmo-abis, libosmo-netif, libosmo-sccp, osmo-mgw (for libosmo-mgcp-client), libsmpp34 (for --enable-smpp); for 3G, use --enable-iu and add: osmo-iuh, libasn1c | |
||
49 | | osmo-bsc | libosmocore, libosmo-abis, libosmo-netif, libosmo-sccp, osmo-mgw (for libosmo-mgcp-client) | |
||
50 | | osmo-sgsn | libosmocore, osmo-ggsn; for 3G, use --enable-iu and add: osmo-iuh, libasn1c | |
||
51 | | osmo-ggsn | libosmocore | |
||
52 | 53 | osmith | | osmo-sip-connector | libosmocore | |
53 | 55 | osmith | | osmo-trx | libosmocore | |
54 | 1 | neels | |
55 | 20 | Darkstar | h1. External dependencies |
56 | |||
57 | 21 | neels | If you want to build on specific Linux distros, you might need to install additional dependencies before the build will succeed |
58 | -- this is a collection of various dependencies used by various osmocom projects: |
||
59 | 20 | Darkstar | |
60 | | _To build on ..._ | _...you might need to install these packages:_ | |
||
61 | 33 | pespin | |Ubuntu 16.10 | libpcsclite-dev libtalloc-dev libortp-dev libsctp-dev libmnl-dev libdbi-dev libdbd-sqlite3 libsqlite3-dev sqlite3 libc-ares-dev libgnutls-dev | |
62 | 56 | osmith | |Debian 8 and 9| build-essential gcc g++ make automake autoconf libtool pkg-config libtalloc-dev libpcsclite-dev libortp-dev libsctp-dev libssl-dev libdbi-dev libdbd-sqlite3 libsqlite3-dev libpcap-dev libc-ares-dev libgnutls28-dev libsctp-dev sqlite3 libsofia-sip-ua-glib-dev libuhd-dev libusb-1.0-0-dev | |
63 | 22 | laforge | |FreeBSD 11|automake autoconf libtool git pkgconf talloc pcsc-lite python gmake ortp| |
64 | 52 | osmith | |Fedora 28|@development-tools autoconf automake gnutls-devel libtool libtalloc-devel pcsc-lite-devel ortp-devel openssl-devel lksctp-tools-devel libmnl-devel libdbi-devel libdbi-dbd-sqlite libpcap-devel sqlite-devel gcc-g++ uhd-devel libusb-devel fftw-devel boost-devel| |
65 | 20 | Darkstar | |
66 | 1 | neels | h1. Download Sources |
67 | |||
68 | 3 | neels | The latest Osmocom sources are available from git at https://git.osmocom.org, |
69 | where each project's overview page displays the actual git URL. |
||
70 | |||
71 | 1 | neels | The projects' repository URLs generally are of the pattern: |
72 | 3 | neels | <pre>git://git.osmocom.org/project-name</pre> |
73 | 6 | neels | (To contribute, see [[Coding Standards#Submitting-Patches|Submitting Patches]]) |
74 | 3 | neels | |
75 | For example, to verify libosmocore's git repository URL, browse to |
||
76 | 1 | neels | https://git.osmocom.org/libosmocore/ and observe the URL shown at the |
77 | 3 | neels | bottom of the page under _Clone_: @git://git.osmocom.org/libosmocore@ |
78 | |||
79 | 6 | neels | Then download this URL using the @git@ client: |
80 | 3 | neels | |
81 | 1 | neels | <pre> |
82 | git clone git://git.osmocom.org/libosmocore |
||
83 | </pre> |
||
84 | |||
85 | 6 | neels | It is also possible to download specific releases' tarballs for each git ref |
86 | that is defined. For example, browse to https://git.osmocom.org/libosmocore/, |
||
87 | click on _refs_ on the top and select any branch or tag, e.g. "0.9.0":https://git.osmocom.org/libosmocore/tag/?h=0.9.0 |
||
88 | |||
89 | 16 | neels | All of these download instructions hold true for any of the git repositories, |
90 | not limited to libosmocore. |
||
91 | 6 | neels | |
92 | 17 | neels | h1. Build debian packages |
93 | 1 | neels | |
94 | 17 | neels | Most Osmocom projects are setup and ready for building debian packages. |
95 | See the @debian/@ subdir in each source tree. |
||
96 | 13 | wirelesss | |
97 | 17 | neels | For example, to build a libosmocore debian package: |
98 | 1 | neels | |
99 | <pre> |
||
100 | 17 | neels | cd libosmocore/ |
101 | 57 | osmith | sudo apt-get build-dep . |
102 | 13 | wirelesss | dpkg-buildpackage -tc -uc -us |
103 | 17 | neels | # then, you can install the package on your system with |
104 | sudo dpkg -i ../libosmocore*.deb |
||
105 | 13 | wirelesss | </pre> |
106 | |||
107 | 17 | neels | These steps are identical for all other Osmocom projects that are ready for debian packaging. |
108 | 13 | wirelesss | |
109 | 17 | neels | Advantages of debian packages: |
110 | * they allow you to easily install the same binaries on several machines, |
||
111 | * you don't need to keep the source tree around, |
||
112 | * they guarantee a clean de-installation later. |
||
113 | |||
114 | Note: when not using debian packages, i.e. after a '@make install@' directly from the source tree, |
||
115 | you can also achieve a clean de-installation with '@make uninstall@'. |
||
116 | 11 | wirelesss | |
117 | 12 | wirelesss | h1. Details and Troubleshooting |
118 | 11 | wirelesss | |
119 | 12 | wirelesss | Here is a list of the most common configuration items or pitfalls to be |
120 | aware of when building specific Osmocom projects. |
||
121 | |||
122 | 6 | neels | |
123 | h2. Non-GNU Systems |
||
124 | |||
125 | On systems like FreeBSD, you need to run @gmake@ instead of @make@. |
||
126 | |||
127 | 7 | neels | h2. Cross-Compiling for a BTS Platform |
128 | |||
129 | To build new software for the sysmoBTS and Litecell 1.5, you will typically |
||
130 | cross-compile using an SDK matching the BTS. You should find specific instructions |
||
131 | in, for example, the sysmoBTS manual. |
||
132 | |||
133 | 6 | neels | h2. General ./configure options |
134 | |||
135 | To provide the installation location, which is /usr/local by default: |
||
136 | <pre> |
||
137 | ./configure --prefix=$HOME/my_osmocom_inst |
||
138 | </pre> |
||
139 | |||
140 | If you choose a non-standard location, later builds may fail to find it. |
||
141 | For example, if you built libosmocore with a custom prefix, a subsequent |
||
142 | build of libosmo-abis, which needs libosmocore installed, may fail. |
||
143 | You can tell a build process where to look for libraries to compile against |
||
144 | using the @PKG_CONFIG_PATH@ environment variable. |
||
145 | |||
146 | Furthermore, when you want to run binaries compiled against libraries |
||
147 | installed in a non-standard location, you will have to use the |
||
148 | @LD_LIBRARY_PATH@ environment variable to successfully load the binary. |
||
149 | Particularly, the @make check@ step typically runs such binaries, |
||
150 | as well as when you would like to run the installed binaries yourself. |
||
151 | |||
152 | For example: |
||
153 | |||
154 | <pre> |
||
155 | mkdir -p $HOME/osmo/src |
||
156 | cd $HOME/osmo/src |
||
157 | git clone git://git.osmocom.org/libosmocore |
||
158 | cd libosmocore |
||
159 | autoreconf -fi |
||
160 | ./configure --prefix=$HOME/osmo/inst --disable-pcsc |
||
161 | make -j5 |
||
162 | 7 | neels | make check |
163 | make install |
||
164 | 36 | neels | sudo ldconfig |
165 | 7 | neels | |
166 | cd .. |
||
167 | git clone git://git.osmocom.org/libosmo-abis |
||
168 | cd libosmo-abis |
||
169 | autoreconf -fi |
||
170 | export PKG_CONFIG_PATH=$HOME/osmo/inst/lib/pkgconfig |
||
171 | ./configure --prefix=$HOME/osmo/inst |
||
172 | make -j5 |
||
173 | export LD_LIBRARY_PATH=$HOME/osmo/inst/lib |
||
174 | make check |
||
175 | make install |
||
176 | 36 | neels | sudo ldconfig |
177 | 6 | neels | </pre> |
178 | |||
179 | 7 | neels | Note that PKG_CONFIG_PATH points at the prefix's lib/pkgconfig and is needed |
180 | during the configure step of a library; |
||
181 | |||
182 | And that LD_LIBRARY_PATH is needed when running binaries that need libraries |
||
183 | installed in the non-standard location, here via @make check@. |
||
184 | |||
185 | Furthermore, when installing to an SDK's sysroot location, you would usually |
||
186 | set @DESTDIR@ to the sysroot with @--prefix=/usr@, resulting in an install |
||
187 | location of @$DESTDIR/usr@. |
||
188 | |||
189 | 6 | neels | h2. libosmocore |
190 | |||
191 | When @libpcsclite@ is not easily available, e.g. when building for a BTS target platform: |
||
192 | <pre> |
||
193 | ./configure --disable-pcsc |
||
194 | </pre> |
||
195 | 1 | neels | |
196 | 7 | neels | h2. openbsc |
197 | |||
198 | @openbsc@ is so far the only source tree where the build commands must be run |
||
199 | a level deeper than the source tree's root. Enter the second @openbsc@ dir: |
||
200 | |||
201 | <pre> |
||
202 | git clone git://git.osmocom.org/openbsc |
||
203 | cd openbsc/openbsc |
||
204 | autoreconf -fi |
||
205 | [...] |
||
206 | </pre> |
||
207 | |||
208 | 37 | neels | h2. osmo-msc and osmo-sgsn for 3G |
209 | 19 | neels | |
210 | 37 | neels | Be sure to pass the @--enable-iu@ configure option to enable Iu interface support. |
211 | 19 | neels | |
212 | <pre> |
||
213 | 37 | neels | cd osmo-msc |
214 | 19 | neels | ./configure --enable-iu |
215 | </pre> |
||
216 | |||
217 | 38 | neels | h1. Example: completely build osmo-bsc, osmo-msc, osmo-sgsn and osmo-ggsn |
218 | 7 | neels | |
219 | 39 | pespin | This is an example of a complete build process for 2G+3G core network, |
220 | 7 | neels | including SMPP and the "nat" binaries, to the @/usr/local@ prefix; it is assumed |
221 | that your system by default scans @/usr/local@ for installed libraries: |
||
222 | 1 | neels | |
223 | 39 | pespin | If you don't require 3G, you can omit build of osmo-iuh and remove configure flag "--enable-iu" in osmo-msc and osmo-sgsn. |
224 | |||
225 | 7 | neels | <pre> |
226 | osmo_src=$HOME/osmo/src |
||
227 | mkdir -p $osmo_src |
||
228 | |||
229 | cd $osmo_src |
||
230 | git clone git://git.osmocom.org/libosmocore |
||
231 | cd libosmocore |
||
232 | autoreconf -fi |
||
233 | ./configure |
||
234 | make -j5 |
||
235 | make check |
||
236 | 1 | neels | make install |
237 | 38 | neels | sudo ldconfig |
238 | 7 | neels | |
239 | cd $osmo_src |
||
240 | git clone git://git.osmocom.org/libosmo-abis |
||
241 | cd libosmo-abis |
||
242 | autoreconf -fi |
||
243 | ./configure |
||
244 | make -j5 |
||
245 | make check |
||
246 | 1 | neels | make install |
247 | 38 | neels | sudo ldconfig |
248 | 7 | neels | |
249 | cd $osmo_src |
||
250 | git clone git://git.osmocom.org/libosmo-netif |
||
251 | cd libosmo-netif |
||
252 | autoreconf -fi |
||
253 | ./configure |
||
254 | make -j5 |
||
255 | make check |
||
256 | 1 | neels | make install |
257 | 38 | neels | sudo ldconfig |
258 | 7 | neels | |
259 | cd $osmo_src |
||
260 | git clone git://git.osmocom.org/libosmo-sccp |
||
261 | cd libosmo-sccp |
||
262 | autoreconf -fi |
||
263 | ./configure |
||
264 | make -j5 |
||
265 | make check |
||
266 | 1 | neels | make install |
267 | 38 | neels | sudo ldconfig |
268 | 7 | neels | |
269 | cd $osmo_src |
||
270 | git clone git://git.osmocom.org/libsmpp34 |
||
271 | cd libsmpp34 |
||
272 | autoreconf -fi |
||
273 | ./configure |
||
274 | make |
||
275 | make check |
||
276 | 1 | neels | make install |
277 | 38 | neels | sudo ldconfig |
278 | 1 | neels | |
279 | 7 | neels | cd $osmo_src |
280 | 38 | neels | git clone git://git.osmocom.org/osmo-mgw |
281 | cd osmo-mgw |
||
282 | 7 | neels | autoreconf -fi |
283 | ./configure |
||
284 | 1 | neels | make -j5 |
285 | make check |
||
286 | make install |
||
287 | 38 | neels | sudo ldconfig |
288 | 1 | neels | |
289 | cd $osmo_src |
||
290 | 38 | neels | git clone git://git.osmocom.org/libasn1c |
291 | cd libasn1c |
||
292 | 1 | neels | autoreconf -fi |
293 | 38 | neels | ./configure |
294 | 1 | neels | make |
295 | 39 | pespin | make check |
296 | make install |
||
297 | sudo ldconfig |
||
298 | |||
299 | cd $osmo_src |
||
300 | git clone git://git.osmocom.org/osmo-iuh |
||
301 | cd osmo-iuh |
||
302 | autoreconf -fi |
||
303 | ./configure |
||
304 | make -j5 |
||
305 | 38 | neels | make check |
306 | make install |
||
307 | sudo ldconfig |
||
308 | |||
309 | cd $osmo_src |
||
310 | git clone git://git.osmocom.org/osmo-msc |
||
311 | cd osmo-msc |
||
312 | autoreconf -fi |
||
313 | ./configure --enable-iu |
||
314 | 1 | neels | make -j5 |
315 | make check |
||
316 | make install |
||
317 | 38 | neels | sudo ldconfig |
318 | 1 | neels | |
319 | 38 | neels | cd $osmo_src |
320 | 42 | neels | git clone git://git.osmocom.org/osmo-ggsn |
321 | cd osmo-ggsn |
||
322 | 38 | neels | autoreconf -fi |
323 | 42 | neels | ./configure |
324 | 38 | neels | make -j5 |
325 | make check |
||
326 | make install |
||
327 | sudo ldconfig |
||
328 | |||
329 | cd $osmo_src |
||
330 | 42 | neels | git clone git://git.osmocom.org/osmo-sgsn |
331 | cd osmo-sgsn |
||
332 | 38 | neels | autoreconf -fi |
333 | 42 | neels | ./configure --enable-iu |
334 | 1 | neels | make -j5 |
335 | 38 | neels | make check |
336 | make install |
||
337 | sudo ldconfig |
||
338 | |||
339 | 42 | neels | export LD_LIBRARY_PATH="/usr/local/lib" |
340 | export PATH="$PATH:/usr/local/bin" |
||
341 | 38 | neels | which osmo-msc |
342 | osmo-msc --version |
||
343 | 6 | neels | </pre> |
344 | |||
345 | 9 | neels | h1. Example: build script |
346 | 31 | laforge | |
347 | 9 | neels | This is a shell script that builds openbsc and osmo-ggsn, |
348 | expecting the git clones to be ready in the current directory: |
||
349 | |||
350 | 1 | neels | attachment:build_2G.sh |
351 | 43 | neels | |
352 | h1. Example: top-level Makefile |
||
353 | |||
354 | I (neels) use a top-level makefile to manage various configurations and build all source trees in sequence. |
||
355 | See https://git.osmocom.org/osmo-dev and look at the readme file. |
||
356 | 47 | osmith | |
357 | h1. Example: script for cloning and building a single project |
||
358 | |||
359 | <pre> |
||
360 | #!/bin/sh -e |
||
361 | |||
362 | # Location where the git repositories will be stored (must exist) |
||
363 | DIR=~/code |
||
364 | |||
365 | # Check usage |
||
366 | if [ -z "$1" ]; then |
||
367 | echo "usage: $(basename $0) PROJECT" |
||
368 | exit 1 |
||
369 | fi |
||
370 | |||
371 | # Clone |
||
372 | 49 | osmith | cd $DIR |
373 | 47 | osmith | if ! [ -d "$1" ]; then |
374 | git clone "git://git.osmocom.org/$1" |
||
375 | fi |
||
376 | |||
377 | # Build |
||
378 | 50 | osmith | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/" |
379 | 49 | osmith | cd $1 |
380 | 47 | osmith | autoreconf -fi |
381 | ./configure |
||
382 | make -j3 |
||
383 | make check |
||
384 | sudo make install |
||
385 | sudo ldconfig |
||
386 | </pre> |