Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame^] | 1 | project('harfbuzz', 'c', 'cpp', |
| 2 | version: '1.7.6') |
| 3 | |
| 4 | cpp = meson.get_compiler('cpp') |
| 5 | |
| 6 | python3 = import('python').find_installation('python3') |
| 7 | |
| 8 | check_headers = [ |
| 9 | ['unistd.h'], |
| 10 | ['sys/mman.h'], |
| 11 | ['xlocale.h'], |
| 12 | ['stdbool.h'], |
| 13 | ] |
| 14 | |
| 15 | check_funcs = [ |
| 16 | ['atexit'], |
| 17 | ['mprotect'], |
| 18 | ['sysconf'], |
| 19 | ['getpagesize'], |
| 20 | ['mmap'], |
| 21 | ['isatty'], |
| 22 | ['newlocale'], |
| 23 | ['strtod_l'], |
| 24 | ['round'], |
| 25 | ] |
| 26 | |
| 27 | check_freetype_funcs = [ |
| 28 | ['FT_Get_Var_Blend_Coordinates'], |
| 29 | ['FT_Set_Var_Blend_Coordinates'], |
| 30 | ['FT_Done_MM_Var'], |
| 31 | ] |
| 32 | |
| 33 | check_alignofs = [ |
| 34 | ['struct{char;}', {'conf-name': 'ALIGNOF_STRUCT_CHAR__'}] |
| 35 | ] |
| 36 | |
| 37 | freetype_dep = dependency('freetype2', required: false) |
| 38 | glib_dep = dependency('glib-2.0', required: false) |
| 39 | gobject_dep = dependency('gobject-2.0', required: false) |
| 40 | cairo_dep = dependency('cairo', required: false) |
| 41 | cairo_ft_dep = dependency('cairo-ft', required: false) |
| 42 | fontconfig_dep = dependency('fontconfig', required: false) |
| 43 | graphite2_dep = dependency('graphite2', required: false) |
| 44 | icu_dep = dependency('icu-uc', required: false) |
| 45 | m_dep = cpp.find_library('m') |
| 46 | |
| 47 | deps = [m_dep] |
| 48 | |
| 49 | conf = configuration_data() |
| 50 | incbase = include_directories('.') |
| 51 | cpp_args = ['-DHAVE_CONFIG_H'] |
| 52 | |
| 53 | warn_cflags = [ |
| 54 | '-Wno-non-virtual-dtor', |
| 55 | ] |
| 56 | |
| 57 | cpp_args += cpp.get_supported_arguments(warn_cflags) |
| 58 | |
| 59 | if glib_dep.found() |
| 60 | conf.set('HAVE_GLIB', 1) |
| 61 | deps += [glib_dep] |
| 62 | endif |
| 63 | |
| 64 | if gobject_dep.found() |
| 65 | conf.set('HAVE_GOBJECT', 1) |
| 66 | deps += [gobject_dep] |
| 67 | endif |
| 68 | |
| 69 | if cairo_dep.found() |
| 70 | conf.set('HAVE_CAIRO', 1) |
| 71 | deps += [cairo_dep] |
| 72 | endif |
| 73 | |
| 74 | if cairo_ft_dep.found() |
| 75 | conf.set('HAVE_CAIRO_FT', 1) |
| 76 | deps += [cairo_ft_dep] |
| 77 | endif |
| 78 | |
| 79 | if graphite2_dep.found() |
| 80 | conf.set('HAVE_GRAPHITE2', 1) |
| 81 | deps += [graphite2_dep] |
| 82 | endif |
| 83 | |
| 84 | if icu_dep.found() |
| 85 | conf.set('HAVE_ICU', 1) |
| 86 | conf.set('HAVE_ICU_BUILTIN', 1) |
| 87 | deps += [icu_dep] |
| 88 | endif |
| 89 | |
| 90 | if 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 |
| 102 | endif |
| 103 | |
| 104 | if fontconfig_dep.found() |
| 105 | conf.set('HAVE_FONTCONFIG', 1) |
| 106 | deps += [fontconfig_dep] |
| 107 | endif |
| 108 | |
| 109 | if 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 |
| 119 | endif |
| 120 | |
| 121 | conf.set('HAVE_OT', true) |
| 122 | conf.set('HAVE_FALLBACK', true) |
| 123 | conf.set_quoted('PACKAGE_NAME', 'HarfBuzz') |
| 124 | conf.set_quoted('PACKAGE_VERSION', meson.project_version()) |
| 125 | |
| 126 | foreach 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 |
| 132 | endforeach |
| 133 | |
| 134 | foreach 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 |
| 166 | endforeach |
| 167 | |
| 168 | foreach 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)) |
| 175 | endforeach |
| 176 | |
| 177 | if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics') |
| 178 | conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1) |
| 179 | endif |
| 180 | |
| 181 | if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops') |
| 182 | conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1) |
| 183 | endif |
| 184 | |
| 185 | subdir('src') |
| 186 | subdir('util') |
| 187 | subdir('test') |
| 188 | |
| 189 | configure_file(output: 'config.h', configuration: conf) |