• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _building_libinput:
2
3==============================================================================
4libinput build instructions
5==============================================================================
6
7
8.. contents::
9    :local:
10    :backlinks: entry
11
12Instructions on how to build libinput and its tools and how to build against
13libinput.
14
15The build instruction on this page detail how to overwrite your
16system-provided libinput with one from the git repository, see
17see :ref:`reverting_install` to revert to the previous state.
18
19.. _building:
20
21------------------------------------------------------------------------------
22Building libinput
23------------------------------------------------------------------------------
24
25libinput uses `meson <https://www.mesonbuild.com>`_ and
26`ninja <https://www.ninja-build.org>`_. A build is usually the three-step
27process below.  A successful build requires the
28:ref:`building_dependencies` to be installed before running meson.
29
30
31::
32
33     $> git clone https://gitlab.freedesktop.org/libinput/libinput
34     $> cd libinput
35     $> meson --prefix=/usr builddir/
36     $> ninja -C builddir/
37     $> sudo ninja -C builddir/ install
38
39
40When running libinput versions 1.11.x or earlier, you must run
41
42::
43
44     $> sudo systemd-hwdb update
45
46
47Additional options may also be specified. For example:
48
49::
50
51     $> meson --prefix=/usr -Ddocumentation=false builddir/
52
53
54We recommend that users disable the documentation, it's not usually required
55for testing and reduces the number of dependencies needed.
56
57The ``prefix`` or other options can be changed later with the
58``meson configure`` command. For example:
59
60::
61
62     $> meson configure builddir/ -Dprefix=/some/other/prefix -Ddocumentation=true
63     $> ninja -C builddir
64     $> sudo ninja -C builddir/ install
65
66
67Running ``meson configure builddir/`` with no other arguments lists all
68configurable options meson provides.
69
70To rebuild from scratch, simply remove the build directory and run meson
71again:
72
73::
74
75     $> rm -r builddir/
76     $> meson --prefix=....
77
78
79.. _verifying_install:
80
81..............................................................................
82Verifying the install
83..............................................................................
84
85To verify the install worked correctly, check that libinput.so.x.x.x is in
86the library path and that all symlinks point to the new library.
87
88::
89
90     $> ls -l /usr/lib64/libinput.*
91     -rwxr-xr-x 1 root root    946 Apr 28  2015 /usr/lib64/libinput.la
92     lrwxrwxrwx 1 root root     19 Feb  1 15:12 /usr/lib64/libinput.so -> libinput.so.10.13.0
93     lrwxrwxrwx 1 root root     19 Feb  1 15:12 /usr/lib64/libinput.so.10 -> libinput.so.10.13.0
94     -rwxr-xr-x 1 root root 204992 Feb  1 15:12 /usr/lib64/libinput.so.10.13.0
95
96
97.. _reverting_install:
98
99..............................................................................
100Reverting to the system-provided libinput package
101..............................................................................
102
103The recommended way to revert to the system install is to use the package
104manager to reinstall the libinput package. In some cases, this may leave
105files in the system (e.g. ``/usr/lib/libinput.la``) but these files are
106usually harmless. To definitely remove all files, run the following command
107from the libinput source directory:
108
109
110::
111
112     $> sudo ninja -C builddir/ uninstall
113     # WARNING: Do not restart the computer/X/the Wayland compositor after
114     # uninstall, reinstall the system package immediately!
115
116
117The following commands reinstall the current system package for libinput,
118overwriting manually installed files.
119
120- **Debian/Ubuntu** based distributions: ``sudo apt-get install --reinstall libinput``
121- **Fedora 22** and later: ``sudo dnf reinstall libinput``
122- **RHEL/CentOS/Fedora 21** and earlier: ``sudo yum reinstall libinput``
123- **openSUSE**: ``sudo zypper install --force libinput10``
124- **Arch**: ``sudo pacman -S libinput``
125
126.. _building_selinux:
127
128..............................................................................
129SELinux adjustments
130..............................................................................
131
132.. note:: This section only applies to meson version < 0.42.0
133
134On systems with SELinux, overwriting the distribution-provided package with
135a manually built libinput may cause SELinux denials. This usually manifests
136when gdm does not start because it is denied access to libinput. The journal
137shows a log message in the form of:
138
139
140::
141
142     May 25 15:28:42 localhost.localdomain audit[23268]: AVC avc:  denied  { execute } for  pid=23268 comm="gnome-shell" path="/usr/lib64/libinput.so.10.12.2" dev="dm-0" ino=1709093 scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
143     May 25 15:28:42 localhost.localdomain org.gnome.Shell.desktop[23270]: /usr/bin/gnome-shell: error while loading shared libraries: libinput.so.10: failed to map segment from shared object
144
145
146The summary of this error message is that gdm's gnome-shell runs in the
147``system_u:system_r:xdm_t`` context but libinput is installed with the
148context ``unconfined_u:object_r:user_home_t``.
149
150To avoid this issue, restore the SELinux context for any system files.
151
152
153::
154
155     $> sudo restorecon /usr/lib*/libinput.so.*
156
157
158This issue is tracked in https://github.com/mesonbuild/meson/issues/1967.
159
160.. _building_dependencies:
161
162------------------------------------------------------------------------------
163Build dependencies
164------------------------------------------------------------------------------
165
166libinput has a few build-time dependencies that must be installed prior to
167running meson.
168
169.. hint:: The build dependencies for some distributions can be found in the
170	`GitLab Continuous Integration file <https://gitlab.freedesktop.org/libinput/libinput/blob/master/.gitlab-ci.yml>`_.
171	Search for **FEDORA_RPMS** in the **variables:** definition
172	and check the list for an entry for your distribution.
173
174In most cases, it is sufficient to install the dependencies that your
175distribution uses to build the libinput package.  These can be installed
176with one of the following commands:
177
178- **Debian/Ubuntu** based distributions: ``sudo apt-get build-dep libinput``
179- **Fedora 22** and later: ``sudo dnf builddep libinput``
180- **RHEL/CentOS/Fedora 21** and earlier: ``sudo yum-builddep libinput``
181- **openSUSE**: ::
182
183     $> sudo zypper modifyrepo --enable ``zypper repos | grep source | awk '{print $5}'``
184     $> sudo zypper source-install -d libinput10
185     $> sudo zypper install autoconf automake libtool
186     $> sudo zypper modifyrepo --disable ``zypper repos | grep source | awk '{print $5}'``
187
188
189- **Arch**: ::
190
191     $> sudo pacman -S asp
192     $> cd $(mktemp -d)
193     $> asp export libinput
194     $> cd libinput
195     $> makepkg --syncdeps --nobuild --noextract
196
197
198
199If dependencies are missing, meson shows a message ``No package 'foo'
200found``.  See
201`this blog post here <https://who-t.blogspot.com/2018/07/meson-fails-with-native-dependency-not-found.html>`_
202for instructions on how to fix it.
203
204.. _building_conditional:
205
206------------------------------------------------------------------------------
207Conditional builds
208------------------------------------------------------------------------------
209
210libinput supports several meson options to disable parts of the build. See
211the ``meson_options.txt`` file in the source tree for a full list of
212available options. The default build enables most options and thus requires
213more build dependencies. On systems where build dependencies are an issue,
214options may be disabled with this meson command: ::
215
216    meson --prefix=/usr -Dsomefeature=false builddir
217
218Where ``-Dsomefeature=false`` may be one of:
219
220- ``-Ddocumentation=false``
221    Disables the documentation build (this website). Building the
222    documentation is only needed on the maintainer machine.
223- ``-Dtests=false``
224    Disables the test suite. The test suite is only needed on developer
225    systems.
226- ``-Ddebug-gui=false``
227    Disables the ``libinput debug-gui`` helper tool (see :ref:`tools`),
228    dropping GTK and other build dependencies. The debug-gui is only
229    required for troubleshooting.
230- ``-Dlibwacom=false``
231    libwacom is required by libinput's tablet code to gather additional
232    information about tablets that is not available from the kernel device.
233    It is not recommended to disable libwacom unless libinput is used in an
234    environment where tablet support is not required. libinput provides tablet
235    support even without libwacom, but some features may be missing or working
236    differently.
237
238.. _building_against:
239
240------------------------------------------------------------------------------
241Building against libinput
242------------------------------------------------------------------------------
243
244libinput provides a
245`pkg-config <https://www.freedesktop.org/wiki/Software/pkg-config/>`_ file.
246Software that uses autotools should use the ``PKG_CHECK_MODULES`` autoconf
247macro: ::
248
249    PKG_CHECK_MODULES(LIBINPUT, "libinput")
250
251Software that uses meson should use the ``dependency()`` function: ::
252
253    pkgconfig = import('pkgconfig')
254    dep_libinput = dependency('libinput')
255
256Otherwise, the most rudimentary way to compile and link a program against
257libinput is:
258
259
260::
261
262         gcc -o myprogram myprogram.c ``pkg-config --cflags --libs libinput``
263
264
265For further information on using pkgconfig see the pkg-config documentation.
266