2
0

meson.build 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.56.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. kv = import('keyval')
  17. version_conf = kv.load('build/version.conf')
  18. ## General Defines
  19. compiler = meson.get_compiler('cpp')
  20. mconfig_data = configuration_data()
  21. version = meson.project_version()
  22. platform = host_machine.system()
  23. month = version_conf.get('MONTH')
  24. year = version_conf.get('YEAR')
  25. build_shutdown = get_option('build-shutdown')
  26. shutdown_prefix = get_option('shutdown-prefix')
  27. dinit_control_socket_path = get_option('dinit-control-socket-path')
  28. unit_tests = get_option('unit-tests')
  29. igr_tests = get_option('igr-tests')
  30. fuzzer = get_option('fuzzer')
  31. man_pages = get_option('man-pages')
  32. support_cgroups = get_option('support-cgroups')
  33. use_utmpx = get_option('use-utmpx')
  34. use_initgroups = get_option('use-initgroups')
  35. default_auto_restart = get_option('default-auto-restart').to_string()
  36. default_start_timeout = get_option('default-start-timeout').to_string()
  37. default_stop_timeout = get_option('default-stop-timeout').to_string()
  38. # We have custom sbindir for install programs (/sbin instead of /usr/sbin/ by default)
  39. # By default: Prefix = /usr
  40. # By default: Sbin = /sbin
  41. # By default: you find dinit on /sbin/dinit
  42. # Note: Dinit dont follow Meson's default sbindir; Use dinit-sbindir option instead!
  43. prefix = get_option('prefix')
  44. sbindir = get_option('dinit-sbindir')
  45. mandir = get_option('mandir')
  46. ## If Meson's default sbindir is modifed; Warn users about it:
  47. if get_option('sbindir') != 'sbin'
  48. warning('It appears that "sbindir" has been set/modified. Dinit\'s build doesn\'t use the "sbindir" option. Please use "dinit-sbindir" option instead!')
  49. endif
  50. ## Use -lrt?
  51. # We need to pass -lrt to c++ linker on FreeBSD. see BUILD_MESON
  52. if platform == 'freebsd' and compiler.has_link_argument('-lrt')
  53. add_project_link_arguments('-lrt', language : 'cpp')
  54. endif
  55. ## Prepare mconfig.h
  56. mconfig_data.set_quoted('DINIT_VERSION', version)
  57. mconfig_data.set_quoted('SYSCONTROLSOCKET', dinit_control_socket_path)
  58. mconfig_data.set_quoted('SBINDIR', sbindir)
  59. mconfig_data.set_quoted('SHUTDOWN_PREFIX', shutdown_prefix)
  60. mconfig_data.set('DEFAULT_AUTO_RESTART', default_auto_restart)
  61. mconfig_data.set('DEFAULT_START_TIMEOUT', default_start_timeout)
  62. mconfig_data.set('DEFAULT_STOP_TIMEOUT', default_stop_timeout)
  63. mconfig_data.set10('USE_INITGROUPS', use_initgroups)
  64. if support_cgroups.auto() and platform == 'linux' or support_cgroups.enabled()
  65. mconfig_data.set('SUPPORT_CGROUPS', '1')
  66. endif
  67. if use_utmpx.enabled()
  68. mconfig_data.set('USE_UTMPX', '1')
  69. elif use_utmpx.disabled()
  70. mconfig_data.set('USE_UTMPX', '0')
  71. endif
  72. configure_file(
  73. input : 'build/mconfig.mesontemplate',
  74. output : 'mconfig.h',
  75. configuration : mconfig_data
  76. )
  77. ## Outputs
  78. subdir('src')
  79. if unit_tests
  80. subdir('src/tests/')
  81. endif
  82. if fuzzer
  83. subdir('src/tests/cptests/')
  84. endif
  85. if igr_tests
  86. subdir('src/igr-tests/')
  87. endif
  88. if man_pages
  89. subdir('doc/manpages/')
  90. endif