meson.build 4.0 KB

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