summaryrefslogtreecommitdiff
path: root/src/meson.build
blob: 3610af37ca33925a629a5f600086ecda8ac4be65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Configuration file
configure_file(output: 'config.h', configuration: conf)

# List of generated sources:
#   - name of the generated file
#   - registry source file
#   - additional sources
generated_sources = [
  [ 'gl_generated_dispatch.c', gl_registry, [ 'dispatch_common.c', 'dispatch_common.h' ] ]
]

if build_egl
  generated_sources += [ [ 'egl_generated_dispatch.c', egl_registry, 'dispatch_egl.c' ] ]
endif

if build_glx
  generated_sources += [ [ 'glx_generated_dispatch.c', glx_registry, 'dispatch_glx.c' ] ]
endif

if build_wgl
  generated_sources += [ [ 'wgl_generated_dispatch.c', wgl_registry, 'dispatch_wgl.c' ] ]
endif

gen_sources = [ ]
sources = [ ]

foreach g: generated_sources
  gen_source = g[0]
  registry = g[1]
  source = g[2]

  generated = custom_target(gen_source,
                            input: registry,
                            output: [ gen_source ],
                            command: [
                              python,
                              gen_dispatch_py,
                              '--source',
                              '--no-header',
                              '--outputdir=@OUTDIR@',
                              '@INPUT@',
                            ])

  gen_sources += [ generated ]
  sources += [ source ]
endforeach

epoxy_sources = sources + gen_sources
epoxy_headers = gen_headers
foreach h: headers
  epoxy_headers += join_paths(meson.source_root(), 'include/epoxy/@0@'.format(h))
endforeach

if cc.get_id() == 'gcc'
  common_ldflags = [ '-Wl,-Bsymbolic', ]
else
  common_ldflags = []
endif

epoxy_deps = [ dl_dep, ]
if host_system == 'windows'
  epoxy_deps += [ opengl32_dep, gdi32_dep ]
endif

# Allow building a static version of epoxy
libtype = get_option('default_library')

if libtype != 'shared'
  libepoxy_static = static_library('epoxy',
                                   sources: epoxy_sources + epoxy_headers,
                                   install: true,
                                   dependencies: epoxy_deps,
                                   include_directories: libepoxy_inc,
                                   c_args: common_cflags + visibility_cflags,
                                   link_args: common_ldflags)
  libepoxy = libepoxy_static
endif

if libtype != 'static'
  libepoxy_shared = shared_library('epoxy',
                                   sources: epoxy_sources + epoxy_headers,
                                   version: '0.0.0',
                                   install: true,
                                   dependencies: epoxy_deps,
                                   include_directories: libepoxy_inc,
                                   c_args: common_cflags,
                                   link_args: common_ldflags)
  libepoxy = libepoxy_shared
endif

libepoxy_dep = declare_dependency(link_with: libepoxy,
                                  include_directories: libepoxy_inc,
                                  dependencies: epoxy_deps,
                                  sources: epoxy_headers)