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