forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
311 lines (278 loc) · 9.43 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
project('radare2', 'c', meson_version: '>=0.46.0')
py3_exe = import('python3').find_python()
git_exe = find_program('git')
pkgconfig_mod = import('pkgconfig')
glob_cmd = [py3_exe, '-c', 'from sys import argv; print(";".join(__import__("glob").glob(argv[1])))']
# Get r2 version
r2_version = run_command(py3_exe, 'sys/version.py')
if r2_version.returncode() != 0
r2_version = 'unknown-error'
else
r2_version = r2_version.stdout().strip()
endif
repo = '.'
if meson.is_subproject()
repo = meson.current_source_dir()
if host_machine.system() == 'windows'
py_cmd = 'print(__import__("os").readlink(r"@0@"))'.format(repo)
py_cmd = run_command(py3_exe, '-c', py_cmd)
if py_cmd.returncode() == 0
repo = py_cmd.stdout().strip()
message('r2 real path: ' + repo)
endif
endif
endif
# Get version_commit
version_commit = run_command(git_exe, '-C', repo, 'rev-list', '--all', '--count')
if version_commit.returncode() != 0
version_commit = 0
else
version_commit = version_commit.stdout().strip()
endif
# Get gittap
gittap = run_command(git_exe, '-C', repo, 'describe', '--tags', '--match', '[0-9]*')
if gittap.returncode() != 0
gittap = ''
else
gittap = gittap.stdout().strip()
endif
# Get gittip
gittip = run_command(git_exe, '-C', repo, 'rev-parse', 'HEAD')
if gittip.returncode() != 0
gittip = 'unknown'
else
gittip = gittip.stdout().strip()
endif
# Get current date
if host_machine.system() == 'windows'
r2birth = run_command('cmd', '/c', 'echo %date%__%time%')
else
r2birth = run_command('date', '+%Y-%m-%d__%H:%M:%S')
endif
if r2birth.returncode() != 0
r2birth = ''
else
r2birth = r2birth.stdout().strip()
endif
r2_libversion = host_machine.system() == 'windows' ? '' : r2_version
# system dependencies
cc = meson.get_compiler('c')
# required for linux
ldl = cc.find_library('dl', required: false)
pth = cc.find_library('pthread', required: false)
utl = cc.find_library('util', required: false)
mth = cc.find_library('m', required: false)
platform_deps = []
platform_inc = ['.', 'libr/include']
if host_machine.system() == 'windows'
platform_deps = [cc.find_library('ws2_32')]
platform_inc += ['libr/include/msvc']
endif
platform_inc = include_directories(platform_inc)
if get_option('static_runtime')
if cc.get_id() == 'msvc'
add_project_arguments('/MT', language: 'c')
endif
endif
if host_machine.system() == 'windows'
r2_prefix = '.'
r2_libdir = 'lib'
r2_incdir = 'include'
r2_datdir = 'share'
opts1 = ['r2_libdir', 'r2_incdir', 'r2_datdir']
foreach opt : opts1
val = get_option(opt)
if val != ''
set_variable(opt, val)
endif
endforeach
r2_wwwroot = join_paths(r2_datdir, 'www')
r2_sdb = join_paths(r2_datdir)
r2_zigns = join_paths(r2_datdir, 'zigns')
r2_themes = join_paths(r2_datdir, 'cons')
r2_fortunes = join_paths(r2_datdir, 'doc')
r2_hud = join_paths(r2_datdir, 'hud')
opts2 = ['r2_wwwroot', 'r2_sdb', 'r2_zigns', 'r2_themes', 'r2_fortunes', 'r2_hud']
foreach opt : opts2
val = get_option(opt)
if val != ''
set_variable(opt, val)
endif
endforeach
opts3 = ['r2_plugins', 'r2_extras', 'r2_bindings']
r2_plugins = join_paths(r2_libdir, 'plugins')
r2_extras = join_paths(r2_libdir, 'extras')
r2_bindings = join_paths(r2_libdir, 'bindings')
foreach opt : opts1 + opts2 + opts3
val = get_variable(opt)
val = '\\\\'.join(val.split('/'))
set_variable(opt, val)
endforeach
else
r2_prefix = get_option('prefix')
r2_libdir = join_paths(r2_prefix, get_option('libdir'))
r2_incdir = join_paths(r2_prefix, get_option('includedir'), 'libr')
r2_datdir = join_paths(r2_prefix, get_option('datadir'))
r2_wwwroot = join_paths(r2_datdir, 'radare2', r2_version, 'www')
r2_sdb = join_paths(get_option('datadir'), 'radare2', r2_version)
r2_zigns = join_paths(get_option('datadir'), 'radare2', r2_version, 'zigns')
r2_themes = join_paths(get_option('datadir'), 'radare2', r2_version, 'cons')
r2_fortunes = join_paths(get_option('datadir'), 'doc/radare2')
r2_hud = join_paths(get_option('datadir'), 'radare2', r2_version, 'hud')
r2_plugins = join_paths(get_option('libdir'), 'radare2', r2_version)
r2_extras = join_paths(get_option('libdir'), 'radare2-extras', r2_version)
r2_bindings = join_paths(get_option('libdir'), 'radare2-bindings', r2_version)
endif
# load plugin configuration
subdir('libr')
conf_data = configuration_data()
conf_data.set('plugins_core', '&r_core_plugin_' + ',&r_core_plugin_'.join(core) + ', 0')
conf_data.set('plugins_anal', '&r_anal_plugin_' + ',&r_anal_plugin_'.join(anal) + ', 0')
conf_data.set('plugins_asm', '&r_asm_plugin_' + ',&r_asm_plugin_'.join(asm) + ', 0')
conf_data.set('plugins_bp', '&r_bp_plugin_' + ',&r_bp_plugin_'.join(bp) + ', 0')
conf_data.set('plugins_bin', '&r_bin_plugin_' + ',&r_bin_plugin_'.join(bin) + ', 0')
conf_data.set('plugins_crypto', '&r_crypto_plugin_' + ',&r_crypto_plugin_'.join(crypto) + ', 0')
conf_data.set('plugins_io', '&r_io_plugin_' + ',&r_io_plugin_'.join(io) + ', 0')
conf_data.set('plugins_fs', '&r_fs_plugin_' + ',&r_fs_plugin_'.join(fs) + ', 0')
conf_data.set('plugins_debug', '&r_debug_plugin_' + ',&r_debug_plugin_'.join(debug) + ', 0')
conf_data.set('plugins_egg', '&r_egg_plugin_' + ',&r_egg_plugin_'.join(egg) + ', 0')
conf_data.set('plugins_lang', '&r_lang_plugin_' + ',&r_lang_plugin_'.join(lang) + ', 0')
conf_data.set('plugins_parse', '&r_parse_plugin_' + ',&r_parse_plugin_'.join(parse) + ', 0')
config_h = configure_file(
input: 'libr/config.h.in',
output: 'config.h',
configuration: conf_data
)
userconf = configuration_data()
userconf.set('DEBUGGER', 1)
userconf.set('PREFIX', r2_prefix)
userconf.set('LIBDIR', r2_libdir)
userconf.set('INCLUDEDIR', r2_incdir)
userconf.set('DATADIR', r2_datdir)
userconf.set('WWWROOT', r2_wwwroot)
userconf.set('SDB', r2_sdb)
userconf.set('ZIGNS', r2_zigns)
userconf.set('THEMES', r2_themes)
userconf.set('FORTUNES', r2_fortunes)
userconf.set('HUD', r2_hud)
userconf.set('PLUGINS', r2_plugins)
userconf.set('EXTRAS', r2_extras)
userconf.set('BINDINGS', r2_bindings)
userconf.set('HAVE_LIB_MAGIC', 0)
userconf.set('USE_LIB_MAGIC', 0)
userconf.set('HAVE_OPENSSL', 0)
userconf.set('HAVE_FORK', 1)
userconf.set('WITH_GPL', 1)
if host_machine.system() == 'windows'
userconf.set('HAVE_JEMALLOC', 0)
else
userconf.set('HAVE_JEMALLOC', 1)
endif
if cc.has_header_symbol('sys/personality.h', 'ADDR_NO_RANDOMIZE')
userconf.set('HAVE_DECL_ADDR_NO_RANDOMIZE', 1)
else
userconf.set('HAVE_DECL_ADDR_NO_RANDOMIZE', 0)
endif
r_userconf_h = configure_file(
input: 'libr/include/r_userconf.h.in',
output: 'r_userconf.h',
configuration: userconf,
install_dir: join_paths(get_option('includedir'), 'libr')
)
versionconf = configuration_data()
versionconf.set('VERSIONCOMMIT', version_commit)
versionconf.set('R2_VERSION', r2_version)
versionconf.set('R2_GITTAP', gittap)
versionconf.set('R2_GITTIP', gittip)
versionconf.set('R2_BIRTH', r2birth)
r_version_h = configure_file(
input: 'libr/include/r_version.h.in',
output: 'r_version.h',
configuration: versionconf,
install_dir: join_paths(get_option('includedir'), 'libr')
)
# Copy missing header
run_command(py3_exe, '-c', '__import__("shutil").copyfile("shlr/spp/config.def.h", "shlr/spp/config.h")')
pcconf = configuration_data()
pcconf.set('PREFIX', get_option('prefix'))
pcconf.set('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
pcconf.set('VERSION', r2_version)
libr_pc = configure_file(
input: 'libr/libr.pc.acr',
output: 'libr.pc',
configuration: userconf,
install_dir: join_paths(get_option('libdir'), 'pkgconfig')
)
subdir('shlr')
subdir('libr/util')
subdir('libr/hash')
subdir('libr/crypto')
subdir('libr/socket')
subdir('libr/io')
subdir('libr/bp')
subdir('libr/syscall')
subdir('libr/cons')
subdir('libr/search')
subdir('libr/magic')
subdir('libr/flag')
subdir('libr/reg')
subdir('libr/bin')
subdir('libr/config')
subdir('libr/parse')
subdir('libr/lang')
subdir('libr/asm')
subdir('libr/anal')
subdir('libr/egg')
subdir('libr/fs')
subdir('libr/debug')
subdir('libr/core')
subdir('shlr/sdb')
subdir('libr/anal/d')
subdir('libr/asm/d')
subdir('libr/bin/d')
subdir('libr/syscall/d')
subdir('libr/cons/d')
subdir('libr/magic/d')
if not meson.is_subproject()
subdir('binr/rahash2')
subdir('binr/rarun2')
subdir('binr/rasm2')
subdir('binr/rabin2')
subdir('binr/radare2')
subdir('binr/ragg2')
subdir('binr/r2agent')
subdir('binr/radiff2')
subdir('binr/rafind2')
subdir('binr/rax2')
else
libr2_lib = [
r_anal, r_asm, r_bin, r_bp, r_config, r_cons, r_core, r_crypto, r_egg,
r_flag, r_fs, r_hash, r_io, r_lang, r_magic, r_parse, r_reg, r_search,
r_socket, r_syscall, r_util
]
libr2_inc = include_directories(['.', 'libr/include'])
libr2_dep = declare_dependency(
link_with: libr2_lib,
include_directories: libr2_inc,
version: r2_version
)
endif
install_subdir('shlr/www',
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2_version)
)
fortunes_files = run_command(glob_cmd + ['doc/fortunes.*']).stdout().strip().split(';')
install_data(fortunes_files,
install_dir: join_paths(get_option('datadir'), 'doc/radare2')
)
man1_files = run_command(glob_cmd + ['man/*.1']).stdout().strip().split(';')
install_data(man1_files,
install_dir: join_paths(get_option('mandir'), 'man1')
)
man7_files = run_command(glob_cmd + ['man/*.7']).stdout().strip().split(';')
install_data(man7_files,
install_dir: join_paths(get_option('mandir'), 'man7')
)
install_data('doc/hud',
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'hud'),
rename: 'main'
)