Imported Upstream version 1.2.4
[platform/upstream/json-glib.git] / json-glib / meson.build
1 install_header_subdir = 'json-glib-1.0/json-glib'
2 install_header_dir = join_paths(json_includedir, install_header_subdir)
3
4 configure_file(output: 'config.h', configuration: cdata)
5
6 source_h = [
7   'json-builder.h',
8   'json-generator.h',
9   'json-gobject.h',
10   'json-gvariant.h',
11   'json-parser.h',
12   'json-path.h',
13   'json-reader.h',
14   'json-types.h',
15   'json-utils.h',
16   'json-version-macros.h'
17 ]
18
19 json_glib_enums = gnome.mkenums('json-enum-types',
20                                 sources: source_h,
21                                 h_template: 'json-enum-types.h.in',
22                                 c_template: 'json-enum-types.c.in',
23                                 install_header: true,
24                                 install_dir: install_header_dir)
25
26 source_c = [
27   'json-array.c',
28   'json-builder.c',
29   'json-debug.c',
30   'json-gboxed.c',
31   'json-generator.c',
32   'json-gobject.c',
33   'json-gvariant.c',
34   'json-node.c',
35   'json-object.c',
36   'json-parser.c',
37   'json-path.c',
38   'json-reader.c',
39   'json-scanner.c',
40   'json-serializable.c',
41   'json-utils.c',
42   'json-value.c',
43 ]
44
45 version_data = configuration_data()
46 version_data.set('JSON_MAJOR_VERSION', json_version_major)
47 version_data.set('JSON_MINOR_VERSION', json_version_minor)
48 version_data.set('JSON_MICRO_VERSION', json_version_micro)
49 version_data.set('JSON_VERSION', meson.project_version())
50
51 version_h = configure_file(input: 'json-version.h.in',
52                            output: 'json-version.h',
53                            install_dir: install_header_dir,
54                            configuration: version_data)
55
56 install_headers(source_h, subdir: install_header_subdir)
57
58 json_c_args = [
59   '-DJSON_COMPILATION',
60   '-DG_LOG_DOMAIN="Json"',
61   '-DJSON_LOCALEDIR="@0@"'.format(json_localedir)
62 ]
63
64 common_ldflags = []
65
66 if host_system == 'linux'
67   common_ldflags = [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
68 endif
69
70 # Maintain compatibility with autotools
71 if host_system == 'darwin'
72   common_ldflags += [ '-compatibility_version=1', '-current_version=1.0', ]
73 endif
74
75
76 json_lib = library('json-glib-1.0',
77                    source_c,
78                    version: libversion,
79                    soversion: soversion,
80                    include_directories: root_dir,
81                    dependencies: [ gio_dep, gobject_dep, ],
82                    c_args: json_c_args + common_cflags + extra_args,
83                    link_args: common_ldflags,
84                    install: true)
85
86 pkgg = import('pkgconfig')
87
88 pkgg.generate(libraries: [ json_lib ],
89               subdirs: '.',
90               version: json_version,
91               name: 'JSON-GLib',
92               filebase: 'json-glib-@0@'.format(apiversion),
93               description: 'JSON Parser for GLib.',
94               requires: 'glib-2.0 gio-2.0')
95
96 json_gen_sources = [ json_glib_enums, version_h ]
97 if build_gir
98     json_gen_sources += gnome.generate_gir(json_lib,
99                                            sources: source_c + source_h,
100                                            namespace: 'Json',
101                                            nsversion: apiversion,
102                                            identifier_prefix: 'Json',
103                                            symbol_prefix: 'json',
104                                            export_packages: 'json-glib-1.0',
105                                            includes: [ 'GObject-2.0', 'Gio-2.0', ],
106                                            install: true,
107                                            extra_args: ['-DJSON_COMPILATION'])
108 endif
109
110 json_glib_dep = declare_dependency(link_with: json_lib,
111                                    include_directories: root_dir,
112                                    dependencies: [ gobject_dep, gio_dep, ],
113                                    sources: json_gen_sources)
114
115 tools = [
116   [ 'json-glib-validate', [ 'json-glib-validate.c', ] ],
117   [ 'json-glib-format', [ 'json-glib-format.c', ] ],
118 ]
119
120 foreach t: tools
121   bin_name = t[0]
122   bin_sources = t[1]
123
124   executable(bin_name, bin_sources, c_args: json_c_args, dependencies: json_glib_dep)
125 endforeach
126
127 subdir('tests')