-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmeson.build
103 lines (85 loc) · 2.09 KB
/
meson.build
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
project(
'aml',
'c',
version: '0.3.0',
license: 'ISC',
default_options: [
'c_std=c11',
'warning_level=2',
]
)
buildtype = get_option('buildtype')
default_library = get_option('default_library')
is_static_subproject = meson.is_subproject() and default_library == 'static'
c_args = [
'-DPROJECT_VERSION="@0@"'.format(meson.project_version()),
'-D_POSIX_C_SOURCE=200809L',
'-fvisibility=hidden',
'-DAML_UNSTABLE_API=1',
'-Wmissing-prototypes',
'-Wno-unused-parameter',
]
git = find_program('git', native: true, required: false)
if git.found()
git_describe = run_command([git, 'describe', '--tags', '--long'])
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'])
if git_describe.returncode() == 0 and git_branch.returncode() == 0
c_args += '-DGIT_VERSION="@0@ (@1@)"'.format(
git_describe.stdout().strip(),
git_branch.stdout().strip(),
)
endif
endif
if buildtype != 'debug' and buildtype != 'debugoptimized'
c_args += '-DNDEBUG'
endif
add_project_arguments(c_args, language: 'c')
cc = meson.get_compiler('c')
librt = cc.find_library('rt', required: false)
threads = dependency('threads')
inc = include_directories('include')
sources = [
'src/aml.c',
'src/thread-pool.c',
]
have_epoll = cc.has_header_symbol('sys/epoll.h', 'epoll_create')
have_kqueue = cc.has_header_symbol('sys/event.h', 'kqueue')
if have_epoll
sources += 'src/epoll.c'
message('epoll backend chosen')
elif have_kqueue
sources += 'src/kqueue.c'
message('kqueue backend chosen')
else
error('Unsupported system')
endif
dependencies = [
librt,
threads,
]
aml = library(
'aml',
sources,
version: '0.0.0',
dependencies: dependencies,
include_directories: inc,
install: not is_static_subproject,
)
aml_dep = declare_dependency(
include_directories: inc,
link_with: aml,
)
if get_option('examples')
subdir('examples')
endif
if not is_static_subproject
install_headers('include/aml.h')
pkgconfig = import('pkgconfig')
pkgconfig.generate(
aml,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'Another main loop library',
)
endif