1.. _installing:
2
3Installing Gammu
4================
5
6Prebuilt Binaries for Linux
7---------------------------
8
9Many distributions come with prebuilt Gammu binaries, if you can use
10them, it is definitely the easiest thing. There are also binary packages
11of latest release built for many distributions available on Gammu home
12page <https://wammu.eu/gammu/>.
13
14You can usually also find Gammu in your distribution, so unless you need a
15newer version, just install package from your distribution.
16
17Debian
18++++++
19
20Gammu packages are included in Debian (testing versions go to
21experimental and stable to unstable). If you want to build Debian
22package on your own, you can find packaging in Git repository at
23``https://anonscm.debian.org/git/collab-maint/gammu.git`` (you can browse it on
24<https://anonscm.debian.org/git/collab-maint/gammu.git>).
25
26RPM
27+++
28
29Gammu packages are included in openSUSE and Fedora. Additionally source tarball
30contains :file:`gammu.spec` which you can use for building RPM package.
31
32Slackware
33+++++++++
34
35Gammu packages are included in Gentoo. Additionally source tarball contains
36:file:`description-pak` which you can use for building Slackware package.
37
38Prebuilt Binaries for Windows
39-----------------------------
40
41You can download Windows binaries from <https://wammu.eu/gammu/>. For
42Windows 95, 98 and NT 4.0 you will also need ShFolder DLL, which can be
43downloaded from Microsoft:
44
45http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6AE02498-07E9-48F1-A5D6-DBFA18D37E0F
46
47
48.. _deps:
49
50Dependencies
51------------
52
53You need CMake from <https://cmake.org/> for compiling Gammu.
54
55Additionally pkg-config <https://www.freedesktop.org/wiki/Software/pkg-config/> is used for
56detecting available libraries.
57
58.. _opt-deps:
59
60Optional Dependencies
61---------------------
62
63Gammu does not require any special libraries at all to build, but you might
64miss some features. Optional libraries include:
65
66Bluez-libs
67++++++++++
68
69Required for Bluetooth support on Linux.
70
71.. seealso:: http://www.bluez.org/
72
73libusb-1.0
74++++++++++
75
76Required for fbususb/dku2 connection support on Linux.
77
78.. seealso:: http://libusb.sourceforge.net/
79
80libCURL
81+++++++
82
83Required for new versions notification (see :option:`gammu checkversion`).
84
85.. seealso:: https://curl.haxx.se/libcurl/
86
87libiconv
88++++++++
89
90Used to support more character sets in AT engine.
91
92.. seealso:: https://www.gnu.org/software/libiconv/
93
94Gettext
95+++++++
96
97Localization of strings.
98
99.. seealso:: https://www.gnu.org/software/gettext/
100
101MySQL
102+++++
103
104Required for :ref:`gammu-smsd-mysql` in :ref:`smsd`.
105
106.. seealso:: https://www.mysql.com/
107
108PostgreSQL
109++++++++++
110
111Required for :ref:`gammu-smsd-pgsql` in :ref:`smsd`.
112
113.. seealso:: https://www.postgresql.org/
114
115unixODBC
116++++++++
117
118Required for :ref:`gammu-smsd-odbc` in :ref:`smsd`.
119
120.. note:: Not needed on platforms having native ODBC support such as Microsoft Windows.
121
122.. seealso:: http://www.unixodbc.org/
123
124libdbi
125++++++
126
127Required for :ref:`gammu-smsd-dbi` in :ref:`smsd`.
128
129.. note:: Required at least version 0.8.2.
130
131.. seealso:: http://libdbi.sourceforge.net/
132
133Python
134++++++
135
136Gammu has a Python bindings, see :ref:`python`.
137
138.. seealso:: https://www.python.org/
139
140SQLite + libdbi-drivers with SQLite
141+++++++++++++++++++++++++++++++++++
142
143Needed for testing of SMSD using libdbi driver (libdbd-sqlite3), see :ref:`testing`.
144
145.. seealso:: https://www.sqlite.org/
146
147glib
148++++
149
150Currently needed only for :ref:`gammu-detect`.
151
152.. seealso:: https://www.gtk.org/
153
154gudev
155+++++
156
157Currently needed only for :ref:`gammu-detect`.
158
159.. seealso:: http://gudev.sourceforge.net/
160
161
162Compiling on Linux/Unix Systems
163-------------------------------
164
165First install all :ref:`deps` and :ref:`opt-deps`. Do not forget to install
166corresponding devel packages as well, they are usually named with ``-dev`` or
167``-devel`` suffix, depending on your distribution.
168
169For example on Debian or Ubuntu, you can install all optional packages by
170following command:
171
172.. code-block:: sh
173
174    apt-get install cmake python-dev pkg-config libmysqlclient-dev libpq-dev \
175        libcurl4-gnutls-dev libusb-1.0-0-dev libdbi0-dev libbluetooth-dev \
176        libgudev-1.0-dev libglib2.0-dev unixodbc-dev
177
178For openSUSE, the installation all optional packages could look like:
179
180.. code-block:: sh
181
182    zypper install libusb-1_0-devel libdbi-devel bluez-devel postgresql-devel \
183        mysql-devel python-devel libcurl-devel cmake pkgconfig unixODBC-devel \
184        glib2-devel libgudev-1_0-devel
185
186Configure like wrapper
187++++++++++++++++++++++
188
189For compatibility reasons, configure like wrapper is provided, if you
190don't need much specific tuning, you can use usual set of commands:
191
192.. code-block:: sh
193
194    ./configure
195    make
196    sudo make install
197
198The configure wrapper will create directory build-configure and build all
199binaries there (nothing is changed in source tree), for example gammu binary is
200in build-configure/gammu directory.
201
202Using CMake
203+++++++++++
204
205If you need/want to tweak build a bit more than configure wrapper
206provides, you have to use `CMake`_ directly. For now, only out of source
207build is supported, so you have to create separate directory for build:
208
209.. code-block:: sh
210
211    mkdir build
212    cd build
213
214Then just configure project:
215
216.. code-block:: sh
217
218    cmake ..
219
220Build it:
221
222.. code-block:: sh
223
224    make
225
226Test that everything is okay:
227
228.. code-block:: sh
229
230    make test
231
232And finally install it:
233
234.. code-block:: sh
235
236    sudo make install
237
238You can configure build parameters either by command line (see
239parameters below), or using TUI - ccmake.
240
241Useful cmake parameters:
242
243* ``-DBUILD_SHARED_LIBS=ON`` enables shared library
244* ``-DCMAKE_BUILD_TYPE="Debug"`` enables debug build
245* ``-DCMAKE_INSTALL_PREFIX="/usr"`` change installation prefix
246* ``-DENABLE_PROTECTION=OFF`` disables various compile time protections
247  against buffer overflows and similar attacks
248
249You can also disable support for whole set of phones, e.g.:
250
251* ``-DWITH_NOKIA_SUPPORT=OFF`` disables Nokia phones support
252* ``-DWITH_BLUETOOTH=OFF`` disables Bluetooth support
253* ``-DWITH_IRDA=OFF`` disables IrDA support
254
255Library search paths
256++++++++++++++++++++
257
258By installing Gammu to non default system paths, you might need to add path
259where libGammu and other Gammu liraries are installed to :program:`ldconfig`
260search path.
261
262You can do this by editing :file:`/etc/ld.so.conf` or adding new file to
263:file:`/etc/ld.so.conf.d/` directory containing path, wherge Gammu library has
264been installed. Some examples:
265
266.. code-block:: sh
267
268    # Gammu on 64-bit Fedora installed to /opt/gammu
269    echo /opt/gammu/lib64 > /etc/ld.so.conf.d/gammu.conf
270
271    # Gammu installed to /usr/local
272    echo /usr/local/lib > /etc/ld.so.conf.d/gammu.conf
273
274The similar situation exists with Python modules, if you install in path when
275your Python interpreter does not search it won't load newly installed Gammu
276bindings.
277
278You can also avoid changing ldconfig configuration by installing Gammu to paths
279where it already searches, for examble by:
280
281.. code-block:: sh
282
283   cmake .. -DCMAKE_INSTALL_PREFIX="/usr"
284
285
286Compiling on Microsoft Windows
287------------------------------
288
289First install all :ref:`deps` and :ref:`opt-deps`.
290
291`CMake`_ is able to generate projects for various tools including Microsoft
292Visual Studio, Borland toolchains, Cygwin or Mingw32. Just click on
293CMakeLists.txt in project sources and configure CMake to be able to find
294optional libraries (see cross compilation section for more information about
295getting those). The result should be project for your compiler where you
296should be able to work with it as with any other project.
297
298Compiling using MS Visual C++
299+++++++++++++++++++++++++++++
300
301You will probably need additional SDKs:
302
303* Microsoft Windows Platform SDK (required especially for Bluetooth).
304  It's given for free. Below are links to different releases (if you
305  have problems with latest one, use older). They work for various
306  Windows versions, even though Microsoft named them Windows Server 2003
307  Platform SDK.
308* For free Visual C++ Express 2005 you need to set compiler to work with
309  Platform SDK (see description).
310* MySQL include/library files from MySQL install package (for MySQL
311  support in SMSD).
312* PostgreSQL include/library files from PostgreSQL install package (for
313  PostgreSQL support in SMSD).
314* For gettext (internationalization) support, you will need gettext
315  packages from GnuWin32 project.
316* As build is now based on CMake, you will need to get it from
317  https://cmake.org/.
318
319After downloading and installing them into your system:
320
321* Now you should be able to execute cmake by clicking on CMakeLists.txt
322  file in Gammu sources, this should pop up dialog with configuration
323  options.
324
325  * You can also start CMakeSetup from start menu and select source
326    directory (just point to it to Gammu sources).
327  * Select directory where binaries will be stored, I suggest this is
328    different than source one, eg. append subdirectory build.
329  * Select compiler you want to use in Build for select.
330
331* In list below, you can tweak paths to some optional libraries and
332  project configuration.
333* Then just press Configure button, which will do the hard job. After
334  this, just click OK button to generate Visual Studio project.
335* Project files for Visual Studio should be now generated in directory
336  you selected, just open it in Visual Studio and compile :-).
337
338  * Project file should be named Gammu.dsw or Gammu.sln depending on
339    what MSVC version you choose.
340  * You should see ALL_BUILD target, which builds everything needed,
341    similar to make all on Linux.
342
343* For running testsuite, you need working sh and sed. The easiest way to
344  install them is from MinGW project <http://mingw.org/>.
345
346* I know this guide is incomplete, I don't have environment to test,
347  you're welcome to improve it!. Some more information can be found in
348  howtos for other projects using CMake, eg. Blender, SIM, KDE, VTK,
349  ISGTK. ITK, [wxWidgets http://www.wxwidgets.org/wiki/index.php/CMake].
350
351Compiling using Borland C++
352+++++++++++++++++++++++++++
353
354Borland toolchain - you can download compiler at
355<http://www.codegear.com/downloads/free/cppbuilder>. You need to add
356c:/Borland/BCC55/Bin to system path (or manually set it when running
357CMake) and add -Lc:/Borland/BCC55/Lib -Ic:/Borland/BCC55/Include
358-Lc:/Borland/BCC55/Lib/PSDK to CMAKE_C_FLAGS in CMake (otherwise
359compilation fails).
360
361Compiling using Cygwin
362++++++++++++++++++++++
363
364This should work pretty much same as on Linux.
365
366Compiling on Mac OS X
367---------------------
368
369First install all :ref:`deps` and :ref:`opt-deps`.
370
371Gammu should be compilable on Mac OS X, you need to have installed
372Developer Tols (version 2.4.1 was tested) and `CMake`_ (there is a Mac OS X
373"Darwin" DMG download). For database support in SMSD, install wanted
374database, eg. MySQL.
375
376The rest of the compilation should be pretty same as on Linux, see Linux
377section for more details about compile time options.
378
379If you get some errors while linking with iconv, it is caused by two
380incompatible iconv libraries available on the system. You can override the
381library name:
382
383.. code-block:: sh
384
385   cmake -D ICONV_LIBRARIES="/opt/local/lib/libiconv.dylib" ..
386
387Or completely disable iconv support:
388
389.. code-block:: sh
390
391   cmake -DWITH_Iconv=OFF ..
392
393To build backward compatible binaries, you need CMake 2.8 or newer. The
394command line then would look like:
395
396.. code-block:: sh
397
398    cmake -DCMAKE_OSX_ARCHITECTURES="ppc;i386;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.4
399
400
401Cross compilation for Windows on Linux
402--------------------------------------
403
404First install all :ref:`deps` and :ref:`opt-deps` into your mingw build
405environment.
406
407Only cross compilation using `CMake`_ has been tested. You need to install
408MinGW cross tool chain and run time. On Debian you can do it by apt-get
409install mingw32. Build is then quite simple:
410
411.. code-block:: sh
412
413    mkdir build-win32
414    cd build-win32
415    cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake
416    make
417
418There is also toolchain configuration for Win64 available:
419
420.. code-block:: sh
421
422    mkdir build-win64
423    cd build-win64
424    cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake
425    make
426
427If your MinGW cross compiler binaries are not found automatically, you
428can specify their different names in cmake/Toolchain-mingw32.cmake.
429
430To build just bare static library without any dependencies, use:
431
432.. code-block:: sh
433
434    cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake \
435        -DBUILD_SHARED_LIBS=OFF \
436        -DWITH_MySQL=OFF \
437        -DWITH_Postgres=OFF \
438        -DWITH_GettextLibs=OFF \
439        -DWITH_Iconv=OFF \
440        -DWITH_CURL=OFF
441
442To be compatible with current Python on Windows, we need to build
443against matching Microsoft C Runtime library. For Python 2.4 and 2.5
444MSVCR71 was used, for Python 2.6 the right one is MSVCR90. To achieve
445building against different MSVCRT, you need to adjust compiler
446specifications, example is shown in cmake/mingw.spec, which is used by
447CMakeLists.txt. You might need to tune it for your environment.
448
449Third party libraries
450+++++++++++++++++++++
451
452The easiest way to link with third party libraries is to add path to
453their installation to cmake/Toolchain-mingw32.cmake or to list these
454paths in CMAKE_FIND_ROOT_PATH when invoking cmake.
455
456
457MySQL
458~~~~~
459
460You can download MySQL binaries from <http://dev.mysql.com/>, but then
461need some tweaks:
462
463.. code-block:: sh
464
465    cd mysql/lib/opt
466    reimp.exe -d libmysql.lib
467    i586-mingw32msvc-dlltool --kill-at --input-def libmysql.def \
468        --dllname libmysql.dll --output-lib libmysql.a
469
470reimp.exe is part of mingw-utils and can be run through wine, I didn't
471try to compile native binary from it.
472
473
474PostgreSQL
475~~~~~~~~~~
476
477You can download PostgreSQL binaries from <http://www.postgresql.org/>,
478but then you need to add wldap32.dll library to bin.
479
480
481Gettext
482~~~~~~~
483
484For Gettext (internationalization support), you need
485gettext-0.14.4-bin.zip, gettext-0.14.4-dep.zip, gettext-0.14.4-lib.zip
486from <http://gnuwin32.sourceforge.net/>. Unpack these to same directory.
487
488
489CURL
490~~~~
491
492For CURL support, you need curl-7.19.0-devel-mingw32.zip from
493<http://curl.haxx.se/>.
494
495Crosscompiling to different platform
496------------------------------------
497
498To cross compile Gammu to different architecture (or platform) you need to
499provide CMake toolchain file for that and invoke `CMake`_ with it:
500
501.. code-block:: sh
502
503    cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-eldk-ppc74xx.cmake ..
504
505More information on creating that is described in `CMake Cross Compiling`_ wiki
506page. Also distributions like `OpenEmbedded`_ usually already come with
507prepared recipes for `CMake`_.
508
509.. _CMake Cross Compiling: http://www.vtk.org/Wiki/CMake_Cross_Compiling
510.. _OpenEmbedded: http://www.openembedded.org/
511
512Advanced Build Options
513----------------------
514
515The build system accepts wide range of options. You can see them all by
516running GUI version of `CMake`_ or by inspecting :file:`CMakeCache.txt` in
517build directory.
518
519Limiting set of installed data
520++++++++++++++++++++++++++++++
521
522By setting following flags you can control which additional parts will
523be installed:
524
525* INSTALL_GNAPPLET - Install Gnapplet binaries
526* INSTALL_MEDIA - Install sample media files
527* INSTALL_PHP_EXAMPLES - Install PHP example scripts
528* INSTALL_BASH_COMPLETION - Install bash completion script for Gammu
529* INSTALL_LSB_INIT - Install LSB compatible init script for Gammu
530* INSTALL_DOC - Install documentation
531* INSTALL_LOC - Install locales data
532
533For example:
534
535.. code-block:: sh
536
537    cmake -DINSTALL_DOC=OFF
538
539
540Debugging build failures
541++++++++++++++++++++++++
542
543If there is some build failure (eg. some dependencies are not correctly
544detected), please attach :file:`CMakeCache.txt`,
545:file:`CMakeFiles/CMakeError.log` and :file:`CMakeFiles/CMakeOutput.log` files
546to the report. It will help diagnose what was detected on the system and
547possibly fix these errors.
548
549To find out what is going on during compilation, add
550``-DCMAKE_VERBOSE_MAKEFILE=ON`` to :program:`cmake` command line or run
551:program:`make` with ``VERBOSE=1``:
552
553.. code-block:: sh
554
555    make VERBOSE=1
556
557Debugging crashes
558+++++++++++++++++
559
560To debug program crashes, you might want to build Gammu with
561``-DENABLE_PROTECTION=OFF``, otherwise debugging tools are somehow confused
562with protections GCC makes and produce bogus back traces.
563
564
565Compiling python-gammu
566----------------------
567
568Currently python-gammu is distributed as a separate package, which follows
569Python usual method for building modules - distutils, so use :file:`setup.py`
570is placed in the top level directory:
571
572.. code-block:: sh
573
574    ./setup.py build
575    sudo ./setup.py install
576
577You can install it using pip installer:
578
579.. code-block:: sh
580
581    pip install python-gammu
582
583You need to have Gammu installed for compiling python-gammu. It's location is
584discovered using pkg-config or by GAMMU_PATH environment variable. The latter
585is recommended when building on Windows.
586
587.. _CMake: http://www.cmake.org/
588