1
0

meson.build 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. # Set the dbus path as appropriate.
  50. path_dbus_service_dir = get_option('with-dbus-service-dir')
  51. if path_dbus_service_dir == ''
  52. path_dbus_service_dir = join_paths(path_datadir, 'dbus-1', 'services')
  53. endif
  54. path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions')
  55. with_daemon = get_option('with-daemon')
  56. with_examples = get_option('with-examples')
  57. # Provide a config.h
  58. cdata = configuration_data()
  59. cdata.set_quoted('LIBEXECDIR', path_libexecdir)
  60. cdata.set_quoted('GAMEMODE_VERSION', meson.project_version())
  61. config_h = configure_file(
  62. configuration: cdata,
  63. output: 'config.h',
  64. )
  65. config_h_dir = include_directories('.')
  66. # Library is always required
  67. subdir('lib')
  68. # The daemon can be disabled if necessary, allowing multilib builds of the
  69. # main library
  70. if with_daemon == true
  71. # inih currently only needed by the daemon
  72. inih = subproject('inih')
  73. inih_dependency = inih.get_variable('inih_dependency')
  74. subdir('daemon')
  75. # All installed data is currently daemon specific
  76. subdir('data')
  77. endif
  78. # Optionally allow building of examples
  79. if with_examples == true
  80. subdir('example')
  81. endif
  82. report = [
  83. ' Build configuration:',
  84. ' ====================',
  85. '',
  86. ' prefix: @0@'.format(path_prefix),
  87. ' bindir: @0@'.format(path_bindir),
  88. ' datadir: @0@'.format(path_datadir),
  89. ' libdir: @0@'.format(path_libdir),
  90. ' libexecdir: @0@'.format(path_libexecdir),
  91. ' includedir: @0@'.format(path_includedir),
  92. ]
  93. if with_systemd == true
  94. report += [
  95. ' systemd user unit directory: @0@'.format(path_systemd_unit_dir),
  96. ]
  97. endif
  98. report += [
  99. ' D-BUS service directory: @0@'.format(path_dbus_service_dir),
  100. ]
  101. report += [
  102. ' PolKit Action Directory: @0@'.format(path_polkit_action_dir),
  103. '',
  104. ' Options:',
  105. ' ========',
  106. '',
  107. ' daemon: @0@'.format(with_daemon),
  108. ' examples: @0@'.format(with_examples),
  109. ' systemd: @0@'.format(with_systemd),
  110. ]
  111. # Output some stuff to validate the build config
  112. message('\n\n\n' + '\n'.join(report) + '\n\n')