blob: 91d97928d15d62dc9ed9704f0334c350f1eeac91 [file] [log] [blame]
Emmanuele Bassi545b9112018-10-05 00:46:33 +01001project('libepoxy', 'c', version: '1.5.4',
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +00002 default_options: [
Emmanuele Bassi59318ed2016-12-14 15:35:44 +00003 'buildtype=debugoptimized',
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +00004 'c_std=gnu99',
5 'warning_level=1',
6 ],
7 license: 'MIT',
Emmanuele Bassi7a88ef52018-10-04 18:05:58 +02008 meson_version: '>= 0.47.0')
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +00009
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')))
Emmanuele Bassic8613a22018-04-25 11:43:12 +010031conf.set('HAVE_KHRPLATFORM_H', cc.has_header('KHR/khrplatform.h'))
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +000032
Emmanuele Bassi476851b2017-01-18 15:40:00 +000033# 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 Bassia7c31782018-02-23 15:51:56 +000037enable_glx = get_option('glx')
Emmanuele Bassi476851b2017-01-18 15:40:00 +000038if enable_glx == 'auto'
Eric Engestrom5f151682018-03-13 12:21:14 +000039 build_glx = not ['windows', 'darwin', 'android', 'haiku'].contains(host_system)
40else
41 build_glx = enable_glx == 'yes'
Emmanuele Bassi476851b2017-01-18 15:40:00 +000042endif
43
Emmanuele Bassia7c31782018-02-23 15:51:56 +000044enable_egl = get_option('egl')
Thomas Petazzoni0511fc52017-05-08 23:12:49 +020045if enable_egl == 'auto'
Eric Engestrom5f151682018-03-13 12:21:14 +000046 build_egl = not ['windows', 'darwin'].contains(host_system)
47else
48 build_egl = enable_egl == 'yes'
Thomas Petazzoni0511fc52017-05-08 23:12:49 +020049endif
50
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +000051enable_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
Emmanuele Bassi476851b2017-01-18 15:40:00 +000059# The remaining platform specific API for GL/GLES are enabled
60# depending on the platform we're building for
61if host_system == 'windows'
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +000062 build_wgl = true
63 has_znow = true
64elif host_system == 'darwin'
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +000065 build_wgl = false
66 has_znow = false
67else
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +000068 build_wgl = false
69 has_znow = true
70endif
71
Emmanuele Bassi476851b2017-01-18 15:40:00 +000072conf.set10('ENABLE_GLX', build_glx)
Thomas Petazzoni0511fc52017-05-08 23:12:49 +020073conf.set10('ENABLE_EGL', build_egl)
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +000074conf.set10('ENABLE_X11', enable_x11)
Emmanuele Bassi476851b2017-01-18 15:40:00 +000075
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +000076# Compiler flags, taken from the Xorg macros
Emmanuele Bassi9b561402017-02-09 13:48:59 +000077if 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 Bassi9b561402017-02-09 13:48:59 +000081 '-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'
Emmanuele Bassi37eaaad2017-02-08 17:51:34 +0000100 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
Emmanuele Bassi1489c202018-02-24 14:01:46 +0000137common_cflags = cc.get_supported_arguments(test_cflags)
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +0000138
Emmanuele Bassi4719e582017-03-09 21:21:09 +0000139libtype = get_option('default_library')
140
141# Visibility compiler flags; we only use this for shared libraries
Dylan Bakerc02a02d2017-10-13 16:50:44 -0700142visibility_cflags = []
Emmanuele Bassi4719e582017-03-09 21:21:09 +0000143if libtype == 'shared'
Emmanuele Bassi7a068032017-01-24 17:43:59 +0000144 if host_system == 'windows'
145 conf.set('DLL_EXPORT', true)
Emmanuele Bassi898ba5d2017-06-06 10:50:14 +0100146 conf.set('EPOXY_PUBLIC', '__declspec(dllexport) extern')
147 if cc.get_id() != 'msvc'
Emmanuele Bassi7a068032017-01-24 17:43:59 +0000148 visibility_cflags += [ '-fvisibility=hidden' ]
149 endif
150 else
Emmanuele Bassi4719e582017-03-09 21:21:09 +0000151 conf.set('EPOXY_PUBLIC', '__attribute__((visibility("default"))) extern')
Emmanuele Bassi7a068032017-01-24 17:43:59 +0000152 visibility_cflags += [ '-fvisibility=hidden' ]
153 endif
154endif
155
Andrei Fadeevc39f1612017-03-15 09:13:34 +0300156# 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
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +0000164# 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)
Emmanuele Bassif7d36712017-03-09 21:28:52 +0000171
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
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +0000184
Emmanuele Bassiba2e7b12017-01-19 18:41:40 +0000185# On windows, the DLL has to have all of its functions
luz.pazd60b9232018-03-05 06:08:53 -0500186# resolved at link time, so we have to link directly against
Emmanuele Bassiba2e7b12017-01-19 18:41:40 +0000187# 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
Emmanuele Bassi89f9aa02017-02-13 09:26:57 +0000199# Python
Emmanuele Bassi0dfe8402017-03-28 10:06:29 +0100200python = import('python3').find_python()
Emmanuele Bassi877fe812017-02-13 09:33:19 +0000201if not python.found()
202 python = find_program('python', required: true)
203endif
Emmanuele Bassi89f9aa02017-02-13 09:26:57 +0000204
Emmanuele Bassi59318ed2016-12-14 15:35:44 +0000205# Generates the dispatch tables
Emmanuele Bassi0dfe8402017-03-28 10:06:29 +0100206gen_dispatch_py = files('src/gen_dispatch.py')
Emmanuele Bassi59318ed2016-12-14 15:35:44 +0000207
Patrick Griffis61dac912017-01-27 19:13:48 -0500208gl_registry = files('registry/gl.xml')
209egl_registry = files('registry/egl.xml')
210glx_registry = files('registry/glx.xml')
211wgl_registry = files('registry/wgl.xml')
Emmanuele Bassi59318ed2016-12-14 15:35:44 +0000212
213libepoxy_inc = [
214 include_directories('include'),
215 include_directories('src'),
216]
217
218subdir('include/epoxy')
Emmanuele Bassi08cc4d02016-12-09 12:28:42 +0000219subdir('src')
Ross Burtona35192b2018-03-01 17:37:42 +0000220
221if get_option('tests')
222 subdir('test')
223endif
Emmanuele Bassi59d9c2d2017-01-25 16:38:02 +0000224
Emmanuele Bassia7c31782018-02-23 15:51:56 +0000225if get_option('docs')
Emmanuele Bassi59d9c2d2017-01-25 16:38:02 +0000226 doxygen = find_program('doxygen', required: false)
227 if doxygen.found()
228 subdir('doc')
229 else
230 message('Documentation disabled without doxygen')
231 endif
232endif