meson.build (3749B)
1 project('wld', 'c', 2 version: '0.0', 3 meson_version: '>=1.7.99', 4 license: 'MIT', 5 default_options: [ 6 # C11: libdrm uses anonymous union extension 7 # C23: nouveau.c uses empty initializer extension 8 'c_std=c23', 9 'warning_level=3', 10 'default_library=static', 11 'b_ndebug=if-release', 12 ], 13 ) 14 15 cc = meson.get_compiler('c') 16 pkg = import('pkgconfig') 17 inc = include_directories('protocol') 18 19 c_args = cc.get_supported_arguments([ 20 '-fvisibility=hidden', 21 '-Wvla', 22 '-Werror=implicit-function-declaration', 23 '-Werror=implicit-int', 24 '-Werror=pointer-sign', 25 '-Werror=pointer-arith', 26 27 '-Wno-sign-compare', # pixman.c:630 28 '-Wno-gnu-empty-struct', # ARRAY_LENGTH 29 '-Wno-gnu-statement-expression-from-macro-expansion', # CONTAINER_OF 30 '-Wno-gnu-zero-variadic-macro-arguments', # wld-private.h:57 31 '-Wno-static-in-inline', # context.c:unwrap_buffer 32 '-Wno-unused-parameter', # pixman.c 33 '-Wno-zero-length-array', # libdrm/i915_drm.h:2472 34 '-Wno-varargs', # nouveau.c:332 35 '-Wno-excess-initializers', # wayland.c:121 36 '-I' + meson.current_build_dir(), 37 ]) + [ 38 '-D_POSIX_C_SOURCE=200809L', '-D_NETBSD_SOURCE', 39 get_option('buildtype') == 'debug' ? '-DENABLE_DEBUG=1' : [], 40 ] 41 42 requires = [ 43 dependency('pixman-1'), 44 ] 45 # fontconfig, where it is, finds fonts by name; without it a font is opened 46 # from its file (wld_font_open_file), as a system without fontconfig has to 47 fontconfig = dependency('fontconfig', required: get_option('fontconfig')) 48 extra_cflags = [] 49 if fontconfig.found() 50 requires += fontconfig 51 c_args += '-DWLD_FONTCONFIG' 52 extra_cflags += '-DWLD_FONTCONFIG' 53 endif 54 requires_private = [ 55 dependency('freetype2'), 56 ] 57 58 libwld_src = files( 59 'buffer.c', 60 'buffered_surface.c', 61 'color.c', 62 'context.c', 63 'font.c', 64 'renderer.c', 65 'surface.c', 66 'pixman.c', 67 ) 68 69 wayland = dependency('wayland-client', required: get_option('wayland')) 70 if wayland.found() 71 libwld_src += ['wayland.c', 'wayland-shm.c'] 72 c_args += '-DWITH_WAYLAND_SHM=1' 73 requires_private += wayland 74 endif 75 76 drm = dependency('libdrm', required: get_option('drm')) 77 if drm.found() 78 libwld_src += ['drm.c', 'dumb.c'] 79 requires_private += drm 80 81 drivers = get_option('drivers') 82 foreach driver, src : { 83 'nouveau': ['nouveau.c'], 84 'intel': ['intel.c', 'intel/batch.c'], 85 } 86 if not drivers.contains('auto') and not drivers.contains(driver) 87 continue 88 endif 89 dep = dependency('libdrm_' + driver, required: drivers.contains(driver)) 90 if dep.found() 91 libwld_src += src 92 c_args += '-DWITH_DRM_@0@=1'.format(driver.to_upper()) 93 requires_private += dep 94 endif 95 endforeach 96 endif 97 98 if wayland.found() and drm.found() 99 libwld_src += 'wayland-drm.c' 100 c_args += '-DWITH_WAYLAND_DRM=1' 101 102 protocols = import('wayland').scan_xml( 103 files('protocol/wayland-drm.xml'), 104 public: false, 105 client: true, 106 ) 107 libwld_src += [ protocols[0], protocols[1] ] 108 endif 109 110 install_headers([ 111 'wld.h', 'pixman.h', 112 drm.found() ? 'drm.h' : [], 113 wayland.found() ? 'wayland.h' : [], 114 ], subdir: 'wld') 115 116 libwld_lib = library( 117 'wld', 118 libwld_src, 119 dependencies: requires + requires_private, 120 c_args: c_args, 121 include_directories: inc, 122 # Prevents clashing with wld pixman.h 123 implicit_include_directories: false, 124 install: true, 125 ) 126 127 # Allows other meson projects to use libwld 128 libwld = declare_dependency( 129 link_with: libwld_lib, 130 dependencies: requires + requires_private, 131 ) 132 133 pkg.generate( 134 libwld_lib, 135 name: 'wld', 136 description: 'A primitive drawing library library targeted at Wayland', 137 requires: requires, 138 requires_private: requires_private, 139 extra_cflags: extra_cflags, 140 ) 141 142 doxygen = find_program('doxygen', required: get_option('doxygen')) 143 if doxygen.found() 144 run_target('doxygen', command: [doxygen]) 145 endif