2.30.0
[platform/upstream/atk.git] / meson.build
1 project('atk', 'c',
2         version: '2.92.94',
3         license: 'LGPLv2.1+',
4         default_options: [
5           'buildtype=debugoptimized',
6           'warning_level=1',
7           'c_std=c99',
8         ],
9         meson_version : '>= 0.46.0')
10
11 cc = meson.get_compiler('c')
12 host_system = host_machine.system()
13
14 version = meson.project_version().split('.')
15 atk_major_version = version[0].to_int()
16 atk_minor_version = version[1].to_int()
17 atk_micro_version = version[2].to_int()
18
19 atk_interface_age = 1
20 atk_binary_age = 10000 * atk_major_version + 100 * atk_minor_version + 10 + atk_micro_version
21
22 atk_api_version = '1.0'
23 atk_api_path = 'atk-@0@/atk'.format(atk_api_version)
24
25 atk_prefix = get_option('prefix')
26 atk_libdir = join_paths(atk_prefix, get_option('libdir'))
27 atk_sysconfdir = join_paths(atk_prefix, get_option('sysconfdir'))
28 atk_includedir = join_paths(atk_prefix, get_option('includedir'))
29 atk_datadir = join_paths(atk_prefix, get_option('datadir'))
30 atk_libexecdir = join_paths(atk_prefix, get_option('libexecdir'))
31
32 atk_conf = configuration_data()
33
34 atk_conf.set_quoted('VERSION', meson.project_version())
35 atk_conf.set_quoted('GETTEXT_PACKAGE', 'atk10')
36
37 # Maintain version scheme with libtool
38 atk_soversion = 0
39 current = atk_binary_age - atk_interface_age
40 atk_libversion = '@0@.@1@.@2@'.format(atk_soversion, current, atk_interface_age)
41 darwin_versions = ['@0@'.format(current + 1), '@0@.@1@'.format(current + 1, atk_interface_age)]
42
43 add_project_arguments([ '-DG_DISABLE_SINGLE_INCLUDES', '-DATK_DISABLE_SINGLE_INCLUDES' ], language: 'c')
44
45 if cc.get_id() == 'msvc'
46   add_project_arguments([ '-FImsvc_recommended_pragmas.h' ], language: 'c')
47 endif
48
49 # Compiler and linker flags
50 common_cflags = []
51 common_ldflags = []
52
53 test_cflags = []
54
55 # Symbol visibility
56 if get_option('default_library') != 'static'
57   if host_system == 'windows'
58     atk_conf.set('DLL_EXPORT', true)
59     atk_conf.set('_ATK_EXTERN', '__declspec(dllexport) extern')
60     if cc.get_id() != 'msvc'
61       test_cflags += ['-fvisibility=hidden']
62     endif
63   else
64     atk_conf.set('_ATK_EXTERN', '__attribute__((visibility("default"))) extern')
65     test_cflags += ['-fvisibility=hidden']
66   endif
67 endif
68
69 # Check all compiler flags
70 common_cflags += cc.get_supported_arguments(test_cflags)
71
72 # Linker flags
73 if host_machine.system() == 'linux'
74   test_ldflags = [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
75   common_ldflags += cc.get_supported_link_arguments(test_ldflags)
76 endif
77
78 # Maintain compatibility with autotools on macOS
79 if host_machine.system() == 'darwin'
80   common_ldflags += [ '-compatibility_version', darwin_versions[0], '-current_version', darwin_versions[1]]
81 endif
82
83 # Functions
84 checked_funcs = [
85   'bind_textdomain_codeset',
86 ]
87
88 foreach f: checked_funcs
89   if cc.has_function(f)
90     atk_conf.set('HAVE_' + f.underscorify().to_upper(), 1)
91   endif
92 endforeach
93
94 # Dependencies
95 glib_req_version = '>= 2.31.2'
96
97 glib_dep = [dependency('glib-2.0', version: glib_req_version,
98                           fallback : ['glib', 'libglib_dep']),
99             dependency('gobject-2.0', version: glib_req_version,
100                           fallback : ['glib', 'libgobject_dep'])]
101
102 # Compat variables for pkgconfig
103 pkgconf = configuration_data()
104 pkgconf.set('prefix', atk_prefix)
105 pkgconf.set('exec_prefix', atk_prefix)
106 pkgconf.set('libdir', atk_libdir)
107 pkgconf.set('includedir', atk_includedir)
108 pkgconf.set('VERSION', meson.project_version())
109 pkgconf.set('ATK_API_VERSION', atk_api_version)
110 pkgconf.set('srcdir', '.')
111
112 foreach pkg: [ 'atk.pc', ]
113   configure_file(input: pkg + '.in',
114                  output: pkg,
115                  configuration: pkgconf,
116                  install: true,
117                  install_dir: join_paths(atk_libdir, 'pkgconfig'))
118 endforeach
119
120 gnome = import('gnome')
121
122 # Internal configuration header
123 configure_file(output: 'config.h', configuration: atk_conf)
124
125 root_inc = include_directories('.')
126
127 subdir('atk')
128 subdir('tests')
129 subdir('po')
130
131 if get_option('docs')
132   subdir('docs')
133 endif