1# SPDX-License-Identifier: MIT 2# 3# Copyright (c) 2025, Oracle and/or its affiliates. 4# 5# Permission is hereby granted, free of charge, to any person obtaining a 6# copy of this software and associated documentation files (the "Software"), 7# to deal in the Software without restriction, including without limitation 8# the rights to use, copy, modify, merge, publish, distribute, sublicense, 9# and/or sell copies of the Software, and to permit persons to whom the 10# Software is furnished to do so, subject to the following conditions: 11# 12# The above copyright notice and this permission notice (including the next 13# paragraph) shall be included in all copies or substantial portions of the 14# Software. 15# 16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22# DEALINGS IN THE SOFTWARE. 23# 24 25# 26# This is the package version number, not the shared library 27# version. This version number will be substituted into Xft.h 28# Please bump the minor library number at each release as well. 29# 30project( 31 'libXft', 32 'c', 33 version: '2.3.9', 34 license: 'HPND-sell-variant', 35 license_files: 'COPYING', 36 meson_version: '>= 1.1.0', 37) 38 39# Replacement for XORG_DEFAULT_OPTIONS 40cc = meson.get_compiler('c') 41if cc.has_argument('-fno-strict-aliasing') 42 add_project_arguments('-fno-strict-aliasing', language: 'c') 43endif 44 45# Make builds reproducible instead of embedding build paths due to use 46# of __FILE__ in the assert() macro 47fs = import('fs') 48source_prefix_path = fs.relative_to( 49 meson.project_source_root(), 50 meson.project_build_root() 51) 52macro_prefix_map = '-fmacro-prefix-map=' + source_prefix_path + '/src/=' 53if cc.has_argument(macro_prefix_map) 54 add_project_arguments(macro_prefix_map, language: 'c') 55endif 56 57prog_sed = find_program('sed') 58 59# Set library version for Xft.h from package version set above 60xft_version = meson.project_version() 61xft_vers_components = xft_version.split('.') 62xft_vers_conf = configuration_data() 63xft_vers_conf.set('XFT_MAJOR', xft_vers_components[0], 64 description: 'Major version of Xft') 65xft_vers_conf.set('XFT_MINOR', xft_vers_components[1], 66 description: 'Minor version of Xft') 67xft_vers_conf.set('XFT_REVISION', xft_vers_components[2], 68 description: 'Micro revision of Xft') 69# Temporary solution to allow building with either autoconf or meson 70# during the transition period - can be replaced by configure_file() 71# and use of '#mesondefine' when configure.ac is removed. 72xft_h = custom_target( 73 input: 'include/X11/Xft/Xft.h.in', 74 output: 'Xft.h', 75 command: [ 76 prog_sed, 77 '-e', f's/#undef XFT_MAJOR/#define XFT_MAJOR @0@/'.format(xft_vers_conf.get('XFT_MAJOR')), 78 '-e', f's/#undef XFT_MINOR/#define XFT_MINOR @0@/'.format(xft_vers_conf.get('XFT_MINOR')), 79 '-e', f's/#undef XFT_REVISION/#define XFT_REVISION @0@/'.format(xft_vers_conf.get('XFT_REVISION')), 80 '@INPUT@', 81 ], 82 capture: true, 83 install: true, 84 install_dir: get_option('prefix') / get_option('includedir') / 'X11/Xft' 85) 86 87 88# Check for Xrender 89dep_xrender = dependency('xrender', required: true, version: '>= 0.8.2') 90dep_libx11 = dependency('x11', required: true) 91dep_xproto = dependency('xproto', required: true, version: '>= 7.0.22') 92 93# Check freetype configuration 94dep_freetype = dependency('freetype2', required: true, version: '>= 2.1.6') 95 96# Check fontconfig configuration 97dep_fontconfig = dependency('fontconfig', required: true, version: '>= 2.5.92') 98 99libXft_sources = [ 100 'src/xftcolor.c', 101 'src/xftcore.c', 102 'src/xftdbg.c', 103 'src/xftdpy.c', 104 'src/xftdraw.c', 105 'src/xftextent.c', 106 'src/xftfont.c', 107 'src/xftfreetype.c', 108 'src/xftglyphs.c', 109 'src/xftinit.c', 110 'src/xftlist.c', 111 'src/xftname.c', 112 'src/xftrender.c', 113 'src/xftstr.c', 114 'src/xftswap.c', 115 'src/xftxlfd.c' 116] 117 118lib = library( 119 'Xft', 120 libXft_sources, 121 include_directories: 'include/X11/Xft', 122 dependencies: [dep_fontconfig, dep_freetype, dep_xrender, dep_libx11, 123 dep_xproto], 124 sources: xft_h, 125 version: xft_version, 126 install: true, 127) 128 129install_headers( 130 'include/X11/Xft/XftCompat.h', 131 subdir: 'X11/Xft', 132) 133 134pkg = import('pkgconfig') 135pkg.generate( 136 name: 'Xft', 137 description: 'X FreeType library', 138 filebase: 'xft', 139 libraries: '-L${libdir} -lXft', 140 requires: ['xproto'], 141 requires_private: ['xrender', 'fontconfig', 'freetype2'], 142 url: 'https://gitlab.freedesktop.org/xorg/lib/libxft/' 143) 144 145lib_man_suffix = get_option('lib_man_suffix') 146 147custom_target( 148 input: 'man/Xft.man', 149 output: f'Xft.@lib_man_suffix@', 150 command: [ 151 prog_sed, 152 '-e', f's/__libmansuffix__/@lib_man_suffix@/g', 153 '-e', 's/__vendorversion__/"libXft @0@" "X Version 11"/'.format(meson.project_version()), 154 '@INPUT@', 155 ], 156 capture: true, 157 install: true, 158 install_dir: get_option('prefix') / get_option('mandir') / f'man@lib_man_suffix@', 159) 160 161shadow_man_pages = [ 162 'XftCharExists', 163 'XftCharFontSpecRender', 164 'XftCharIndex', 165 'XftCharSpecRender', 166 'XftColorAllocName', 167 'XftColorAllocValue', 168 'XftColorFree', 169 'XftDefaultHasRender', 170 'XftDefaultSet', 171 'XftDefaultSubstitute', 172 'XftDrawChange', 173 'XftDrawCharFontSpec', 174 'XftDrawCharSpec', 175 'XftDrawColormap', 176 'XftDrawCreate', 177 'XftDrawCreateAlpha', 178 'XftDrawCreateBitmap', 179 'XftDrawDestroy', 180 'XftDrawDisplay', 181 'XftDrawDrawable', 182 'XftDrawGlyphFontSpec', 183 'XftDrawGlyphSpec', 184 'XftDrawGlyphs', 185 'XftDrawPicture', 186 'XftDrawRect', 187 'XftDrawSetClip', 188 'XftDrawSetClipRectangles', 189 'XftDrawSetSubwindowMode', 190 'XftDrawSrcPicture', 191 'XftDrawString16', 192 'XftDrawString32', 193 'XftDrawString8', 194 'XftDrawStringUtf16', 195 'XftDrawStringUtf8', 196 'XftDrawVisual', 197 'XftFontCheckGlyph', 198 'XftFontClose', 199 'XftFontCopy', 200 'XftFontInfoCreate', 201 'XftFontInfoDestroy', 202 'XftFontInfoEqual', 203 'XftFontInfoHash', 204 'XftFontLoadGlyphs', 205 'XftFontMatch', 206 'XftFontOpen', 207 'XftFontOpenInfo', 208 'XftFontOpenName', 209 'XftFontOpenPattern', 210 'XftFontOpenXlfd', 211 'XftFontUnloadGlyphs', 212 'XftGetVersion', 213 'XftGlyphExtents', 214 'XftGlyphFontSpecRender', 215 'XftGlyphRender', 216 'XftGlyphSpecRender', 217 'XftInit', 218 'XftInitFtLibrary', 219 'XftListFonts', 220 'XftLockFace', 221 'XftNameParse', 222 'XftNameUnparse', 223 'XftTextExtents16', 224 'XftTextExtents32', 225 'XftTextExtents8', 226 'XftTextExtentsUtf16', 227 'XftTextExtentsUtf8', 228 'XftTextRender16', 229 'XftTextRender16BE', 230 'XftTextRender16LE', 231 'XftTextRender32', 232 'XftTextRender32BE', 233 'XftTextRender32LE', 234 'XftTextRender8', 235 'XftTextRenderUtf16', 236 'XftTextRenderUtf8', 237 'XftUnlockFace', 238 'XftXlfdParse' 239] 240 241foreach man: shadow_man_pages 242 custom_target( 243 output: f'@man@.@lib_man_suffix@', 244 command: ['echo', f'.so man@lib_man_suffix@/Xft.@lib_man_suffix@'], 245 capture: true, 246 install: true, 247 install_dir: get_option('prefix') / get_option('mandir') / f'man@lib_man_suffix@', 248 ) 249endforeach 250