meson.build 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ## Experimetal meson build system for dinit
  2. project(
  3. 'dinit',
  4. 'cpp',
  5. version : run_command('grep', '^VERSION=', 'build/version.conf',
  6. check: true).stdout().strip().split('=')[1],
  7. license : 'Apache-2.0',
  8. meson_version : '>= 0.61.0',
  9. default_options : [
  10. 'cpp_std=c++11',
  11. 'optimization=s',
  12. 'debug=false'
  13. ]
  14. )
  15. ## Import variables from build/version.conf
  16. version_conf = import('keyval').load('build/version.conf')
  17. ## General Defines
  18. compiler = meson.get_compiler('cpp')
  19. mconfig_data = configuration_data()
  20. version = meson.project_version()
  21. platform = host_machine.system()
  22. month = version_conf.get('MONTH')
  23. year = version_conf.get('YEAR')
  24. build_shutdown = get_option('build-shutdown')
  25. shutdown_prefix = get_option('shutdown-prefix')
  26. dinit_control_socket_path = get_option('dinit-control-socket-path')
  27. unit_tests = get_option('unit-tests')
  28. igr_tests = get_option('igr-tests')
  29. fuzzer = get_option('fuzzer')
  30. man_pages = get_option('man-pages')
  31. support_cgroups = get_option('support-cgroups')
  32. support_capabilities = get_option('support-capabilities')
  33. support_ioprio = get_option('support-ioprio')
  34. support_oom_adj = get_option('support-oom-adj')
  35. use_utmpx = get_option('use-utmpx')
  36. use_initgroups = get_option('use-initgroups')
  37. default_auto_restart = get_option('default-auto-restart')
  38. default_start_timeout = get_option('default-start-timeout').to_string()
  39. default_stop_timeout = get_option('default-stop-timeout').to_string()
  40. # We have custom sbindir for install programs (/sbin instead of /usr/sbin/ by default)
  41. # By default: Prefix = /usr
  42. # By default: Sbin = /sbin
  43. # By default: you find dinit on /sbin/dinit
  44. # Note: Dinit dont follow Meson's default sbindir; Use dinit-sbindir option instead!
  45. prefix = get_option('prefix')
  46. sbindir = get_option('dinit-sbindir')
  47. mandir = get_option('mandir')
  48. ## If Meson's default sbindir is modifed; Warn users about it:
  49. if get_option('sbindir') != 'sbin'
  50. warning('It appears that "sbindir" has been set/modified. Dinit\'s build doesn\'t use the "sbindir" option. Please use "dinit-sbindir" option instead!')
  51. endif
  52. ## Use -lrt?
  53. # We need to pass -lrt to c++ linker on FreeBSD. see BUILD_MESON
  54. if platform == 'freebsd' and compiler.has_link_argument('-lrt')
  55. add_project_link_arguments('-lrt', language : 'cpp')
  56. endif
  57. ## Dependencies
  58. libcap_dep = dependency('libcap', required: support_capabilities)
  59. ## Prepare mconfig.h
  60. mconfig_data.set_quoted('DINIT_VERSION', version)
  61. mconfig_data.set_quoted('SYSCONTROLSOCKET', dinit_control_socket_path)
  62. mconfig_data.set_quoted('SBINDIR', sbindir)
  63. mconfig_data.set_quoted('SHUTDOWN_PREFIX', shutdown_prefix)
  64. mconfig_data.set('DEFAULT_AUTO_RESTART', default_auto_restart)
  65. mconfig_data.set('DEFAULT_START_TIMEOUT', default_start_timeout)
  66. mconfig_data.set('DEFAULT_STOP_TIMEOUT', default_stop_timeout)
  67. mconfig_data.set10('USE_INITGROUPS', use_initgroups)
  68. mconfig_data.set10('SUPPORT_CGROUPS', support_cgroups.auto() and platform == 'linux' or support_cgroups.enabled())
  69. mconfig_data.set10('SUPPORT_CAPABILITIES', libcap_dep.found() and not support_capabilities.disabled())
  70. mconfig_data.set10('SUPPORT_IOPRIO', support_ioprio.auto() and platform == 'linux' or support_ioprio.enabled())
  71. mconfig_data.set10('SUPPORT_OOM_ADJ', support_oom_adj.auto() and platform == 'linux' or support_oom_adj.enabled())
  72. if use_utmpx.enabled() or (use_utmpx.auto() and compiler.has_header_symbol('utmpx.h', '_PATH_UTMPX') and
  73. compiler.has_header_symbol('utmpx.h', '_PATH_WTMPX'))
  74. mconfig_data.set('USE_UTMPX', '1')
  75. else
  76. mconfig_data.set('USE_UTMPX', '0')
  77. endif
  78. configure_file(
  79. input : 'build/mconfig.mesontemplate',
  80. output : 'mconfig.h',
  81. configuration : mconfig_data
  82. )
  83. ## Outputs
  84. subdir('src')
  85. if unit_tests
  86. subdir('src/tests/')
  87. endif
  88. if unit_tests or fuzzer
  89. subdir('src/tests/cptests/')
  90. endif
  91. if igr_tests
  92. subdir('src/igr-tests/')
  93. endif
  94. if man_pages
  95. subdir('doc/manpages/')
  96. endif