summaryrefslogtreecommitdiff
path: root/src/meson.build
blob: 881e087faec3e77bc99b211dfe04d662f8a840d7 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# 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: [
                              gen_dispatch_py,
                              '--source',
                              '--no-header',
                              '--outputdir=@OUTDIR@',
                              '@INPUT@',
                            ])

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

epoxy_sources = sources + gen_sources

common_ldflags = []

if host_system == 'linux' and cc.get_id() == 'gcc'
  common_ldflags += cc.get_supported_link_arguments([ '-Wl,-Bsymbolic-functions', '-Wl,-z,relro' ])
endif

# Maintain compatibility with autotools; see: https://github.com/anholt/libepoxy/issues/108
darwin_versions = [1, '1.0']

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

libepoxy = library(
  'epoxy',
  sources: epoxy_sources + epoxy_headers,
  version: '0.0.0',
  darwin_versions: darwin_versions,
  install: true,
  dependencies: epoxy_deps,
  include_directories: libepoxy_inc,
  c_args: common_cflags + visibility_cflags,
  link_args: common_ldflags,
)

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

epoxy_has_glx = build_glx ? '1' : '0'
epoxy_has_egl = build_egl ? '1' : '0'
epoxy_has_wgl = build_wgl ? '1' : '0'

# We don't want to add these dependencies to the library, as they are
# not needed when building Epoxy; we do want to add them to the generated
# pkg-config file, for consumers of Epoxy
gl_reqs = []
if gl_dep.found() and gl_dep.type_name() == 'pkgconfig'
  gl_reqs += 'gl'
endif
if build_egl and egl_dep.found() and egl_dep.type_name() == 'pkgconfig'
  gl_reqs += 'egl'
endif

pkg = import('pkgconfig')
pkg.generate(
  libraries: libepoxy,
  name: 'epoxy',
  description: 'GL dispatch library',
  version: meson.project_version(),
  variables: [
    'epoxy_has_glx=@0@'.format(epoxy_has_glx),
    'epoxy_has_egl=@0@'.format(epoxy_has_egl),
    'epoxy_has_wgl=@0@'.format(epoxy_has_wgl),
  ],
  filebase: 'epoxy',
  requires_private: ' '.join(gl_reqs),
)