blob: f1aa94b3a948b04c2ac0946ddbbc2586c98c6de7 [file] [log] [blame]
Mathieu Duponchelle920efc02018-05-17 01:28:53 +02001project('harfbuzz', 'c', 'cpp',
2 version: '1.7.6')
3
4cpp = meson.get_compiler('cpp')
5
6python3 = import('python').find_installation('python3')
7
8check_headers = [
9 ['unistd.h'],
10 ['sys/mman.h'],
11 ['xlocale.h'],
12 ['stdbool.h'],
13]
14
15check_funcs = [
16 ['atexit'],
17 ['mprotect'],
18 ['sysconf'],
19 ['getpagesize'],
20 ['mmap'],
21 ['isatty'],
22 ['newlocale'],
23 ['strtod_l'],
24 ['round'],
25]
26
27check_freetype_funcs = [
28 ['FT_Get_Var_Blend_Coordinates'],
29 ['FT_Set_Var_Blend_Coordinates'],
30 ['FT_Done_MM_Var'],
31]
32
33check_alignofs = [
34 ['struct{char;}', {'conf-name': 'ALIGNOF_STRUCT_CHAR__'}]
35]
36
37freetype_dep = dependency('freetype2', required: false)
38glib_dep = dependency('glib-2.0', required: false)
39gobject_dep = dependency('gobject-2.0', required: false)
40cairo_dep = dependency('cairo', required: false)
41cairo_ft_dep = dependency('cairo-ft', required: false)
42fontconfig_dep = dependency('fontconfig', required: false)
43graphite2_dep = dependency('graphite2', required: false)
44icu_dep = dependency('icu-uc', required: false)
45m_dep = cpp.find_library('m')
46
47deps = [m_dep]
48
49conf = configuration_data()
50incbase = include_directories('.')
51cpp_args = ['-DHAVE_CONFIG_H']
52
53warn_cflags = [
54 '-Wno-non-virtual-dtor',
55]
56
57cpp_args += cpp.get_supported_arguments(warn_cflags)
58
59if glib_dep.found()
60 conf.set('HAVE_GLIB', 1)
61 deps += [glib_dep]
62endif
63
64if gobject_dep.found()
65 conf.set('HAVE_GOBJECT', 1)
66 deps += [gobject_dep]
67endif
68
69if cairo_dep.found()
70 conf.set('HAVE_CAIRO', 1)
71 deps += [cairo_dep]
72endif
73
74if cairo_ft_dep.found()
75 conf.set('HAVE_CAIRO_FT', 1)
76 deps += [cairo_ft_dep]
77endif
78
79if graphite2_dep.found()
80 conf.set('HAVE_GRAPHITE2', 1)
81 deps += [graphite2_dep]
82endif
83
84if icu_dep.found()
85 conf.set('HAVE_ICU', 1)
86 conf.set('HAVE_ICU_BUILTIN', 1)
87 deps += [icu_dep]
88endif
89
90if freetype_dep.found()
91 conf.set('HAVE_FREETYPE', 1)
92 deps += [freetype_dep]
93
94 if freetype_dep.type_name() == 'internal'
95 foreach func: check_freetype_funcs
96 name = func[0]
97 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
98 endforeach
99 else
100 check_funcs += check_freetype_funcs
101 endif
102endif
103
104if fontconfig_dep.found()
105 conf.set('HAVE_FONTCONFIG', 1)
106 deps += [fontconfig_dep]
107endif
108
109if host_machine.system() != 'windows'
110 thread_dep = dependency('threads', required: false)
111
112 if thread_dep.found()
113 conf.set('HAVE_PTHREAD', 1)
114 deps += [thread_dep]
115 else
116 check_headers += ['sched.h']
117 check_funcs += ['sched_yield', {'link_with': 'rt'}]
118 endif
119endif
120
121conf.set('HAVE_OT', true)
122conf.set('HAVE_FALLBACK', true)
123conf.set_quoted('PACKAGE_NAME', 'HarfBuzz')
124conf.set_quoted('PACKAGE_VERSION', meson.project_version())
125
126foreach check : check_headers
127 name = check[0]
128
129 if cpp.has_header(name)
130 conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1)
131 endif
132endforeach
133
134foreach check : check_funcs
135 name = check[0]
136 opts = check.length() > 1 ? check[1] : {}
137 link_withs = opts.get('link_with', [])
138 extra_deps = []
139 found = true
140
141 # First try without linking
142
143 found = cpp.has_function(name)
144
145 if not found and link_withs.length() > 0
146 found = true
147
148 foreach link_with : link_withs
149 dep = cpp.find_library(link_with, required: false)
150 if dep.found()
151 extra_deps += dep
152 else
153 found = false
154 endif
155 endforeach
156
157 if found
158 found = cpp.has_function(name, dependencies: extra_deps)
159 endif
160 endif
161
162 if found
163 deps += extra_deps
164 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
165 endif
166endforeach
167
168foreach check : check_alignofs
169 type = check[0]
170 opts = check.length() > 1 ? check[1] : {}
171
172 conf_name = opts.get('conf-name', 'ALIGNOF_@0@'.format(type.to_upper()))
173
174 conf.set(conf_name, cpp.alignment(type))
175endforeach
176
177if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics')
178 conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1)
179endif
180
181if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops')
182 conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1)
183endif
184
185subdir('src')
186subdir('util')
187subdir('test')
188
189configure_file(output: 'config.h', configuration: conf)