Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 1 | project('harfbuzz', 'c', 'cpp', |
Mathieu Duponchelle | 07cadc9 | 2018-06-18 17:18:05 +0200 | [diff] [blame] | 2 | meson_version: '>= 0.47.0', |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 3 | version: '1.7.6') |
| 4 | |
Mathieu Duponchelle | 484313f | 2018-06-05 02:15:43 +0200 | [diff] [blame] | 5 | pkgmod = import('pkgconfig') |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 6 | cpp = meson.get_compiler('cpp') |
| 7 | |
| 8 | python3 = import('python').find_installation('python3') |
| 9 | |
| 10 | check_headers = [ |
| 11 | ['unistd.h'], |
| 12 | ['sys/mman.h'], |
| 13 | ['xlocale.h'], |
| 14 | ['stdbool.h'], |
| 15 | ] |
| 16 | |
| 17 | check_funcs = [ |
| 18 | ['atexit'], |
| 19 | ['mprotect'], |
| 20 | ['sysconf'], |
| 21 | ['getpagesize'], |
| 22 | ['mmap'], |
| 23 | ['isatty'], |
| 24 | ['newlocale'], |
| 25 | ['strtod_l'], |
| 26 | ['round'], |
| 27 | ] |
| 28 | |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 29 | freetype_dep = dependency('freetype2', required: get_option('freetype'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 30 | fallback: ['freetype2', 'freetype_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 31 | glib_dep = dependency('glib-2.0', required: get_option('glib'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 32 | fallback: ['glib', 'libglib_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 33 | gobject_dep = dependency('gobject-2.0', required: get_option('gobject'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 34 | fallback: ['glib', 'libgobject_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 35 | cairo_dep = dependency('cairo', required: get_option('cairo'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 36 | fallback: ['cairo', 'libcairo_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 37 | fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 38 | fallback: ['fontconfig', 'fontconfig_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 39 | graphite2_dep = dependency('graphite2', required: get_option('graphite')) |
| 40 | icu_dep = dependency('icu-uc', required: get_option('icu')) |
Mathieu Duponchelle | fce88f9 | 2018-05-17 16:20:10 +0200 | [diff] [blame] | 41 | m_dep = cpp.find_library('m', required: false) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 42 | |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 43 | # Ensure that cairo-ft is fetched from the same library as cairo itself |
| 44 | if cairo_dep.found() |
| 45 | if cairo_dep.type_name() == 'pkgconfig' |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 46 | cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo')) |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 47 | else |
| 48 | cairo_ft_dep = cairo_dep |
| 49 | endif |
| 50 | else |
| 51 | # Not-found dependency |
| 52 | cairo_ft_dep = dependency('', required: false) |
| 53 | endif |
| 54 | |
Mathieu Duponchelle | fce88f9 | 2018-05-17 16:20:10 +0200 | [diff] [blame] | 55 | deps = [] |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 56 | |
| 57 | conf = configuration_data() |
| 58 | incbase = include_directories('.') |
| 59 | cpp_args = ['-DHAVE_CONFIG_H'] |
| 60 | |
| 61 | warn_cflags = [ |
| 62 | '-Wno-non-virtual-dtor', |
| 63 | ] |
| 64 | |
| 65 | cpp_args += cpp.get_supported_arguments(warn_cflags) |
| 66 | |
Mathieu Duponchelle | fce88f9 | 2018-05-17 16:20:10 +0200 | [diff] [blame] | 67 | if m_dep.found() |
| 68 | deps += [m_dep] |
| 69 | endif |
| 70 | |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 71 | if glib_dep.found() |
| 72 | conf.set('HAVE_GLIB', 1) |
| 73 | deps += [glib_dep] |
| 74 | endif |
| 75 | |
| 76 | if gobject_dep.found() |
| 77 | conf.set('HAVE_GOBJECT', 1) |
| 78 | deps += [gobject_dep] |
| 79 | endif |
| 80 | |
| 81 | if cairo_dep.found() |
| 82 | conf.set('HAVE_CAIRO', 1) |
| 83 | deps += [cairo_dep] |
| 84 | endif |
| 85 | |
| 86 | if cairo_ft_dep.found() |
| 87 | conf.set('HAVE_CAIRO_FT', 1) |
| 88 | deps += [cairo_ft_dep] |
| 89 | endif |
| 90 | |
| 91 | if graphite2_dep.found() |
| 92 | conf.set('HAVE_GRAPHITE2', 1) |
| 93 | deps += [graphite2_dep] |
| 94 | endif |
| 95 | |
| 96 | if icu_dep.found() |
| 97 | conf.set('HAVE_ICU', 1) |
| 98 | conf.set('HAVE_ICU_BUILTIN', 1) |
| 99 | deps += [icu_dep] |
| 100 | endif |
| 101 | |
| 102 | if freetype_dep.found() |
| 103 | conf.set('HAVE_FREETYPE', 1) |
| 104 | deps += [freetype_dep] |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 105 | check_freetype_funcs = [ |
| 106 | ['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}], |
| 107 | ['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}], |
| 108 | ['FT_Done_MM_Var', {'deps': freetype_dep}], |
| 109 | ] |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 110 | |
| 111 | if freetype_dep.type_name() == 'internal' |
| 112 | foreach func: check_freetype_funcs |
| 113 | name = func[0] |
| 114 | conf.set('HAVE_@0@'.format(name.to_upper()), 1) |
| 115 | endforeach |
| 116 | else |
| 117 | check_funcs += check_freetype_funcs |
| 118 | endif |
| 119 | endif |
| 120 | |
| 121 | if fontconfig_dep.found() |
| 122 | conf.set('HAVE_FONTCONFIG', 1) |
| 123 | deps += [fontconfig_dep] |
| 124 | endif |
| 125 | |
Tim-Philipp Müller | b7796a5 | 2018-11-12 16:56:56 +0000 | [diff] [blame^] | 126 | # uniscribe (windows) - FIXME: untested |
| 127 | if host_machine.system() == 'windows' and not get_option('uniscribe').disabled() |
| 128 | # TODO: make nicer once we have https://github.com/mesonbuild/meson/issues/3940 |
| 129 | if cpp.has_header('usp10.h') and cpp.has_header('windows.h') |
| 130 | foreach usplib : ['usp10', 'gdi32', 'rpcrt4'] |
| 131 | deps += [cpp.find_library(usplib, required: true)] |
| 132 | endforeach |
| 133 | conf.set('HAVE_UNISCRIBE', 1) |
| 134 | elif get_option('uniscribe').enabled() |
| 135 | error('uniscribe was enabled explicitly, but some required headers are missing.') |
| 136 | endif |
| 137 | endif |
| 138 | |
| 139 | # threads |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 140 | if host_machine.system() != 'windows' |
| 141 | thread_dep = dependency('threads', required: false) |
| 142 | |
| 143 | if thread_dep.found() |
| 144 | conf.set('HAVE_PTHREAD', 1) |
| 145 | deps += [thread_dep] |
| 146 | else |
| 147 | check_headers += ['sched.h'] |
| 148 | check_funcs += ['sched_yield', {'link_with': 'rt'}] |
| 149 | endif |
| 150 | endif |
| 151 | |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 152 | conf.set('HAVE_OT', 1) |
| 153 | conf.set('HAVE_FALLBACK', 1) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 154 | conf.set_quoted('PACKAGE_NAME', 'HarfBuzz') |
| 155 | conf.set_quoted('PACKAGE_VERSION', meson.project_version()) |
| 156 | |
| 157 | foreach check : check_headers |
| 158 | name = check[0] |
| 159 | |
| 160 | if cpp.has_header(name) |
| 161 | conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1) |
| 162 | endif |
| 163 | endforeach |
| 164 | |
| 165 | foreach check : check_funcs |
| 166 | name = check[0] |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 167 | opts = check.get(1, {}) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 168 | link_withs = opts.get('link_with', []) |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 169 | check_deps = opts.get('deps', []) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 170 | extra_deps = [] |
| 171 | found = true |
| 172 | |
| 173 | # First try without linking |
| 174 | |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 175 | found = cpp.has_function(name, dependencies: check_deps) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 176 | |
| 177 | if not found and link_withs.length() > 0 |
| 178 | found = true |
| 179 | |
| 180 | foreach link_with : link_withs |
| 181 | dep = cpp.find_library(link_with, required: false) |
| 182 | if dep.found() |
| 183 | extra_deps += dep |
| 184 | else |
| 185 | found = false |
| 186 | endif |
| 187 | endforeach |
| 188 | |
| 189 | if found |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 190 | found = cpp.has_function(name, dependencies: check_deps + extra_deps) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 191 | endif |
| 192 | endif |
| 193 | |
| 194 | if found |
| 195 | deps += extra_deps |
| 196 | conf.set('HAVE_@0@'.format(name.to_upper()), 1) |
| 197 | endif |
| 198 | endforeach |
| 199 | |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 200 | if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics') |
| 201 | conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1) |
| 202 | endif |
| 203 | |
| 204 | if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops') |
| 205 | conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1) |
| 206 | endif |
| 207 | |
| 208 | subdir('src') |
| 209 | subdir('util') |
| 210 | subdir('test') |
| 211 | |
| 212 | configure_file(output: 'config.h', configuration: conf) |