summaryrefslogtreecommitdiff
path: root/meson.build
blob: 68eb0b1af279097d4afc059b2c6b3f2ed4618fec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
project(
  'libgdata', 'c',
  version: '0.19.0',
  license: 'LGPL2.1+',
  default_options: 'buildtype=debugoptimized',
  meson_version: '>= 0.50.0',
)

gdata_name = meson.project_name()
gdata_version = meson.project_version()

ver_arr = gdata_version.split('.')
gdata_version_major = ver_arr[0].to_int()
gdata_version_minor = ver_arr[1].to_int()
gdata_version_micro = ver_arr[2].to_int()

# API version
gdata_api_version_major = 0
gdata_api_version_minor = 0

# Define the install directories
gdata_prefix = get_option('prefix')
gdata_datadir = get_option('datadir')
gdata_libexecdir = get_option('libexecdir')
gdata_includedir = get_option('includedir')

gdata_include_subdir = gdata_name / 'gdata'

# Before making a release, the GDATA_LT_VERSION string should be modified. The string is of the form c:r:a. Follow these instructions sequentially:
#
#  1. If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
#  2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
#  3. If any interfaces have been added since the last public release, then increment age.
#  4. If any interfaces have been removed or changed since the last public release, then set age to 0.
#
# Note that versioning started at 2:0:0 to ensure no conflicts with e-d-s' libgdata library, whose maximum version was 1:0:0
current = 28
revision = 0
age = 6
gdata_soversion = '@0@.@1@.@2@'.format(current - age, age, revision)

top_inc_dir = include_directories('.')

########################
# Configuration begins #
########################

config_h = configuration_data()

config_h.set_quoted('VERSION', gdata_version)

# Globally define _GNU_SOURCE and therefore enable the GNU extensions
config_h.set('_GNU_SOURCE', true)

config_h.set_quoted('GETTEXT_PACKAGE', 'gdata')

gnome = import('gnome')
pkgconfig = import('pkgconfig')

# Internationalisation support
i18n = import('i18n')

build_root = meson.current_build_dir()

# FIXME: Work around the namespace being incorrectly detected
# by glib-mkenums. This needs to be fixed by changing the
# namespace in libgdata. See !6.
sed = find_program('sed')
enum_source_cmd = [sed, '-e', 's/-in//', '-e', 's/g_data/gdata/', build_root / '@INPUT@']
enum_header_cmd = [sed, '-e', 's/g_data/gdata/', '-e', 's/G_TYPE_DATA/GDATA_TYPE/', build_root / '@INPUT@']

top_inc_dir = include_directories('.')

cc = meson.get_compiler('c')

# Requirements
gdata_deps = [
  dependency('gobject-2.0'),
  dependency('glib-2.0', version: '>= 2.62.0'),
  dependency('gio-2.0', version: '>= 2.44.0'),
  dependency('json-glib-1.0', version: '>= 0.15'),
  dependency('libxml-2.0'),
]

common_c_args = [
  '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_62',
  '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_68',
]

# Private dependencies for libgdata (specifically used for pkgconfig)
gdata_private_deps = [
  dependency('gthread-2.0'),
]

libsoup_dep = dependency('libsoup-2.4', version: '>= 2.42.0')
gdata_deps += libsoup_dep
# libsoup 2.47.3 is needed for the new SoupServer API; but it contained a bug in
# soup_server_set_ssl_cert_file() which was only fixed in 2.55.90.
config_h.set('HAVE_LIBSOUP_2_55_90', libsoup_dep.version().version_compare('>= 2.55.90'))

# Check for gtk
gtk_dep_req_version = '>= 2.91.2'
gtk_dep = dependency(
  'gtk+-3.0',
  version: gtk_dep_req_version,
  required: get_option('gtk'),
  not_found_message: 'GTK+ support requested but gtk+-3.0 ' + gtk_dep_req_version + ' could not be found',
)

# GNOME support, which pulls in gcr-base-3 to provide non-pageable memory
gcr_dep = dependency('gcr-base-3', required: get_option('gnome'))
enable_gnome = gcr_dep.found()
if enable_gnome
  gdata_private_deps += dependency('gcr-base-3')
endif
config_h.set('HAVE_GNOME', enable_gnome)

# Check for goa
# GNOME Online Accounts support -- only used if GNOME support is also enabled
# Pulls in gdata/gdata-goa-authorizer.[ch]
goa_dep = dependency('goa-1.0', version: '>= 3.8', required: get_option('goa'))
enable_goa = goa_dep.found()
if enable_goa
  gdata_deps += goa_dep
endif

# Enable always building tests (default: yes) enable_always_build_tests = get_option('always_build_tests')
# Install test programs (default: no)
always_build_tests = get_option('always_build_tests')
install_tests = get_option('installed_tests')

if always_build_tests
  libuhttpmock_dep = dependency('libuhttpmock-0.0', version: '>= 0.5.0')

  gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.14')
  config_h.set('HAVE_GDK_PIXBUF', gdk_pixbuf_dep.found())
endif

check_functions = [
  'memset',
  'setlocale',
  'strchr',
  'strstr',
]

check_functions += [
  'CFLocaleCopyCurrent',
  'CFPreferencesCopyAppValue',
]

foreach func: check_functions
  cc.has_function(func)
endforeach

check_headers = [
  'arpa/inet.h',
  'locale.h',
  'memory.h',
  'netinet/in.h',
  'stdlib.h',
  'string.h',
  'strings.h',
  'sys/socket.h',
  'sys/time.h',
  'sys/types.h',
  'unistd.h',
]

foreach func: check_headers
  cc.has_header(func)
endforeach

subdir('gdata')
subdir('demos')
subdir('po')
if get_option('gtk_doc')
  subdir('docs/reference')
endif

# Create the `config.h` file from the `config_h` data
configure_file(output: 'config.h', configuration: config_h)