1project('libepoxy', 'c', version: '1.5.10', 2 default_options: [ 3 'buildtype=debugoptimized', 4 'c_std=gnu99', 5 'warning_level=1', 6 ], 7 license: 'MIT', 8 meson_version: '>= 0.54.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 '/utf-8', # Set the input and exec encoding to utf-8, like is the default with GCC 99 ] 100elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' 101 test_cflags = [ 102 '-Wpointer-arith', 103 '-Wmissing-declarations', 104 '-Wformat=2', 105 '-Wstrict-prototypes', 106 '-Wmissing-prototypes', 107 '-Wnested-externs', 108 '-Wbad-function-cast', 109 '-Wold-style-definition', 110 '-Wdeclaration-after-statement', 111 '-Wunused', 112 '-Wuninitialized', 113 '-Wshadow', 114 '-Wmissing-noreturn', 115 '-Wmissing-format-attribute', 116 '-Wredundant-decls', 117 '-Wlogical-op', 118 '-Werror=implicit', 119 '-Werror=nonnull', 120 '-Werror=init-self', 121 '-Werror=main', 122 '-Werror=missing-braces', 123 '-Werror=sequence-point', 124 '-Werror=return-type', 125 '-Werror=trigraphs', 126 '-Werror=array-bounds', 127 '-Werror=write-strings', 128 '-Werror=address', 129 '-Werror=int-to-pointer-cast', 130 '-Werror=pointer-to-int-cast', 131 '-fno-strict-aliasing', 132 '-Wno-int-conversion', 133 ] 134else 135 test_cflags = [] 136endif 137 138common_cflags = cc.get_supported_arguments(test_cflags) 139 140libtype = get_option('default_library') 141 142# Visibility compiler flags; we only use this for shared libraries 143visibility_cflags = [] 144if libtype == 'shared' 145 if host_system == 'windows' 146 conf.set('DLL_EXPORT', true) 147 conf.set('EPOXY_PUBLIC', '__declspec(dllexport) extern') 148 if cc.get_id() != 'msvc' 149 visibility_cflags += [ '-fvisibility=hidden' ] 150 endif 151 else 152 conf.set('EPOXY_PUBLIC', '__attribute__((visibility("default"))) extern') 153 visibility_cflags += [ '-fvisibility=hidden' ] 154 endif 155endif 156 157# The inline keyword is available only for C++ in MSVC. 158# So we need to use Microsoft specific __inline. 159if host_system == 'windows' 160 if cc.get_id() == 'msvc' 161 conf.set('inline', '__inline') 162 endif 163endif 164 165# Dependencies 166dl_dep = cc.find_library('dl', required: false) 167gl_dep = dependency('gl', required: false) 168egl_dep = dependency('egl', required: false) 169elg_headers_dep = egl_dep.partial_dependency(compile_args: true, includes: true) 170 171# Optional dependencies for tests 172x11_dep = dependency('x11', required: false) 173x11_headers_dep = x11_dep.partial_dependency(compile_args: true, includes: true) 174 175# GLES v2 and v1 may have pkg-config files, courtesy of downstream 176# packagers; let's check those first, and fall back to find_library() 177# if we fail 178gles2_dep = dependency('glesv2', required: false) 179if not gles2_dep.found() 180 gles2_dep = cc.find_library('libGLESv2', required: false) 181endif 182 183gles1_dep = dependency('glesv1_cm', required: false) 184if not gles1_dep.found() 185 gles1_dep = cc.find_library('libGLESv1_CM', required: false) 186endif 187 188# On windows, the DLL has to have all of its functions 189# resolved at link time, so we have to link directly against 190# opengl32. But that's the only GL provider, anyway. 191if host_system == 'windows' 192 opengl32_dep = cc.find_library('opengl32', required: true) 193 194 # When building against static libraries, we need to control 195 # the order of the dependencies, and gdi32 provides symbols 196 # needed when using opengl32, like SetPixelFormat and 197 # ChoosePixelFormat. This is mostly a workaround for older 198 # versions of Meson. 199 gdi32_dep = cc.find_library('gdi32', required: true) 200endif 201 202# Generates the dispatch tables 203gen_dispatch_py = find_program('src/gen_dispatch.py') 204 205gl_registry = files('registry/gl.xml') 206egl_registry = files('registry/egl.xml') 207glx_registry = files('registry/glx.xml') 208wgl_registry = files('registry/wgl.xml') 209 210libepoxy_inc = [ 211 include_directories('include'), 212 include_directories('src'), 213] 214 215subdir('include/epoxy') 216subdir('src') 217 218if get_option('tests') 219 subdir('test') 220endif 221 222if get_option('docs') 223 doxygen = find_program('doxygen', required: false) 224 if doxygen.found() 225 subdir('doc') 226 else 227 message('Documentation disabled without doxygen') 228 endif 229endif 230