meson.build 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. project(
  2. 'gamemode',
  3. 'c',
  4. default_options : ['c_std=c11'],
  5. version: '0.2',
  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. # Set the dbus path as appropriate.
  40. path_dbus_service_dir = get_option('with-dbus-service-dir')
  41. if path_dbus_service_dir == ''
  42. path_dbus_service_dir = join_paths(path_datadir, 'dbus-1', 'services')
  43. endif
  44. path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions')
  45. with_daemon = get_option('with-daemon')
  46. with_examples = get_option('with-examples')
  47. # Provide config.h so the daemon knows where the helper is
  48. cdata = configuration_data()
  49. cdata.set_quoted('LIBEXECDIR', path_libexecdir)
  50. config_h = configure_file(
  51. configuration: cdata,
  52. output: 'config.h',
  53. )
  54. config_h_dir = include_directories('.')
  55. # Library is always required
  56. subdir('lib')
  57. # The daemon can be disabled if necessary, allowing multilib builds of the
  58. # main library
  59. if with_daemon == true
  60. subdir('daemon')
  61. # All installed data is currently daemon specific
  62. subdir('data')
  63. endif
  64. # Optionally allow building of examples
  65. if with_examples == true
  66. subdir('example')
  67. endif
  68. report = [
  69. ' Build configuration:',
  70. ' ====================',
  71. '',
  72. ' prefix: @0@'.format(path_prefix),
  73. ' bindir: @0@'.format(path_bindir),
  74. ' datadir: @0@'.format(path_datadir),
  75. ' libdir: @0@'.format(path_libdir),
  76. ' libexecdir: @0@'.format(path_libexecdir),
  77. ' includedir: @0@'.format(path_includedir),
  78. ' D-BUS service directory: @0@'.format(path_dbus_service_dir),
  79. ' PolKit Action Directory: @0@'.format(path_polkit_action_dir),
  80. '',
  81. ' Options:',
  82. ' ========',
  83. '',
  84. ' daemon: @0@'.format(with_daemon),
  85. ' examples: @0@'.format(with_examples),
  86. ]
  87. # Output some stuff to validate the build config
  88. message('\n\n\n' + '\n'.join(report) + '\n\n')