meson.build 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ## Experimetal meson build system for dinit
  2. project(
  3. 'dinit',
  4. 'cpp',
  5. version : run_command(
  6. ['sh', 'build/general_variables_for_meson.sh', 'version'],
  7. check : true).stdout(),
  8. license : 'Apache-2.0',
  9. meson_version : '>= 0.47.0',
  10. default_options : [
  11. 'cpp_std = c++11',
  12. 'optimization=s',
  13. 'debug=false'
  14. ]
  15. )
  16. ## General Defines
  17. compiler = meson.get_compiler('cpp')
  18. mconfig_data = configuration_data()
  19. version = meson.project_version()
  20. platform = host_machine.system()
  21. month = run_command('build/general_variables_for_meson.sh', 'month', check : true).stdout()
  22. year = run_command('build/general_variables_for_meson.sh', 'year', check : true).stdout()
  23. build_shutdown = get_option('build-shutdown')
  24. shutdown_prefix = get_option('shutdown-prefix')
  25. dinit_control_socket_path = get_option('dinit-control-socket-path')
  26. unit_tests = get_option('unit-tests')
  27. igr_tests = get_option('igr-tests')
  28. fuzzer = get_option('fuzzer')
  29. man_pages = get_option('man-pages')
  30. support_cgroups = get_option('support-cgroups')
  31. use_utmpx = get_option('use-utmpx')
  32. # We have custom sbindir for install programs (/sbin instead of /usr/sbin/ by default)
  33. # By default: Prefix = /usr
  34. # By default: Sbin = /sbin
  35. # By default: you find dinit on /sbin/dinit
  36. # Note: Dinit dont follow Meson's default sbindir; Use dinit-sbindir option instead!
  37. prefix = get_option('prefix')
  38. sbindir = get_option('dinit-sbindir')
  39. mandir = get_option('mandir')
  40. ## If Meson's default sbindir is modifed; Warn users about it:
  41. if get_option('sbindir') != 'sbin'
  42. warning('Seems like Default "sbindir" is modified. Dinit dont follow Default "sbindir" option. Please use "dinit-sbindir" option instead!')
  43. endif
  44. ## Use -lrt?
  45. # We need to pass -lrt to c++ linker on FreeBSD. see BUILD_MESON
  46. if platform == 'freebsd'
  47. add_project_link_arguments('-lrt', language : 'cpp')
  48. endif
  49. ## Prepare mconfig.h
  50. mconfig_data.set('DINIT_VERSION', '"' + meson.project_version() + '"')
  51. mconfig_data.set('SYSCONTROLSOCKET', '"' + dinit_control_socket_path + '"')
  52. mconfig_data.set('SBINDIR', '"' + sbindir + '"')
  53. mconfig_data.set('SHUTDOWN_PREFIX', '"' + shutdown_prefix + '"')
  54. if support_cgroups.auto() and platform == 'linux' or support_cgroups.enabled()
  55. mconfig_data.set('SUPPORT_CGROUPS', '1')
  56. endif
  57. if use_utmpx.enabled()
  58. mconfig_data.set('USE_UTMPX', '1')
  59. elif use_utmpx.disabled()
  60. mconfig_data.set('USE_UTMPX', '0')
  61. endif
  62. ## Outputs
  63. subdir('src')
  64. if unit_tests
  65. subdir('src/tests/')
  66. endif
  67. if fuzzer
  68. subdir('src/tests/cptests/')
  69. endif
  70. if igr_tests
  71. subdir('src/igr-tests/')
  72. endif
  73. if man_pages
  74. subdir('doc/manpages/')
  75. endif