Project

General

Profile

Build from Source » History » Version 57

osmith, 04/05/2019 11:53 AM
installing debian builddepends works with "sudo apt-get build-dep"

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