1
0

meson.build 4.3 KB

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