1
0

building.rst 11 KB

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