project('fontconfig', 'c', version: '2.17.1', meson_version : '>= 1.6.1', default_options: [ 'c_std=c11,c99', 'buildtype=debugoptimized', 'rust_std=2021', ] ) fs = import('fs') fc_version = meson.project_version() version_arr = fc_version.split('.') fc_version_major = version_arr[0].to_int() fc_version_minor = version_arr[1].to_int() fc_version_micro = version_arr[2].to_int() # Try and maintain compatibility with the previous libtool versioning # (this is a bit of a hack, but it should work fine for our case where # API is added, in which case LT_AGE and LIBT_CURRENT are both increased) soversion = fc_version_major - 1 curversion = fc_version_minor - 1 libversion = '@0@.@1@.0'.format(soversion, curversion) defversion = '@0@.@1@'.format(curversion, fc_version_micro) osxversion = curversion + 1 cacheversion = '9' freetype_req = '>= 21.0.15' freetype_req_cmake = '>= 2.8.1' cc = meson.get_compiler('c') math_dep = cc.find_library('m', required: false) conf = configuration_data() freetype_dep = dependency('freetype2', method: 'pkg-config', version: freetype_req, required: false) # Give another shot using CMake if not freetype_dep.found() freetype_dep = dependency('freetype', method: 'cmake', version: freetype_req_cmake, fallback: ['freetype2', 'freetype_dep'], default_options: 'werror=false') endif if freetype_dep.type_name() == 'internal' conf.set('FREETYPE_PCF_LONG_FAMILY_NAMES', false) else if cc.compiles(files('meson-cc-tests/freetype-pcf-long-family-names.c'), dependencies: freetype_dep) conf.set('FREETYPE_PCF_LONG_FAMILY_NAMES', true) else conf.set('FREETYPE_PCF_LONG_FAMILY_NAMES', false) endif endif jsonc_dep = dependency('json-c', required: false) xml_dep = dependency('', required: false) xmlbackend = get_option('xml-backend') xmltype = '' if xmlbackend == 'auto' or xmlbackend == 'expat' # Linking expat should not be so difficult... see: https://github.com/mesonbuild/meson/issues/10516 xml_dep = dependency('expat', required: false) if not xml_dep.found() xml_dep = cc.find_library('expat', required : false) if not xml_dep.found() and xmlbackend == 'expat' xml_dep = dependency('expat', method: 'system', required: true, fallback: ['expat', 'expat_dep']) else xmltype = 'expat' endif endif endif if (xmlbackend == 'auto' and not xml_dep.found()) or xmlbackend == 'libxml2' xml_dep = dependency('libxml-2.0', required: true) conf.set('ENABLE_LIBXML2', 1) endif if xmltype == '' xmltype = xml_dep.name() endif fontations = get_option('fontations') if (fontations.enabled()) conf.set('ENABLE_FONTATIONS', 1) add_languages(['rust'], native: false, required : true) endif pkgmod = import('pkgconfig') python3 = import('python').find_installation() pytest = find_program('pytest', required: false) check_headers = [ ['dirent.h'], ['dlfcn.h'], ['fcntl.h'], ['inttypes.h'], ['stdint.h'], ['stdio.h'], ['stdlib.h'], ['strings.h'], ['string.h'], ['unistd.h'], ['sys/statvfs.h'], ['sys/vfs.h'], ['sys/statfs.h'], ['sys/stat.h'], ['sys/types.h'], ['sys/param.h'], ['sys/mount.h'], ['time.h'], ['wchar.h'], ] check_funcs = [ ['link'], ['mkstemp'], ['mkostemp'], ['_mktemp_s'], ['mkdtemp'], ['getopt'], ['getopt_long'], ['getprogname'], ['getexecname'], ['rand'], ['random'], ['lrand48'], ['random_r'], ['rand_r'], ['readlink'], ['fstatvfs'], ['fstatfs'], ['lstat'], ['strerror'], ['strerror_r'], ['mmap'], ['vprintf'], ['vsnprintf'], ['vsprintf'], ['getpagesize'], ['getpid'], ['dcgettext'], ['gettext'], ['localtime_r'], ] check_freetype_funcs = [ ['FT_Get_BDF_Property', {'dependencies': freetype_dep}], ['FT_Get_PS_Font_Info', {'dependencies': freetype_dep}], ['FT_Has_PS_Glyph_Names', {'dependencies': freetype_dep}], ['FT_Get_X11_Font_Format', {'dependencies': freetype_dep}], ['FT_Done_MM_Var', {'dependencies': freetype_dep}], ] check_header_symbols = [ ['posix_fadvise', 'fcntl.h'] ] check_struct_members = [ ['struct statvfs', 'f_basetype', ['sys/statvfs.h']], ['struct statvfs', 'f_fstypename', ['sys/statvfs.h']], ['struct statfs', 'f_flags', ['sys/vfs.h', 'sys/statfs.h', 'sys/param.h', 'sys/mount.h']], ['struct statfs', 'f_fstypename', ['sys/vfs.h', 'sys/statfs.h', 'sys/param.h', 'sys/mount.h']], ['struct stat', 'st_mtim', ['sys/stat.h']], ['struct dirent', 'd_type', ['sys/types.h', 'dirent.h']], ] check_sizeofs = [ ['void *', {'conf-name': 'SIZEOF_VOID_P'}], ] check_alignofs = [ ['void *', {'conf-name': 'ALIGNOF_VOID_P'}], ['double'], ] add_project_arguments('-DHAVE_CONFIG_H', language: 'c') if cc.get_id() == 'clang' and host_machine.cpu_family() == 'wasm' add_project_arguments('-matomics', '-mbulk-memory', language: 'c') endif c_args = [] deps = [freetype_dep, xml_dep] incbase = include_directories('.', 'fc-lang') # For compatibility to autoconf (regardless of the usage in fontconfig) conf.set_quoted('PACKAGE_NAME', meson.project_name()) conf.set_quoted('PACKAGE_TARNAME', 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_BUGREPORT', 'https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/new') conf.set_quoted('PACKAGE_URL', '') conf.set('WORDS_BIGENDIAN', (host_machine.endian() == 'big').to_int()) if host_machine.system() == 'windows' conf.set('EXEEXT', '.exe') else conf.set('EXEEXT', '') endif i18n = import('i18n') gettext_args = [ '--msgid-bugs-address=@0@'.format(conf.get('PACKAGE_BUGREPORT')) ] # Check for libintl.h opt_nls = get_option('nls') libintl_dep = dependency('', required: false) if opt_nls.allowed() libintl_dep = dependency('intl', required: opt_nls, fallback: ['libintl', 'libintl_dep']) endif if libintl_dep.found() conf.set('ENABLE_NLS', opt_nls.allowed().to_int()) deps += [libintl_dep] if host_machine.system() == 'darwin' deps += [dependency('CoreFoundation', method: 'extraframework')] endif else opt_nls = opt_nls.require(false) endif # Check iconv support iconv = get_option('iconv') iconv_dep = dependency('', required: false) found_iconv = 0 if iconv.allowed() iconv_dep = cc.find_library('iconv', required: false) if cc.has_header_symbol('iconv.h', 'libiconv_open', dependencies: libintl_dep) conf.set('LIBICONV_PLUG', 1) found_iconv = 1 elif cc.has_header('iconv.h') and cc.has_function('iconv_open', dependencies: iconv_dep) found_iconv = 1 else iconv.require(false) endif endif conf.set('USE_ICONV', found_iconv) deps += [iconv_dep] # We cannot try compiling against an internal dependency if freetype_dep.type_name() == 'internal' foreach func: check_freetype_funcs name = func[0] conf.set('HAVE_@0@'.format(name.to_upper()), 1) endforeach else check_funcs += check_freetype_funcs endif foreach check : check_headers name = check[0] if cc.has_header(name) conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1) endif endforeach foreach check : check_funcs name = check[0] opts = check.length() > 1 ? check[1] : {} extra_deps = opts.get('dependencies', []) if cc.has_function(name, dependencies: extra_deps) conf.set('HAVE_@0@'.format(name.to_upper()), 1) endif endforeach foreach check : check_header_symbols name = check[0] header = check[1] if cc.has_header_symbol(header, name) conf.set('HAVE_@0@'.format(name.to_upper()), 1) endif endforeach foreach check : check_struct_members struct_name = check[0] member_name = check[1] headers = check[2] prefix = '' foreach header : headers prefix += '#include <@0@>\n'.format(header) endforeach if cc.has_member(struct_name, member_name, prefix: prefix) conf.set('HAVE_@0@_@1@'.format(struct_name, member_name).to_upper().underscorify(), 1) endif endforeach foreach check : check_sizeofs type = check[0] opts = check.length() > 1 ? check[1] : {} conf_name = opts.get('conf-name', 'SIZEOF_@0@'.format(type.to_upper())) conf.set(conf_name, cc.sizeof(type)) endforeach foreach check : check_alignofs type = check[0] opts = check.length() > 1 ? check[1] : {} conf_name = opts.get('conf-name', 'ALIGNOF_@0@'.format(type.to_upper())) conf.set(conf_name, cc.alignment(type)) endforeach if cc.compiles(files('meson-cc-tests/flexible-array-member-test.c')) conf.set('FLEXIBLE_ARRAY_MEMBER', '/**/') else conf.set('FLEXIBLE_ARRAY_MEMBER', 1) endif if cc.compiles(files('meson-cc-tests/pthread-prio-inherit-test.c')) conf.set('HAVE_PTHREAD_PRIO_INHERIT', 1) endif if cc.links(files('meson-cc-tests/stdatomic-primitives-test.c'), name: 'stdatomic.h atomics') conf.set('HAVE_STDATOMIC_PRIMITIVES', 1) endif if cc.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics') conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1) endif if cc.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops') conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1) endif if host_machine.system() == 'windows' conf.set('HAVE_GETOPT', 1) conf.set('HAVE_GETOPT_LONG', 1) getopt_dep = cc.find_library('getopt', required: false) else getopt_dep = dependency('', required: false) endif prefix = get_option('prefix') fonts_conf = configuration_data() default_fonts_dirs = get_option('default-fonts-dirs') if default_fonts_dirs == ['yes'] if host_machine.system() == 'windows' fc_fonts_paths = ['WINDOWSFONTDIR', 'WINDOWSUSERFONTDIR'] elif host_machine.system() == 'darwin' fc_fonts_paths = ['/System/Library/Fonts', '/Library/Fonts', '~/Library/Fonts', '/System/Library/Assets/com_apple_MobileAsset_Font3', '/System/Library/Assets/com_apple_MobileAsset_Font4'] elif host_machine.system() == 'android' fc_fonts_paths = ['/system/fonts/', '/product/fonts/'] else fc_fonts_paths = ['/usr/share/fonts', '/usr/local/share/fonts'] endif else fc_fonts_paths = default_fonts_dirs endif xml_path = '' escaped_xml_path = '' foreach p : fc_fonts_paths s = '\t