meson.build 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. 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()
  67. mconfig_data.set('USE_UTMPX', '1')
  68. elif use_utmpx.disabled()
  69. mconfig_data.set('USE_UTMPX', '0')
  70. endif
  71. configure_file(
  72. input : 'build/mconfig.mesontemplate',
  73. output : 'mconfig.h',
  74. configuration : mconfig_data
  75. )
  76. ## Outputs
  77. subdir('src')
  78. if unit_tests
  79. subdir('src/tests/')
  80. endif
  81. if unit_tests or fuzzer
  82. subdir('src/tests/cptests/')
  83. endif
  84. if igr_tests
  85. subdir('src/igr-tests/')
  86. endif
  87. if man_pages
  88. subdir('doc/manpages/')
  89. endif