summaryrefslogtreecommitdiff
path: root/meson.build
blob: 5142e3aa33846a1c27eea110510bcab72b4c8f83 (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
project('gnome-dictionary', 'c', version: '3.26.2',
        default_options: [
          'buildtype=debugoptimized',
          'c_std=c99',
          'warning_level=1',
        ],
        license: 'GPLv2+',
        meson_version: '>= 0.54.0')

# Paths for the pkg-config file
gdict_prefix = get_option('prefix')
gdict_bindir = gdict_prefix / get_option('bindir')
gdict_libdir = gdict_prefix / get_option('libdir')
gdict_datadir = gdict_prefix / get_option('datadir')
gdict_includedir = gdict_prefix / get_option('includedir')
gdict_libexecdir = gdict_prefix / get_option('libexecdir')
gdict_mandir = gdict_prefix / get_option('mandir')
gdict_sysconfdir = gdict_prefix / get_option('sysconfdir')
gdict_schemadir = gdict_datadir / 'glib-2.0' / 'schemas'
gdict_servicedir = gdict_datadir / 'dbus-1' / 'services'

cc = meson.get_compiler('c')
host_system = host_machine.system()

conf = configuration_data()
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('PACKAGE_STRING', '@0@-@1@'.format(meson.project_name(), meson.project_version()))
conf.set_quoted('PACKAGE_DATADIR', gdict_datadir)
conf.set_quoted('PACKAGE_LIBDIR', gdict_libdir)
conf.set_quoted('PACKAGE_LOCALE_DIR', join_paths(gdict_datadir, 'locale'))
conf.set_quoted('PACKAGE_LIBEXECDIR', gdict_libexecdir)
conf.set('VERSION', 'PACKAGE_VERSION')
conf.set('GETTEXT_PACKAGE', 'PACKAGE_NAME')
conf.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
conf.set10('ENABLE_NLS', true) # Always enabled
conf.set('HAVE_UNISTD_H', cc.has_header('unistd.h'))

# Compiler flags
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
  test_cflags = [
    '-fstrict-aliasing',
    '-Wpointer-arith',
    '-Wmissing-declarations',
    '-Wformat=2',
    '-Wstrict-prototypes',
    '-Wmissing-prototypes',
    '-Wnested-externs',
    '-Wold-style-definition',
    '-Wunused',
    '-Wuninitialized',
    '-Wshadow',
    '-Wmissing-noreturn',
    '-Wmissing-format-attribute',
    '-Wredundant-decls',
    '-Wlogical-op',
    '-Wcast-align',
    '-Wno-unused-local-typedefs',
    '-Werror=implicit',
    '-Werror=init-self',
    '-Werror=main',
    '-Werror=missing-braces',
    '-Werror=return-type',
    '-Werror=array-bounds',
    '-Werror=write-strings'
  ]
else
  test_cflags = []
endif

common_cflags = cc.get_supported_arguments(test_cflags)

debug = get_option('debug')
optimization = get_option('optimization')
buildtype = get_option('buildtype')
debug_cflags = []

if debug
  debug_cflags += '-DGDICT_ENABLE_DEBUG'
elif optimization in ['2', '3', 's']
  debug_cflags += '-DG_DISABLE_CAST_CHECKS'
endif

if buildtype == 'release'
  debug_cflags += [ '-DG_DISABLE_ASSERT', '-DG_DISABLE_CHECKS', '-DG_DISABLE_CAST_CHECKS', ]
endif

ipv6_deps = []

use_ipv6 = get_option('use_ipv6')
if use_ipv6
  ipv6_prog = '''
#include <sys/socket.h>
#include <sys/types.h>

int main (void) {
  struct sockaddr_storage ss;
  socket(AF_INET6, SOCK_STREAM, 0);
  return 0;
}
  '''
  has_ipv6 = cc.compiles(ipv6_prog, name: 'AF_INET6 is available')
  has_getaddrinfo = cc.has_function('getaddrinfo')

  # Look for getaddrinfo in all the known places
  if not has_getaddrinfo
    found_getaddrinfo = false
    foreach l: [ 'bsd', 'socket', 'inet' ]
      dep = cc.find_library(l, required: false)
      if not found_getaddrinfo and dep.found()
        has_getaddrinfo = cc.has_function('getaddrinfo', dependencies: dep)
        if has_getaddrinfo
          ipv6_deps += dep
        endif
      endif
    endforeach
  endif

  use_ipv6 = has_ipv6 and has_getaddrinfo
endif

conf.set10('ENABLE_IPV6', use_ipv6)

root_inc = include_directories('.')
libgdict_inc = include_directories('libgdict')
src_inc = include_directories('src')
po_dir = join_paths(meson.current_source_dir(), 'po')

configure_file(output: 'config.h', configuration: conf)

gio_dep = dependency('gio-2.0', version: '>= 2.42.0')
gtk_dep = dependency('gtk+-3.0', version: '>= 3.21.2')

gnome = import('gnome')
i18n = import('i18n')

subdir('libgdict')
subdir('src')
subdir('po')
subdir('data')
subdir('help')

# Post-installation trigger
meson.add_install_script ('build-aux/post-install.sh')