-
Notifications
You must be signed in to change notification settings - Fork 25
/
meson.build
163 lines (153 loc) · 4.65 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# If we want to build static program with wrap on Windows,
# We need to set `default_library=static` here
# instead of setting it for each dependencies.
# Because though FlipClock does not link against freetype2 directly,
# sdl2_ttf needs to link against freetype2,
# and if we only pass `default_library=static` to sdl2_ttf,
# it still links against freetype2 dynamically.
project(
'flipclock',
'c',
version: '2.10.0',
license: 'Apache-2.0',
default_options: ['c_std=c11', 'default_library=static']
)
cc = meson.get_compiler('c')
c_args = []
if get_option('debug') == true
warning_level = 3
c_args += ['-D__DEBUG__']
endif
conf_data = configuration_data()
conf_data.set('project_version', meson.project_version())
conf_data.set('package_bindir', get_option('prefix') / get_option('bindir'))
conf_data.set('package_datadir', get_option('prefix') / get_option('datadir'))
# `sysconfdir` is `/etc` if `prefix` is `/usr`,
# but it will be relative path if using other prefix.
# See <https://mesonbuild.com/Builtin-options.html#universal-options>.
# Meson's string path building operator will not join two absolute path,
# it will keep the right one, so it's OK to handle `sysconfdir` with it.
# See <https://mesonbuild.com/Syntax.html#string-path-building>.
conf_data.set('package_sysconfdir', get_option('prefix') / get_option('sysconfdir'))
configure_file(
input: 'srcs/config.h.in',
output: 'config.h',
configuration: conf_data
)
# Don't install desktop entry for Windows.
if host_machine.system() == 'linux'
configure_file(
input: 'dists/one.alynx.FlipClock.desktop.in',
output: 'one.alynx.FlipClock.desktop',
configuration: conf_data,
install: true,
# If a relative path is given, meson will put it under prefix
# so we don't need to put `get_option('prefix')` manually here.
install_dir: get_option('datadir') / 'applications'
)
endif
sources = files(
'srcs/main.c',
'srcs/getarg.c',
'srcs/card.c',
'srcs/clock.c',
'srcs/flipclock.c'
)
dependencies = []
include_directories = []
# Windows does not have sperated libm.
if host_machine.system() == 'linux'
m = cc.find_library('m', required: true)
dependencies += [m]
endif
# Wrap files will be used as fallback.
sdl2 = dependency('sdl2', required: true)
sdl2_ttf = dependency('SDL2_ttf', required: true)
dependencies += [sdl2, sdl2_ttf]
if host_machine.system() == 'linux' or host_machine.system() == 'darwin'
executable(
'flipclock',
sources: sources,
c_args: c_args,
dependencies: dependencies,
include_directories: include_directories,
install: true
# By default, meson install binary to
# `get_option('prefix') / get_option('bindir')`,
# so we can omit `install_dir` here.
)
install_data(
'dists' / 'flipclock.conf',
install_dir: get_option('sysconfdir')
)
install_data(
'dists' / 'flipclock.ttf',
install_dir: get_option('datadir') / 'fonts'
)
install_data(
'dists' / 'icons' / '128x128' / 'one.alynx.FlipClock.png',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / '128x128' / 'apps'
)
install_data(
'dists' / 'icons' / '64x64' / 'one.alynx.FlipClock.png',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / '64x64' / 'apps'
)
install_data(
'dists' / 'icons' / 'scalable' / 'one.alynx.FlipClock.svg',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps'
)
install_data(
'dists' / 'one.alynx.FlipClock.metainfo.xml',
install_dir: get_option('datadir') / 'metainfo'
)
install_data(
'LICENSE',
install_dir: get_option('datadir') / 'licenses' / meson.project_name()
)
elif host_machine.system() == 'windows'
if get_option('debug') == true
executable(
'flipclock',
sources: sources,
c_args: c_args,
dependencies: dependencies,
include_directories: include_directories,
install: true,
install_dir: meson.project_name(),
name_suffix: 'scr',
win_subsystem: 'console'
)
else
executable(
'flipclock',
sources: sources,
c_args: c_args,
dependencies: dependencies,
include_directories: include_directories,
install: true,
install_dir: meson.project_name(),
name_suffix: 'scr',
win_subsystem: 'windows'
)
endif
install_data(
'dists' / 'flipclock.conf',
install_dir: meson.project_name()
)
install_data(
'dists' / 'flipclock.ttf',
install_dir: meson.project_name()
)
install_data(
'LICENSE',
install_dir: meson.project_name()
)
install_data(
'dists' / 'COPYING',
install_dir: meson.project_name()
)
install_data(
'dists' / '请先读我.txt',
install_dir: meson.project_name()
)
endif