summaryrefslogtreecommitdiff
path: root/meson.build
blob: c9f21913ffacdaccf357c90dd6e3c15cb37df8a3 (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
project('libsoup', 'c',
        version: '2.60.2',
        meson_version : '>=0.40.1',
        license : 'LGPL',
        default_options : ['warning_level=1', 'c_std=c89'])

gnome = import('gnome')
i18n = import('i18n')
cc = meson.get_compiler('c')

soup_version = meson.project_version()
version_arr = soup_version.split('.')
soup_version_major = version_arr[0]
soup_version_minor = version_arr[1]
soup_version_micro = version_arr[2]

libversion = '1.8.0'
apiversion = '2.4'
soversion = '0'

host_system = host_machine.system()

glib_dep = [dependency('glib-2.0', version : '>=2.38'),
            dependency('gobject-2.0', version : '>=2.38'),
            dependency('gio-2.0', version : '>=2.38')]

sqlite_dep = [dependency('sqlite3')]

libxml_dep = [dependency('libxml-2.0')]

cdata = configuration_data()

platform_deps = []
if host_machine.system() == 'windows'
  platform_deps = [cc.find_library('ws2_32')]
  cdata.set('_SOUP_EXTERN', '__declspec(dllexport)')
  cdata.set('DLL_EXPORT', 1)
endif

###################
# glib-networking #
###################
check_glib_networking_src = '''#include <gio/gio.h>
int main(void) {
  return !g_tls_backend_supports_tls (g_tls_backend_get_default ());
}
'''

enable_tls_check = get_option('tls_check')
if enable_tls_check
  if not cc.compiles(check_glib_networking_src, name : 'glib-networking supports TLS', dependencies : glib_dep)
    error('libsoup requires glib-networking for TLS support')
  endif
endif

################################
# Regresion tests dependencies #
################################
apache_httpd2 = find_program('httpd2', 'httpd', 'apache2', 'apache', required : false)
have_apache=false
apache_httpd2_version = ''
if apache_httpd2.found()
  apache_httpd2_version_raw = run_command(apache_httpd2.path(), '-v')
  if apache_httpd2_version_raw.returncode() == 0
    apache_httpd2_version = apache_httpd2_version_raw.stdout().split('\n')[0]
    apache_httpd2_version = apache_httpd2_version.split('/')[1].split(' ')[0]
    if apache_httpd2_version.version_compare('>=2.4')
      have_apache = true
      cdata.set('APACHE_HTTPD', '"@0@"'.format(apache_httpd2.path()))
    else
      message('Found ' + apache_httpd2_version + ', but at least 2.4 is needed - ignoring')
    endif
  endif
endif

if have_apache
  apache_modules = run_command('get_apache_module_dirs.py', apache_httpd2.path())
  if apache_modules.returncode() == 0
    message('Apache module directory: ' + apache_modules.stdout().split(':')[0])
    apache_module_dir = apache_modules.stdout().split(':')[0]
    cdata.set('APACHE_MODULE_DIR', apache_module_dir)
    apache_ssl_module_dir = apache_modules.stdout().split(':')[1]
    cdata.set('APACHE_SSL_MODULE_DIR', apache_ssl_module_dir)
    if apache_module_dir != '' and apache_ssl_module_dir != ''
      have_apache = true
      add_project_arguments('-DHAVE_APACHE=1', language : 'c')
    endif
    cdata.set('APACHE_PHP_MODULE_DIR', apache_modules.stdout().split(':')[2])
  endif
endif

have_php = false
if have_apache
  php = find_program('php', required : false)
  apache_php_module = run_command('test', '-d', cdata.get('APACHE_PHP_MODULE_DIR'))
  if apache_php_module.returncode() == 0
    have_php = true
    php_xmlrpc = run_command(php, '--rf', 'xmlrpc_server_create')
    if php_xmlrpc.returncode() == 0
      message('php-xmlrpc found')
      add_project_arguments('-DHAVE_PHP_XMLRPC=1', language : 'c')
    else
      message('php-xmlrpc not found')
    endif
  endif
  cdata.set('IF_HAVE_PHP', have_php ? '' : '#')
  apache_mod_unixd = run_command('test', '-f', cdata.get('APACHE_MODULE_DIR') + '/mod_unixd.so')
  cdata.set('IF_HAVE_MOD_UNIXD', apache_mod_unixd.returncode() == 0 ? '' : '#')
endif

if find_program('curl', required : false).found()
  add_project_arguments('-DHAVE_CURL=1', language : 'c')
endif

##################
# GSSAPI support #
##################
enable_gssapi = get_option('gssapi')
krb5_config_option = get_option('krb5_config')
if enable_gssapi
  krb5_config_path = krb5_config_option != '' ? krb5_config_option : 'krb5-config'
  krb5_config = find_program(krb5_config_path, required : false)

  if krb5_config.found()
    krb5_config_output = run_command (krb5_config, '--libs', 'gssapi')
    if krb5_config_output.returncode() == 0
      add_project_link_arguments(krb5_config_output.stdout().split(), language : 'c')
    else
      error('Failed to obtain cflags for GSSAPI from krb5-config')
      enable_gssapi = false
    endif

    krb5_config_output = run_command (krb5_config, '--cflags', 'gssapi')
    if krb5_config_output.returncode() == 0
      add_project_arguments(krb5_config_output.stdout().split(), language : 'c')
    else
      error('Failed to obtain cflags for GSSAPI from krb5-config')
      enable_gssapi = false
    endif
  else
    error('GSSAPI support requested, but krb5-config not found. Please specify its path with -Dkrb5-config=PATH')
    enable_gssapi = false
  endif

  if enable_gssapi
    add_project_arguments('-DLIBSOUP_HAVE_GSSAPI=1', language : 'c')
  endif
endif

################
# NTLM support #
################
# NTLM not supported on Windows
if host_machine.system() != 'windows'
  enable_ntlm = get_option('ntlm')
  if enable_ntlm
    ntlm_auth_option = get_option('ntlm_auth')
    ntlm_auth_path = ntlm_auth_option != '' ? ntlm_auth_option : 'ntlm_auth'
    ntlm_auth = find_program(ntlm_auth_path, required : false)

    if ntlm_auth.found()
      add_project_arguments('-DUSE_NTLM_AUTH=1', language : 'c')
      add_project_arguments('-DNTLM_AUTH=' + ntlm_auth.path(), language : 'c')
    endif
  endif
endif

#################
# GNOME support #
#################
enable_gnome = get_option('gnome')
if host_machine.system() == 'windows'
  enable_gnome = false
endif
cdata.set('BUILD_LIBSOUP_GNOME', enable_gnome)

configinc = include_directories('.')

prefix = get_option('prefix')

cdata.set('PACKAGE_VERSION', '"@0@"'.format(soup_version))
cdata.set('LOCALEDIR', '"@0@/@1@"'.format(prefix, get_option('localedir')))
cdata.set('GETTEXT_PACKAGE', '"libsoup-2.4"')
configure_file(output : 'config.h', configuration : cdata)

pkgconf = configuration_data()

pkgconf.set('prefix', get_option('prefix'))
pkgconf.set('exec_prefix', '${prefix}')
pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
pkgconf.set('VERSION', soup_version)

pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))

configure_file(output : 'libsoup-2.4.pc',
  input : 'libsoup-2.4.pc.in',
  configuration : pkgconf,
  install_dir : pkg_install_dir)

if enable_gnome
  configure_file(output : 'libsoup-gnome-2.4.pc',
    input : 'libsoup-gnome-2.4.pc.in',
    configuration : pkgconf,
    install_dir : pkg_install_dir)
endif

subdir('libsoup')
subdir('po')
subdir('examples')

if get_option('tests')
  subdir('tests')
 endif

if get_option('doc')
  subdir('docs/reference')
endif