1project('libepoxy', 'c', version: '1.5.4', 2 default_options: [ 3 'buildtype=debugoptimized', 4 'c_std=gnu99', 5 'warning_level=1', 6 ], 7 license: 'MIT', 8 meson_version: '>= 0.47.0') 9 10epoxy_version = meson.project_version().split('.') 11epoxy_major_version = epoxy_version[0].to_int() 12epoxy_minor_version = epoxy_version[1].to_int() 13epoxy_micro_version = epoxy_version[2].to_int() 14 15epoxy_prefix = get_option('prefix') 16epoxy_libdir = join_paths(epoxy_prefix, get_option('libdir')) 17epoxy_datadir = join_paths(epoxy_prefix, get_option('datadir')) 18epoxy_includedir = join_paths(epoxy_prefix, get_option('includedir')) 19 20cc = meson.get_compiler('c') 21host_system = host_machine.system() 22 23conf = configuration_data() 24conf.set_quoted('PACKAGE_NAME', meson.project_name()) 25conf.set_quoted('PACKAGE_VERSION', meson.project_version()) 26conf.set_quoted('PACKAGE_STRING', '@0@-@1@'.format(meson.project_name(), meson.project_version())) 27conf.set_quoted('PACKAGE_DATADIR', join_paths(get_option('prefix'), get_option('datadir'))) 28conf.set_quoted('PACKAGE_LIBDIR', join_paths(get_option('prefix'), get_option('libdir'))) 29conf.set_quoted('PACKAGE_LOCALEDIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale')) 30conf.set_quoted('PACKAGE_LIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir'))) 31conf.set('HAVE_KHRPLATFORM_H', cc.has_header('KHR/khrplatform.h')) 32 33# GLX can be used on different platforms, so we expose a 34# configure time switch to enable or disable it; in case 35# the "auto" default value is set, we only enable GLX 36# support on Linux and Unix 37enable_glx = get_option('glx') 38if enable_glx == 'auto' 39 build_glx = not ['windows', 'darwin', 'android', 'haiku'].contains(host_system) 40else 41 build_glx = enable_glx == 'yes' 42endif 43 44enable_egl = get_option('egl') 45if enable_egl == 'auto' 46 build_egl = not ['windows', 'darwin'].contains(host_system) 47else 48 build_egl = enable_egl == 'yes' 49endif 50 51enable_x11 = get_option('x11') 52if not enable_x11 53 if enable_glx == 'yes' 54 error('GLX support is explicitly enabled, but X11 was disabled') 55 endif 56 build_glx = false 57endif 58 59# The remaining platform specific API for GL/GLES are enabled 60# depending on the platform we're building for 61if host_system == 'windows' 62 build_wgl = true 63 has_znow = true 64elif host_system == 'darwin' 65 build_wgl = false 66 has_znow = false 67else 68 build_wgl = false 69 has_znow = true 70endif 71 72conf.set10('ENABLE_GLX', build_glx) 73conf.set10('ENABLE_EGL', build_egl) 74conf.set10('ENABLE_X11', enable_x11) 75 76# Compiler flags, taken from the Xorg macros 77if cc.get_id() == 'msvc' 78 # Compiler options taken from msvc_recommended_pragmas.h 79 # in GLib, based on _Win32_Programming_ by Rector and Newcomer 80 test_cflags = [ 81 '-we4002', # too many actual parameters for macro 82 '-we4003', # not enough actual parameters for macro 83 '-w14010', # single-line comment contains line-continuation character 84 '-we4013', # 'function' undefined; assuming extern returning int 85 '-w14016', # no function return type; using int as default 86 '-we4020', # too many actual parameters 87 '-we4021', # too few actual parameters 88 '-we4027', # function declared without formal parameter list 89 '-we4029', # declared formal parameter list different from definition 90 '-we4033', # 'function' must return a value 91 '-we4035', # 'function' : no return value 92 '-we4045', # array bounds overflow 93 '-we4047', # different levels of indirection 94 '-we4049', # terminating line number emission 95 '-we4053', # an expression of type void was used as an operand 96 '-we4071', # no function prototype given 97 '-we4819', # the file contains a character that cannot be represented in the current code page 98 ] 99elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' 100 test_cflags = [ 101 '-Wpointer-arith', 102 '-Wmissing-declarations', 103 '-Wformat=2', 104 '-Wstrict-prototypes', 105 '-Wmissing-prototypes', 106 '-Wnested-externs', 107 '-Wbad-function-cast', 108 '-Wold-style-definition', 109 '-Wdeclaration-after-statement', 110 '-Wunused', 111 '-Wuninitialized', 112 '-Wshadow', 113 '-Wmissing-noreturn', 114 '-Wmissing-format-attribute', 115 '-Wredundant-decls', 116 '-Wlogical-op', 117 '-Werror=implicit', 118 '-Werror=nonnull', 119 '-Werror=init-self', 120 '-Werror=main', 121 '-Werror=missing-braces', 122 '-Werror=sequence-point', 123 '-Werror=return-type', 124 '-Werror=trigraphs', 125 '-Werror=array-bounds', 126 '-Werror=write-strings', 127 '-Werror=address', 128 '-Werror=int-to-pointer-cast', 129 '-Werror=pointer-to-int-cast', 130 '-fno-strict-aliasing', 131 '-Wno-int-conversion', 132 ] 133else 134 test_cflags = [] 135endif 136 137common_cflags = cc.get_supported_arguments(test_cflags) 138 139libtype = get_option('default_library') 140 141# Visibility compiler flags; we only use this for shared libraries 142visibility_cflags = [] 143if libtype == 'shared' 144 if host_system == 'windows' 145 conf.set('DLL_EXPORT', true) 146 conf.set('EPOXY_PUBLIC', '__declspec(dllexport) extern') 147 if cc.get_id() != 'msvc' 148 visibility_cflags += [ '-fvisibility=hidden' ] 149 endif 150 else 151 conf.set('EPOXY_PUBLIC', '__attribute__((visibility("default"))) extern') 152 visibility_cflags += [ '-fvisibility=hidden' ] 153 endif 154endif 155 156# The inline keyword is available only for C++ in MSVC. 157# So we need to use Microsoft specific __inline. 158if host_system == 'windows' 159 if cc.get_id() == 'msvc' 160 conf.set('inline', '__inline') 161 endif 162endif 163 164# Dependencies 165dl_dep = cc.find_library('dl', required: false) 166gl_dep = dependency('gl', required: false) 167egl_dep = dependency('egl', required: false) 168 169# Optional dependencies for tests 170x11_dep = dependency('x11', required: false) 171 172# GLES v2 and v1 may have pkg-config files, courtesy of downstream 173# packagers; let's check those first, and fall back to find_library() 174# if we fail 175gles2_dep = dependency('glesv2', required: false) 176if not gles2_dep.found() 177 gles2_dep = cc.find_library('libGLESv2', required: false) 178endif 179 180gles1_dep = dependency('glesv1_cm', required: false) 181if not gles1_dep.found() 182 gles1_dep = cc.find_library('libGLESv1_CM', required: false) 183endif 184 185# On windows, the DLL has to have all of its functions 186# resolved at link time, so we have to link directly against 187# opengl32. But that's the only GL provider, anyway. 188if host_system == 'windows' 189 opengl32_dep = cc.find_library('opengl32', required: true) 190 191 # When building against static libraries, we need to control 192 # the order of the dependencies, and gdi32 provides symbols 193 # needed when using opengl32, like SetPixelFormat and 194 # ChoosePixelFormat. This is mostly a workaround for older 195 # versions of Meson. 196 gdi32_dep = cc.find_library('gdi32', required: true) 197endif 198 199# Python 200python = import('python3').find_python() 201if not python.found() 202 python = find_program('python', required: true) 203endif 204 205# Generates the dispatch tables 206gen_dispatch_py = files('src/gen_dispatch.py') 207 208gl_registry = files('registry/gl.xml') 209egl_registry = files('registry/egl.xml') 210glx_registry = files('registry/glx.xml') 211wgl_registry = files('registry/wgl.xml') 212 213libepoxy_inc = [ 214 include_directories('include'), 215 include_directories('src'), 216] 217 218subdir('include/epoxy') 219subdir('src') 220 221if get_option('tests') 222 subdir('test') 223endif 224 225if get_option('docs') 226 doxygen = find_program('doxygen', required: false) 227 if doxygen.found() 228 subdir('doc') 229 else 230 message('Documentation disabled without doxygen') 231 endif 232endif 233