Emmanuele Bassi | 545b911 | 2018-10-05 00:46:33 +0100 | [diff] [blame] | 1 | project('libepoxy', 'c', version: '1.5.4', |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 2 | default_options: [ |
Emmanuele Bassi | 59318ed | 2016-12-14 15:35:44 +0000 | [diff] [blame] | 3 | 'buildtype=debugoptimized', |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 4 | 'c_std=gnu99', |
| 5 | 'warning_level=1', |
| 6 | ], |
| 7 | license: 'MIT', |
Emmanuele Bassi | 7a88ef5 | 2018-10-04 18:05:58 +0200 | [diff] [blame] | 8 | meson_version: '>= 0.47.0') |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 9 | |
| 10 | epoxy_version = meson.project_version().split('.') |
| 11 | epoxy_major_version = epoxy_version[0].to_int() |
| 12 | epoxy_minor_version = epoxy_version[1].to_int() |
| 13 | epoxy_micro_version = epoxy_version[2].to_int() |
| 14 | |
| 15 | epoxy_prefix = get_option('prefix') |
| 16 | epoxy_libdir = join_paths(epoxy_prefix, get_option('libdir')) |
| 17 | epoxy_datadir = join_paths(epoxy_prefix, get_option('datadir')) |
| 18 | epoxy_includedir = join_paths(epoxy_prefix, get_option('includedir')) |
| 19 | |
| 20 | cc = meson.get_compiler('c') |
| 21 | host_system = host_machine.system() |
| 22 | |
| 23 | conf = configuration_data() |
| 24 | conf.set_quoted('PACKAGE_NAME', meson.project_name()) |
| 25 | conf.set_quoted('PACKAGE_VERSION', meson.project_version()) |
| 26 | conf.set_quoted('PACKAGE_STRING', '@0@-@1@'.format(meson.project_name(), meson.project_version())) |
| 27 | conf.set_quoted('PACKAGE_DATADIR', join_paths(get_option('prefix'), get_option('datadir'))) |
| 28 | conf.set_quoted('PACKAGE_LIBDIR', join_paths(get_option('prefix'), get_option('libdir'))) |
| 29 | conf.set_quoted('PACKAGE_LOCALEDIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale')) |
| 30 | conf.set_quoted('PACKAGE_LIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir'))) |
Emmanuele Bassi | c8613a2 | 2018-04-25 11:43:12 +0100 | [diff] [blame] | 31 | conf.set('HAVE_KHRPLATFORM_H', cc.has_header('KHR/khrplatform.h')) |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 32 | |
Emmanuele Bassi | 476851b | 2017-01-18 15:40:00 +0000 | [diff] [blame] | 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 |
Emmanuele Bassi | a7c3178 | 2018-02-23 15:51:56 +0000 | [diff] [blame] | 37 | enable_glx = get_option('glx') |
Emmanuele Bassi | 476851b | 2017-01-18 15:40:00 +0000 | [diff] [blame] | 38 | if enable_glx == 'auto' |
Eric Engestrom | 5f15168 | 2018-03-13 12:21:14 +0000 | [diff] [blame] | 39 | build_glx = not ['windows', 'darwin', 'android', 'haiku'].contains(host_system) |
| 40 | else |
| 41 | build_glx = enable_glx == 'yes' |
Emmanuele Bassi | 476851b | 2017-01-18 15:40:00 +0000 | [diff] [blame] | 42 | endif |
| 43 | |
Emmanuele Bassi | a7c3178 | 2018-02-23 15:51:56 +0000 | [diff] [blame] | 44 | enable_egl = get_option('egl') |
Thomas Petazzoni | 0511fc5 | 2017-05-08 23:12:49 +0200 | [diff] [blame] | 45 | if enable_egl == 'auto' |
Eric Engestrom | 5f15168 | 2018-03-13 12:21:14 +0000 | [diff] [blame] | 46 | build_egl = not ['windows', 'darwin'].contains(host_system) |
| 47 | else |
| 48 | build_egl = enable_egl == 'yes' |
Thomas Petazzoni | 0511fc5 | 2017-05-08 23:12:49 +0200 | [diff] [blame] | 49 | endif |
| 50 | |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 51 | enable_x11 = get_option('x11') |
| 52 | if 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 |
| 57 | endif |
| 58 | |
Emmanuele Bassi | 476851b | 2017-01-18 15:40:00 +0000 | [diff] [blame] | 59 | # The remaining platform specific API for GL/GLES are enabled |
| 60 | # depending on the platform we're building for |
| 61 | if host_system == 'windows' |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 62 | build_wgl = true |
| 63 | has_znow = true |
| 64 | elif host_system == 'darwin' |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 65 | build_wgl = false |
| 66 | has_znow = false |
| 67 | else |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 68 | build_wgl = false |
| 69 | has_znow = true |
| 70 | endif |
| 71 | |
Emmanuele Bassi | 476851b | 2017-01-18 15:40:00 +0000 | [diff] [blame] | 72 | conf.set10('ENABLE_GLX', build_glx) |
Thomas Petazzoni | 0511fc5 | 2017-05-08 23:12:49 +0200 | [diff] [blame] | 73 | conf.set10('ENABLE_EGL', build_egl) |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 74 | conf.set10('ENABLE_X11', enable_x11) |
Emmanuele Bassi | 476851b | 2017-01-18 15:40:00 +0000 | [diff] [blame] | 75 | |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 76 | # Compiler flags, taken from the Xorg macros |
Emmanuele Bassi | 9b56140 | 2017-02-09 13:48:59 +0000 | [diff] [blame] | 77 | if 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 = [ |
Emmanuele Bassi | 9b56140 | 2017-02-09 13:48:59 +0000 | [diff] [blame] | 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 | ] |
| 99 | elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' |
Emmanuele Bassi | 37eaaad | 2017-02-08 17:51:34 +0000 | [diff] [blame] | 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 | ] |
| 133 | else |
| 134 | test_cflags = [] |
| 135 | endif |
| 136 | |
Emmanuele Bassi | 1489c20 | 2018-02-24 14:01:46 +0000 | [diff] [blame] | 137 | common_cflags = cc.get_supported_arguments(test_cflags) |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 138 | |
Emmanuele Bassi | 4719e58 | 2017-03-09 21:21:09 +0000 | [diff] [blame] | 139 | libtype = get_option('default_library') |
| 140 | |
| 141 | # Visibility compiler flags; we only use this for shared libraries |
Dylan Baker | c02a02d | 2017-10-13 16:50:44 -0700 | [diff] [blame] | 142 | visibility_cflags = [] |
Emmanuele Bassi | 4719e58 | 2017-03-09 21:21:09 +0000 | [diff] [blame] | 143 | if libtype == 'shared' |
Emmanuele Bassi | 7a06803 | 2017-01-24 17:43:59 +0000 | [diff] [blame] | 144 | if host_system == 'windows' |
| 145 | conf.set('DLL_EXPORT', true) |
Emmanuele Bassi | 898ba5d | 2017-06-06 10:50:14 +0100 | [diff] [blame] | 146 | conf.set('EPOXY_PUBLIC', '__declspec(dllexport) extern') |
| 147 | if cc.get_id() != 'msvc' |
Emmanuele Bassi | 7a06803 | 2017-01-24 17:43:59 +0000 | [diff] [blame] | 148 | visibility_cflags += [ '-fvisibility=hidden' ] |
| 149 | endif |
| 150 | else |
Emmanuele Bassi | 4719e58 | 2017-03-09 21:21:09 +0000 | [diff] [blame] | 151 | conf.set('EPOXY_PUBLIC', '__attribute__((visibility("default"))) extern') |
Emmanuele Bassi | 7a06803 | 2017-01-24 17:43:59 +0000 | [diff] [blame] | 152 | visibility_cflags += [ '-fvisibility=hidden' ] |
| 153 | endif |
| 154 | endif |
| 155 | |
Andrei Fadeev | c39f161 | 2017-03-15 09:13:34 +0300 | [diff] [blame] | 156 | # The inline keyword is available only for C++ in MSVC. |
| 157 | # So we need to use Microsoft specific __inline. |
| 158 | if host_system == 'windows' |
| 159 | if cc.get_id() == 'msvc' |
| 160 | conf.set('inline', '__inline') |
| 161 | endif |
| 162 | endif |
| 163 | |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 164 | # Dependencies |
| 165 | dl_dep = cc.find_library('dl', required: false) |
| 166 | gl_dep = dependency('gl', required: false) |
| 167 | egl_dep = dependency('egl', required: false) |
| 168 | |
| 169 | # Optional dependencies for tests |
| 170 | x11_dep = dependency('x11', required: false) |
Emmanuele Bassi | f7d3671 | 2017-03-09 21:28:52 +0000 | [diff] [blame] | 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 |
| 175 | gles2_dep = dependency('glesv2', required: false) |
| 176 | if not gles2_dep.found() |
| 177 | gles2_dep = cc.find_library('libGLESv2', required: false) |
| 178 | endif |
| 179 | |
| 180 | gles1_dep = dependency('glesv1_cm', required: false) |
| 181 | if not gles1_dep.found() |
| 182 | gles1_dep = cc.find_library('libGLESv1_CM', required: false) |
| 183 | endif |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 184 | |
Emmanuele Bassi | ba2e7b1 | 2017-01-19 18:41:40 +0000 | [diff] [blame] | 185 | # On windows, the DLL has to have all of its functions |
luz.paz | d60b923 | 2018-03-05 06:08:53 -0500 | [diff] [blame] | 186 | # resolved at link time, so we have to link directly against |
Emmanuele Bassi | ba2e7b1 | 2017-01-19 18:41:40 +0000 | [diff] [blame] | 187 | # opengl32. But that's the only GL provider, anyway. |
| 188 | if 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) |
| 197 | endif |
| 198 | |
Emmanuele Bassi | 89f9aa0 | 2017-02-13 09:26:57 +0000 | [diff] [blame] | 199 | # Python |
Emmanuele Bassi | 0dfe840 | 2017-03-28 10:06:29 +0100 | [diff] [blame] | 200 | python = import('python3').find_python() |
Emmanuele Bassi | 877fe81 | 2017-02-13 09:33:19 +0000 | [diff] [blame] | 201 | if not python.found() |
| 202 | python = find_program('python', required: true) |
| 203 | endif |
Emmanuele Bassi | 89f9aa0 | 2017-02-13 09:26:57 +0000 | [diff] [blame] | 204 | |
Emmanuele Bassi | 59318ed | 2016-12-14 15:35:44 +0000 | [diff] [blame] | 205 | # Generates the dispatch tables |
Emmanuele Bassi | 0dfe840 | 2017-03-28 10:06:29 +0100 | [diff] [blame] | 206 | gen_dispatch_py = files('src/gen_dispatch.py') |
Emmanuele Bassi | 59318ed | 2016-12-14 15:35:44 +0000 | [diff] [blame] | 207 | |
Patrick Griffis | 61dac91 | 2017-01-27 19:13:48 -0500 | [diff] [blame] | 208 | gl_registry = files('registry/gl.xml') |
| 209 | egl_registry = files('registry/egl.xml') |
| 210 | glx_registry = files('registry/glx.xml') |
| 211 | wgl_registry = files('registry/wgl.xml') |
Emmanuele Bassi | 59318ed | 2016-12-14 15:35:44 +0000 | [diff] [blame] | 212 | |
| 213 | libepoxy_inc = [ |
| 214 | include_directories('include'), |
| 215 | include_directories('src'), |
| 216 | ] |
| 217 | |
| 218 | subdir('include/epoxy') |
Emmanuele Bassi | 08cc4d0 | 2016-12-09 12:28:42 +0000 | [diff] [blame] | 219 | subdir('src') |
Ross Burton | a35192b | 2018-03-01 17:37:42 +0000 | [diff] [blame] | 220 | |
| 221 | if get_option('tests') |
| 222 | subdir('test') |
| 223 | endif |
Emmanuele Bassi | 59d9c2d | 2017-01-25 16:38:02 +0000 | [diff] [blame] | 224 | |
Emmanuele Bassi | a7c3178 | 2018-02-23 15:51:56 +0000 | [diff] [blame] | 225 | if get_option('docs') |
Emmanuele Bassi | 59d9c2d | 2017-01-25 16:38:02 +0000 | [diff] [blame] | 226 | doxygen = find_program('doxygen', required: false) |
| 227 | if doxygen.found() |
| 228 | subdir('doc') |
| 229 | else |
| 230 | message('Documentation disabled without doxygen') |
| 231 | endif |
| 232 | endif |