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