meson.build 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. project(
  2. 'gamemode',
  3. 'c',
  4. default_options : ['c_std=c11', 'warning_level=3'],
  5. version: '1.3',
  6. license: 'BSD',
  7. )
  8. am_cflags = [
  9. '-fstack-protector',
  10. '-Wstrict-prototypes',
  11. '-Wundef',
  12. '-fno-common',
  13. '-Werror-implicit-function-declaration',
  14. '-Wformat-security',
  15. '-Werror=format-security',
  16. '-Wconversion',
  17. '-Wunreachable-code',
  18. ]
  19. # Add our main flags
  20. add_global_arguments(am_cflags, language: 'c')
  21. cc = meson.get_compiler('c')
  22. path_prefix = get_option('prefix')
  23. path_bindir = join_paths(path_prefix, get_option('bindir'))
  24. path_datadir = join_paths(path_prefix, get_option('datadir'))
  25. path_includedir = join_paths(path_prefix, get_option('includedir'))
  26. path_libdir = join_paths(path_prefix, get_option('libdir'))
  27. path_libexecdir = join_paths(path_prefix, get_option('libexecdir'))
  28. # Find systemd via pkgconfig
  29. dep_systemd = dependency('libsystemd')
  30. # Allow meson to figure out how the compiler sets up threading
  31. dep_threads = dependency('threads')
  32. # On non glibc systems this might be a stub, i.e. for musl
  33. libdl = cc.find_library('dl', required: false)
  34. with_systemd = get_option('with-systemd')
  35. if with_systemd == true
  36. # If the path isn't explicitly set, ask systemd for the systemd user unit directory
  37. path_systemd_unit_dir = get_option('with-systemd-user-unit-dir')
  38. if path_systemd_unit_dir == ''
  39. message('Asking pkg-config for systemd\'s directories')
  40. pkgconfig_systemd = dependency('systemd')
  41. path_systemd_unit_dir = pkgconfig_systemd.get_pkgconfig_variable('systemduserunitdir')
  42. endif
  43. endif
  44. with_limits_conf = get_option('with-pam-group')
  45. if with_limits_conf != ''
  46. ldata = configuration_data()
  47. ldata.set('LIMITSGROUP', with_limits_conf)
  48. # Install the limits.d configuration file
  49. configure_file(
  50. input: 'data/10-gamemode.conf.in',
  51. output: '10-gamemode.conf',
  52. configuration: ldata,
  53. install_dir: '/etc/security/limits.d',
  54. )
  55. endif
  56. # Set the dbus path as appropriate.
  57. path_dbus_service_dir = get_option('with-dbus-service-dir')
  58. if path_dbus_service_dir == ''
  59. path_dbus_service_dir = join_paths(path_datadir, 'dbus-1', 'services')
  60. endif
  61. path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions')
  62. with_daemon = get_option('with-daemon')
  63. with_examples = get_option('with-examples')
  64. # Provide a config.h
  65. cdata = configuration_data()
  66. cdata.set_quoted('LIBEXECDIR', path_libexecdir)
  67. cdata.set_quoted('GAMEMODE_VERSION', meson.project_version())
  68. config_h = configure_file(
  69. configuration: cdata,
  70. output: 'config.h',
  71. )
  72. config_h_dir = include_directories('.')
  73. # Library is always required
  74. subdir('lib')
  75. # The daemon can be disabled if necessary, allowing multilib builds of the
  76. # main library
  77. if with_daemon == true
  78. # inih currently only needed by the daemon
  79. inih = subproject('inih')
  80. inih_dependency = inih.get_variable('inih_dependency')
  81. subdir('daemon')
  82. # All installed data is currently daemon specific
  83. subdir('data')
  84. endif
  85. # Optionally allow building of examples
  86. if with_examples == true
  87. subdir('example')
  88. endif
  89. report = [
  90. ' Build configuration:',
  91. ' ====================',
  92. '',
  93. ' prefix: @0@'.format(path_prefix),
  94. ' bindir: @0@'.format(path_bindir),
  95. ' datadir: @0@'.format(path_datadir),
  96. ' libdir: @0@'.format(path_libdir),
  97. ' libexecdir: @0@'.format(path_libexecdir),
  98. ' includedir: @0@'.format(path_includedir),
  99. ]
  100. if with_systemd == true
  101. report += [
  102. ' systemd user unit directory: @0@'.format(path_systemd_unit_dir),
  103. ]
  104. endif
  105. report += [
  106. ' D-BUS service directory: @0@'.format(path_dbus_service_dir),
  107. ]
  108. report += [
  109. ' PolKit Action Directory: @0@'.format(path_polkit_action_dir),
  110. '',
  111. ' Options:',
  112. ' ========',
  113. '',
  114. ' daemon: @0@'.format(with_daemon),
  115. ' examples: @0@'.format(with_examples),
  116. ' systemd: @0@'.format(with_systemd),
  117. ]
  118. # Output some stuff to validate the build config
  119. message('\n\n\n' + '\n'.join(report) + '\n\n')