meson.build 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. project('libhandy', 'c',
  2. version: '0.0.0',
  3. license: 'LGPL-2.1+',
  4. meson_version: '>= 0.40.1',
  5. default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ],
  6. )
  7. version_arr = meson.project_version().split('.')
  8. handy_version_major = version_arr[0].to_int()
  9. handy_version_minor = version_arr[1].to_int()
  10. handy_version_micro = version_arr[2].to_int()
  11. apiversion = '0.0'
  12. soversion = 0
  13. if handy_version_minor.is_odd()
  14. handy_interface_age = 0
  15. else
  16. handy_interface_age = handy_version_micro
  17. endif
  18. # maintaining compatibility with libtool versioning
  19. # current = minor * 100 + micro - interface
  20. # revision = interface
  21. current = handy_version_minor * 100 + handy_version_micro - handy_interface_age
  22. revision = handy_interface_age
  23. libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
  24. config_h = configuration_data()
  25. config_h.set_quoted('GETTEXT_PACKAGE', 'libhandy')
  26. config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
  27. configure_file(
  28. output: 'config.h',
  29. configuration: config_h,
  30. )
  31. add_project_arguments([
  32. '-DHAVE_CONFIG_H',
  33. '-DHANDY_COMPILATION',
  34. '-I' + meson.build_root(),
  35. ], language: 'c')
  36. root_inc = include_directories('.')
  37. src_inc = include_directories('src')
  38. cc = meson.get_compiler('c')
  39. global_c_args = []
  40. test_c_args = [
  41. '-Wcast-align',
  42. '-Wdeclaration-after-statement',
  43. ['-Werror=format-security', '-Werror=format=2'],
  44. '-Wformat-nonliteral',
  45. '-Wformat-security',
  46. '-Wmissing-include-dirs',
  47. '-Wnested-externs',
  48. '-Wno-missing-field-initializers',
  49. '-Wno-sign-compare',
  50. '-Wno-strict-aliasing',
  51. '-Wno-uninitialized',
  52. '-Wno-unused-parameter',
  53. '-Wpointer-arith',
  54. '-Wredundant-decls',
  55. '-Wshadow',
  56. '-Wswitch-default',
  57. '-Wswitch-enum',
  58. '-Wundef',
  59. ]
  60. if get_option('buildtype') != 'plain'
  61. test_c_args += '-fstack-protector-strong'
  62. endif
  63. if get_option('profiling')
  64. test_c_args += '-pg'
  65. endif
  66. foreach arg: test_c_args
  67. if cc.has_multi_arguments(arg)
  68. global_c_args += arg
  69. endif
  70. endforeach
  71. add_project_arguments(
  72. global_c_args,
  73. language: 'c'
  74. )
  75. # Setup various paths that subdirectory meson.build files need
  76. package_subdir = get_option('package_subdir') # When used as subproject
  77. libdir = join_paths(get_option('libdir'), package_subdir)
  78. girdir = join_paths(get_option('datadir'), package_subdir, 'gir-1.0')
  79. typelibdir = join_paths(get_option('libdir'), package_subdir, 'girepository-1.0')
  80. if package_subdir != ''
  81. vapidir = join_paths(get_option('datadir'), package_subdir, 'vapi')
  82. else
  83. vapidir = join_paths(get_option('datadir'), 'vala', 'vapi')
  84. endif
  85. gnome = import('gnome')
  86. subdir('src')
  87. subdir('examples')
  88. subdir('tests')
  89. subdir('doc')
  90. subdir('data')
  91. run_data = configuration_data()
  92. run_data.set('ABS_BUILDDIR', meson.current_build_dir())
  93. run_data.set('ABS_SRCDIR', meson.current_source_dir())
  94. configure_file(
  95. input: 'run.in',
  96. output: 'run',
  97. configuration: run_data)
  98. summary = [
  99. '',
  100. '------',
  101. 'Handy @0@ (@1@)'.format(current, apiversion),
  102. '',
  103. ' Tests: @0@'.format(get_option('tests')),
  104. ' Examples: @0@'.format(get_option('examples')),
  105. ' Documentation: @0@'.format(get_option('gtk_doc')),
  106. ' Introspection: @0@'.format(get_option('introspection')),
  107. ' Vapi: @0@'.format(get_option('vapi')),
  108. ' Glade Catalog: @0@'.format(get_option('glade_catalog')),
  109. '------',
  110. ''
  111. ]
  112. message('\n'.join(summary))