meson.build 3.3 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.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. use_utmpx = get_option('use-utmpx')
  33. use_initgroups = get_option('use-initgroups')
  34. default_auto_restart = get_option('default-auto-restart').to_string()
  35. default_start_timeout = get_option('default-start-timeout').to_string()
  36. default_stop_timeout = get_option('default-stop-timeout').to_string()
  37. # We have custom sbindir for install programs (/sbin instead of /usr/sbin/ by default)
  38. # By default: Prefix = /usr
  39. # By default: Sbin = /sbin
  40. # By default: you find dinit on /sbin/dinit
  41. # Note: Dinit dont follow Meson's default sbindir; Use dinit-sbindir option instead!
  42. prefix = get_option('prefix')
  43. sbindir = get_option('dinit-sbindir')
  44. mandir = get_option('mandir')
  45. ## If Meson's default sbindir is modifed; Warn users about it:
  46. if get_option('sbindir') != 'sbin'
  47. warning('It appears that "sbindir" has been set/modified. Dinit\'s build doesn\'t use the "sbindir" option. Please use "dinit-sbindir" option instead!')
  48. endif
  49. ## Use -lrt?
  50. # We need to pass -lrt to c++ linker on FreeBSD. see BUILD_MESON
  51. if platform == 'freebsd' and compiler.has_link_argument('-lrt')
  52. add_project_link_arguments('-lrt', language : 'cpp')
  53. endif
  54. ## Prepare mconfig.h
  55. mconfig_data.set_quoted('DINIT_VERSION', version)
  56. mconfig_data.set_quoted('SYSCONTROLSOCKET', dinit_control_socket_path)
  57. mconfig_data.set_quoted('SBINDIR', sbindir)
  58. mconfig_data.set_quoted('SHUTDOWN_PREFIX', shutdown_prefix)
  59. mconfig_data.set('DEFAULT_AUTO_RESTART', default_auto_restart)
  60. mconfig_data.set('DEFAULT_START_TIMEOUT', default_start_timeout)
  61. mconfig_data.set('DEFAULT_STOP_TIMEOUT', default_stop_timeout)
  62. mconfig_data.set10('USE_INITGROUPS', use_initgroups)
  63. if support_cgroups.auto() and platform == 'linux' or support_cgroups.enabled()
  64. mconfig_data.set('SUPPORT_CGROUPS', '1')
  65. endif
  66. if use_utmpx.enabled() or (use_utmpx.auto() and compiler.has_header_symbol('utmpx.h', '_PATH_UTMPX') and
  67. compiler.has_header_symbol('utmpx.h', '_PATH_WTMPX'))
  68. mconfig_data.set('USE_UTMPX', '1')
  69. else
  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 unit_tests or 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