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