[meson] Make compatbile with 0.49.0

Contains a just put together summary feature polyfill and workaround
to broken ternary operator.
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 25f4b35..9bfca2b 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -77,7 +77,8 @@
       - image: alpine
     steps:
       - checkout
-      - run: apk update && apk add ragel meson gcc g++ glib-dev freetype-dev cairo-dev git
+      - run: apk update && apk add ragel gcc g++ glib-dev freetype-dev cairo-dev git py3-pip ninja
+      - run: pip3 install meson==0.49.0
       - run: meson build --buildtype=minsize
       - run: ninja -Cbuild -j9
       - run: meson test -Cbuild --print-errorlogs
diff --git a/meson.build b/meson.build
index e6d5aa9..ddf20d1 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
 project('harfbuzz', 'c', 'cpp',
-  meson_version: '>= 0.53.0',
+  meson_version: '>= 0.49.0',
   version: '2.7.0',
   default_options: [
     'cpp_eh=none',          # Just to support msvc, we are passing -fno-rtti also anyway
@@ -107,7 +107,12 @@
   endif
 
   if not icu_dep.found() and cpp.get_id() == 'msvc'
-    icu_dep = cpp.find_library(get_option('buildtype') == 'debug' ? 'icuucd' : 'icuuc',
+    if get_option('buildtype') == 'debug'
+      icu_dep_name = 'icuucd'
+    else
+      icu_dep_name = 'icuuc'
+    endif
+    icu_dep = cpp.find_library(icu_dep_name,
                                required: get_option('icu'),
                                has_headers: ['unicode/uchar.h',
                                              'unicode/unorm2.h',
@@ -142,10 +147,10 @@
     if cairo_dep.type_name() == 'internal'
       # It is true at least for the port we have
       cairo_ft_dep = cairo_dep
-    elif cairo_dep.type_name() == 'library' and \
-         cpp.has_function('cairo_ft_font_face_create_for_ft_face',
-                          prefix: '#include <cairo-ft.h>',
-                          dependencies: cairo_dep)
+    elif (cairo_dep.type_name() == 'library' and
+          cpp.has_function('cairo_ft_font_face_create_for_ft_face',
+                           prefix: '#include <cairo-ft.h>',
+                           dependencies: cairo_dep))
       cairo_ft_dep = cairo_dep
     else # including the most important type for us, 'pkgconfig'
       cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo'))
@@ -343,11 +348,11 @@
   subdir('test')
 endif
 
-if not get_option('benchmark').disabled() and \
-    get_option('wrap_mode') != 'nodownload' and \
-    host_machine.system() != 'windows' and \
-    not meson.is_subproject() and \
-    not meson.is_cross_build()
+if (not get_option('benchmark').disabled() and
+    get_option('wrap_mode') != 'nodownload' and
+    host_machine.system() != 'windows' and
+    not meson.is_subproject() and
+    not meson.is_cross_build())
   subdir('perf')
 endif
 
@@ -357,28 +362,53 @@
 
 configure_file(output: 'config.h', configuration: conf)
 
-summary({'prefix': get_option('prefix'),
-         'bindir': get_option('bindir'),
-         'libdir': get_option('libdir'),
-         'includedir': get_option('includedir'),
-         'datadir': get_option('datadir'),
-        }, section: 'Directories')
-summary({'Builtin': true,
-         'Glib': conf.get('HAVE_GLIB', 0) == 1,
-         'ICU': conf.get('HAVE_ICU', 0) == 1,
-        }, bool_yn: true, section: 'Unicode callbacks (you want at least one)')
-summary({'FreeType': conf.get('HAVE_FREETYPE', 0) == 1,
-        }, bool_yn: true, section: 'Font callbacks (the more the merrier)')
-summary({'Cairo': conf.get('HAVE_CAIRO', 0) == 1,
-         'Fontconfig': conf.get('HAVE_FONTCONFIG', 0) == 1,
-        }, bool_yn: true, section: 'Dependencies used for command-line utilities')
-summary({'Graphite2': conf.get('HAVE_GRAPHITE2', 0) == 1,
-        }, bool_yn: true, section: 'Additional shapers')
-summary({'CoreText': conf.get('HAVE_CORETEXT', 0) == 1,
-         'DirectWrite': conf.get('HAVE_DIRECTWRITE', 0) == 1,
-         'GDI/Uniscribe': (conf.get('HAVE_GDI', 0) == 1) and (conf.get('HAVE_UNISCRIBE', 0) == 1),
-        }, bool_yn: true, section: 'Platform shapers (not normally needed)')
-summary({'Documentation': conf.get('HAVE_GTK_DOC', 0) == 1,
-         'GObject bindings': conf.get('HAVE_GOBJECT', 0) == 1,
-         'Introspection': conf.get('HAVE_INTROSPECTION', 0) == 1,
-        }, bool_yn: true, section: 'Other features')
+build_summary = {
+  'Directories':
+    {'prefix': get_option('prefix'),
+     'bindir': get_option('bindir'),
+     'libdir': get_option('libdir'),
+     'includedir': get_option('includedir'),
+     'datadir': get_option('datadir'),
+    },
+  'Unicode callbacks (you want at least one)':
+    {'Builtin': true,
+     'Glib': conf.get('HAVE_GLIB', 0) == 1,
+     'ICU': conf.get('HAVE_ICU', 0) == 1,
+    },
+  'Font callbacks (the more the merrier)':
+    {'FreeType': conf.get('HAVE_FREETYPE', 0) == 1,
+    },
+  'Dependencies used for command-line utilities':
+    {'Cairo': conf.get('HAVE_CAIRO', 0) == 1,
+     'Fontconfig': conf.get('HAVE_FONTCONFIG', 0) == 1,
+    },
+  'Additional shapers':
+    {'Graphite2': conf.get('HAVE_GRAPHITE2', 0) == 1,
+    },
+  'Platform shapers (not normally needed)':
+    {'CoreText': conf.get('HAVE_CORETEXT', 0) == 1,
+     'DirectWrite': conf.get('HAVE_DIRECTWRITE', 0) == 1,
+     'GDI/Uniscribe': (conf.get('HAVE_GDI', 0) == 1) and (conf.get('HAVE_UNISCRIBE', 0) == 1),
+    },
+  'Other features':
+    {'Documentation': conf.get('HAVE_GTK_DOC', 0) == 1,
+     'GObject bindings': conf.get('HAVE_GOBJECT', 0) == 1,
+     'Introspection': conf.get('HAVE_INTROSPECTION', 0) == 1,
+    },
+}
+if meson.version().version_compare('>=0.53')
+  foreach section_title, section : build_summary
+    summary(section, bool_yn: true, section: section_title)
+  endforeach
+else
+  summary = ['']
+  foreach section_title, section : build_summary
+    summary += '  @0@:'.format(section_title)
+    foreach feature, value : section
+      summary += '    @0@:'.format(feature)
+      summary += '          @0@'.format(value)
+    endforeach
+    summary += ''
+  endforeach
+  message('\n'.join(summary))
+endif
diff --git a/perf/meson.build b/perf/meson.build
index e12744c..384574d 100644
--- a/perf/meson.build
+++ b/perf/meson.build
@@ -6,6 +6,12 @@
   ttf_parser_dep = subproject('ttf-parser').get_variable('ttf_parser_dep')
 endif
 
+if ttf_parser_dep.found()
+  benchmark_cpp_args = ['-DHAVE_TTFPARSER']
+else
+  benchmark_cpp_args = []
+endif
+
 benchmark('perf', executable('perf', 'perf.cc',
   dependencies: [
     google_benchmark_dep, freetype_dep,
@@ -14,7 +20,7 @@
     # https://github.com/RazrFalcon/ttf-parser/issues/29
     ttf_parser_dep, thread_dep, cpp.find_library('dl'),
   ],
-  cpp_args: ttf_parser_dep.found() ? ['-DHAVE_TTFPARSER'] : [],
+  cpp_args: benchmark_cpp_args,
   include_directories: [incconfig, incsrc],
   link_with: [libharfbuzz],
   install: false,
diff --git a/src/meson.build b/src/meson.build
index 7bdaee4..b53d8b2 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -563,15 +563,22 @@
 
 have_gobject = conf.get('HAVE_GOBJECT', 0) == 1
 
+if have_gobject
+  have_gobject_string = 'true'
+else
+  have_gobject_string = 'false'
+endif
+
 cmake_config = configuration_data()
 cmake_config.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
 cmake_config.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
 cmake_config.set('HB_LIBTOOL_VERSION_INFO', hb_libtool_version_info)
-cmake_config.set('have_gobject', have_gobject ? 'true' : 'false')
+cmake_config.set('have_gobject', have_gobject_string)
 configure_file(input: 'harfbuzz-config.cmake.in',
   output: 'harfbuzz-config.cmake',
   configuration: cmake_config,
-  install_dir: get_option('libdir') / 'cmake' / 'harfbuzz')
+  install_dir: get_option('libdir') / 'cmake' / 'harfbuzz',
+)
 
 libharfbuzz_gobject_dep = null_dep
 if have_gobject
@@ -670,10 +677,16 @@
                     '--cflags-end'])
   endif
 
+  if build_gir
+    gobject_sources = hb_gen_files_gir
+  else
+    gobject_sources = hb_gobject_sources
+  endif
+
   libharfbuzz_gobject_dep = declare_dependency(
     link_with: libharfbuzz_gobject,
     include_directories: incsrc,
-    sources: build_gir ? hb_gen_files_gir : hb_gobject_sources,
+    sources: gobject_sources,
     dependencies: [glib_dep, gobject_dep])
 
   pkgmod.generate(libharfbuzz_gobject,
@@ -721,10 +734,15 @@
   endif
 
   foreach name : dist_check_script
+    if name == 'check-symbols'
+      test_depends = defs_list
+    else
+      test_depends = []
+    endif
     test(name, find_program(name + '.py'),
       env: env,
-      depends: name == 'check-symbols' ? defs_list : [],
-      suite: ['src'] + (name == 'check-static-inits' ? ['slow'] : []),
+      depends: test_depends,
+      suite: ['src'],
     )
   endforeach
 endif