1project('radare2', 'c', license: 'LGPL3', meson_version: '>=0.50.1')
2
3py3_exe = import('python').find_installation('python3')
4git_exe = find_program('git', required: false)
5pkgconfig_mod = import('pkgconfig')
6
7# Get r2 version
8r2_version = 'unknown-error'
9r2_version_major = 0
10r2_version_minor = 0
11r2_version_patch = 0
12r2_version_number = 0
13r = run_command(py3_exe, 'sys/version.py', '--full-version')
14if r.returncode() == 0
15  vers = r.stdout().strip().split('\n')
16  r2_version = vers[0]
17  r2_version_major = vers[1]
18  r2_version_minor = vers[2]
19  r2_version_patch = vers[3]
20  r2_version_number = vers[4]
21  if host_machine.system() == 'darwin'
22    r2_version = r2_version.split('-')[0]
23  endif
24else
25  message('Cannot find project version with sys/version.py')
26endif
27
28repo = '.'
29if meson.is_subproject()
30  repo = meson.current_source_dir()
31  if host_machine.system() == 'windows'
32    py_cmd = 'print(__import__("os").readlink(r"@0@"))'.format(repo)
33    py_cmd = run_command(py3_exe, '-c', py_cmd)
34    if py_cmd.returncode() == 0
35      repo = py_cmd.stdout().strip()
36      message('r2 real path: ' + repo)
37    endif
38  endif
39endif
40
41# by default, not version commit is used
42version_commit = '0'
43
44gittap = ''
45gittip = 'unknown'
46
47if git_exe.found()
48  # Get version_commit
49  git_rev_list = run_command(git_exe, '-C', repo, 'rev-list', '--all', '--count')
50  if git_rev_list.returncode() == 0
51    version_commit = git_rev_list.stdout().strip()
52  endif
53
54  # Get gittap
55  git_describe = run_command(git_exe, '-C', repo, 'describe', '--tags', '--match', '[0-9]*')
56  if git_describe.returncode() == 0
57    gittap = git_describe.stdout().strip()
58  endif
59
60  # Get gittip
61  git_rev_parse = run_command(git_exe, '-C', repo, 'rev-parse', 'HEAD')
62  if git_rev_parse.returncode() == 0
63    gittip = git_rev_parse.stdout().strip()
64  endif
65endif
66
67if get_option('r2_version_commit') != ''
68  version_commit = get_option('r2_version_commit')
69endif
70
71if get_option('r2_gittap') != ''
72  gittap = get_option('r2_gittap')
73endif
74# gittap is used for the version of each r_ library
75# in case it has not been set (e.g. a release tarball) set it
76if gittap == ''
77  gittap = r2_version
78endif
79
80if get_option('r2_gittip') != ''
81  gittip = get_option('r2_gittip')
82endif
83
84# Get current date
85if host_machine.system() == 'windows'
86  r2birth = run_command('cmd', '/c', 'echo %date%__%time%')
87else
88  r2birth = run_command('date', '+%Y-%m-%d__%H:%M:%S')
89endif
90if r2birth.returncode() != 0
91  r2birth = ''
92else
93  r2birth = r2birth.stdout().strip()
94endif
95
96r2_libversion = host_machine.system() == 'windows' ? '' : r2_version
97message('r2 lib version: ' + r2_libversion)
98
99# system dependencies
100cc = meson.get_compiler('c')
101# required for linux
102ldl = cc.find_library('dl', required: false)
103pth = dependency('threads', required: false)
104utl = cc.find_library('util', required: false)
105if host_machine.system() == 'sunos'
106  # workaround for Solaris until https://github.com/mesonbuild/meson/issues/4328 is fixed
107  mth = declare_dependency(link_args: '-lm')
108else
109  mth = cc.find_library('m', required: false)
110endif
111
112platform_deps = []
113platform_inc = ['.', 'libr/include']
114if host_machine.system() == 'windows'
115  platform_deps = [cc.find_library('ws2_32'), cc.find_library('wininet'), cc.find_library('psapi')]
116endif
117platform_inc = include_directories(platform_inc)
118
119if get_option('static_runtime')
120  if cc.get_id() == 'msvc'
121    add_project_arguments('/MT', language: 'c')
122  endif
123endif
124
125if cc.get_id() == 'clang-cl'
126  add_project_arguments('-D__STDC__=1', language: 'c')
127  add_project_arguments('-D_CRT_DECLARE_NONSTDC_NAMES ', language: 'c')
128  add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
129  add_project_arguments('-D_CRT_NONSTDC_NO_DEPRECATE', language: 'c')
130endif
131
132if get_option('default_library') == 'shared'
133  if host_machine.system() != 'windows' or cc.get_id()!='msvc' and cc.get_id()!='clang-cl'
134    add_project_arguments('-fvisibility=hidden', language: 'c')
135  endif
136endif
137
138library_cflags = ['-DR2_PLUGIN_INCORE=1']
139
140if host_machine.system() == 'windows'
141  r2_prefix = '.'
142  r2_libdir = 'lib'
143  r2_incdir = join_paths('include', 'libr')
144  r2_datdir = 'share'
145
146  opts1 = [
147    'r2_libdir',
148    'r2_incdir',
149    'r2_datdir'
150  ]
151  foreach opt : opts1
152    val = get_option(opt)
153    if val != ''
154      set_variable(opt, val)
155    endif
156  endforeach
157
158  r2_wwwroot = join_paths(r2_datdir, 'www')
159  r2_sdb = join_paths(r2_datdir)
160  r2_zigns = join_paths(r2_datdir, 'zigns')
161  r2_themes = join_paths(r2_datdir, 'cons')
162  r2_fortunes = join_paths(r2_datdir, 'doc')
163  r2_flags = join_paths(r2_datdir, 'flag')
164  r2_hud = join_paths(r2_datdir, 'hud')
165
166  opts2 = [
167    'r2_wwwroot',
168    'r2_sdb',
169    'r2_zigns',
170    'r2_themes',
171    'r2_fortunes',
172    'r2_flags',
173    'r2_hud'
174  ]
175  foreach opt : opts2
176    val = get_option(opt)
177    if val != ''
178      set_variable(opt, val)
179    endif
180  endforeach
181
182  opts3 = [
183    'r2_plugins',
184    'r2_extras',
185    'r2_bindings'
186  ]
187  r2_plugins = join_paths(r2_libdir, 'plugins')
188  r2_extras = join_paths(r2_libdir, 'extras')
189  r2_bindings = join_paths(r2_libdir, 'bindings')
190
191  foreach opt : opts1 + opts2 + opts3
192    val = get_variable(opt)
193    val = '\\\\'.join(val.split('/'))
194    set_variable(opt, val)
195  endforeach
196else
197  r2_prefix = get_option('prefix')
198  r2_libdir = get_option('libdir')
199  r2_incdir = join_paths(get_option('includedir'), 'libr')
200  r2_datdir = get_option('datadir')
201  r2_datdir_r2 = join_paths(r2_datdir, 'radare2')
202  r2_wwwroot = join_paths(r2_datdir_r2, r2_version, 'www')
203  r2_sdb = join_paths(r2_datdir_r2, r2_version)
204  r2_zigns = join_paths(r2_datdir_r2, r2_version, 'zigns')
205  r2_themes = join_paths(r2_datdir_r2, r2_version, 'cons')
206  r2_fortunes = join_paths(r2_datdir, 'doc', 'radare2')
207  r2_flags = join_paths(r2_datdir_r2, r2_version, 'flag')
208  r2_hud = join_paths(r2_datdir_r2, r2_version, 'hud')
209  r2_plugins = join_paths(r2_libdir, 'radare2', r2_version)
210  r2_extras = join_paths(r2_libdir, 'radare2-extras', r2_version)
211  r2_bindings = join_paths(r2_libdir, 'radare2-bindings', r2_version)
212endif
213
214r2_zsh_compdir = join_paths(r2_datdir, 'zsh', 'site-functions')
215
216# load plugin configuration
217subdir('libr')
218
219conf_data = configuration_data()
220conf_data.set('plugins_core', '&r_core_plugin_' + ', &r_core_plugin_'.join(core_plugins) + ', 0')
221conf_data.set('plugins_esil', '&r_esil_plugin_' + ', &r_esil_plugin_'.join(esil_plugins) + ', 0')
222conf_data.set('plugins_anal', '&r_anal_plugin_' + ', &r_anal_plugin_'.join(anal_plugins) + ', 0')
223conf_data.set('plugins_asm', '&r_asm_plugin_' + ', &r_asm_plugin_'.join(asm_plugins) + ', 0')
224conf_data.set('plugins_bp', '&r_bp_plugin_' + ', &r_bp_plugin_'.join(bp_plugins) + ', 0')
225conf_data.set('plugins_bin', '&r_bin_plugin_' + ', &r_bin_plugin_'.join(bin_plugins) + ', 0')
226conf_data.set('plugins_bin_ldr', '&r_bin_ldr_plugin_' + ', &r_bin_ldr_plugin_'.join(bin_ldr_plugins) + ', 0')
227conf_data.set('plugins_bin_xtr', '&r_bin_xtr_plugin_' + ', &r_bin_xtr_plugin_'.join(bin_xtr_plugins) + ', 0')
228conf_data.set('plugins_crypto', '&r_crypto_plugin_' + ', &r_crypto_plugin_'.join(crypto_plugins) + ', 0')
229conf_data.set('plugins_io', '&r_io_plugin_' + ', &r_io_plugin_'.join(io_plugins) + ', 0')
230conf_data.set('plugins_fs', '&r_fs_plugin_' + ', &r_fs_plugin_'.join(fs_plugins) + ', 0')
231conf_data.set('plugins_debug', '&r_debug_plugin_' + ', &r_debug_plugin_'.join(debug_plugins) + ', 0')
232conf_data.set('plugins_egg', '&r_egg_plugin_' + ', &r_egg_plugin_'.join(egg_plugins) + ', 0')
233conf_data.set('plugins_lang', '&r_lang_plugin_' + ', &r_lang_plugin_'.join(lang_plugins) + ', 0')
234conf_data.set('plugins_parse', '&r_parse_plugin_' + ', &r_parse_plugin_'.join(parse_plugins) + ', 0')
235config_h = configure_file(
236  input: 'libr/config.h.in',
237  output: 'config.h',
238  configuration: conf_data
239)
240
241# handle magic library
242sys_magic = cc.find_library('magic', required: false)
243use_syslib_magic = false
244
245if sys_magic.found() and get_option('use_sys_magic')
246  use_syslib_magic = true
247endif
248
249# handle xxhash library
250sys_xxhash = dependency('xxhash', required: false)
251use_sys_xxhash = false
252if not sys_xxhash.found()
253  sys_xxhash = cc.find_library('xxhash', required: false)
254endif
255
256if sys_xxhash.found() and get_option('use_sys_xxhash')
257  message('Using system xxhash library')
258  use_sys_xxhash = true
259else
260  message('Using bundled xxhash library')
261endif
262
263# handle openssl library
264static_sys_openssl = get_option('static_sys_openssl')
265sys_openssl = dependency('openssl', required: false, static: static_sys_openssl)
266use_sys_openssl = false
267if sys_openssl.found() and get_option('use_sys_openssl')
268  message('Using system openssl library')
269  use_sys_openssl = true
270else
271  message('Using bundled openssl code')
272endif
273
274# handle libuv library
275if get_option('use_libuv')
276  libuv_dep = dependency('libuv', version: '>=1.0.0', required: false)
277  use_libuv = libuv_dep.found()
278  if not libuv_dep.found()
279    warning('use_libuv option was set to true, but libuv was not found.')
280  endif
281else
282  use_libuv = false
283endif
284
285if use_libuv
286  message('Using libuv')
287else
288  message('Not using libuv, thus using fallback server implementations')
289endif
290
291has_debugger = get_option('debugger')
292have_ptrace = not ['windows', 'cygwin', 'sunos'].contains(host_machine.system())
293use_ptrace_wrap = ['linux'].contains(host_machine.system())
294
295have_ptrace = have_ptrace and has_debugger
296use_ptrace_wrap = use_ptrace_wrap and has_debugger
297
298message('HAVE_PTRACE: @0@'.format(have_ptrace))
299message('USE_PTRACE_WRAP: @0@'.format(use_ptrace_wrap))
300
301checks_level = get_option('checks_level')
302if checks_level == 9999
303  if get_option('buildtype') == 'release'
304    checks_level = 1
305  else
306    checks_level = 2
307  endif
308endif
309
310message('R2_CHECKS_LEVEL: @0@'.format(checks_level))
311
312userconf = configuration_data()
313userconf.set('R_CHECKS_LEVEL', checks_level)
314userconf.set10('HAVE_LIB_MAGIC', sys_magic.found())
315userconf.set10('USE_LIB_MAGIC', use_syslib_magic)
316userconf.set10('HAVE_LIB_XXHASH', sys_xxhash.found())
317userconf.set10('USE_LIB_XXHASH', use_sys_xxhash)
318userconf.set10('DEBUGGER', has_debugger)
319userconf.set('PREFIX', r2_prefix)
320if host_machine.system() == 'windows'
321  userconf.set('LIBDIR', r2_libdir)
322  userconf.set('INCLUDEDIR', r2_incdir)
323  userconf.set('DATADIR_R2', r2_datdir)
324  userconf.set10('HAVE_JEMALLOC', false)
325else
326  userconf.set('LIBDIR', join_paths(r2_prefix, r2_libdir))
327  userconf.set('INCLUDEDIR', join_paths(r2_prefix, r2_incdir))
328  userconf.set('DATADIR_R2', r2_datdir_r2)
329  userconf.set10('HAVE_JEMALLOC', true)
330endif
331userconf.set('DATADIR', join_paths(r2_prefix, r2_datdir))
332userconf.set('WWWROOT', join_paths(r2_prefix, r2_wwwroot))
333userconf.set('SDB', r2_sdb)
334userconf.set('ZIGNS', r2_zigns)
335userconf.set('THEMES', r2_themes)
336userconf.set('FORTUNES', r2_fortunes)
337userconf.set('FLAGS', r2_flags)
338userconf.set('HUD', r2_hud)
339userconf.set('PLUGINS', r2_plugins)
340userconf.set('EXTRAS', r2_extras)
341userconf.set('BINDINGS', r2_bindings)
342userconf.set10('HAVE_OPENSSL', use_sys_openssl)
343userconf.set10('HAVE_LIBUV', use_libuv)
344userconf.set10('HAVE_FORK', true)
345userconf.set10('WANT_DYLINK', true)
346userconf.set10('HAVE_PTRACE', have_ptrace)
347userconf.set10('USE_PTRACE_WRAP', use_ptrace_wrap)
348userconf.set10('WITH_GPL', true)
349ok = cc.has_header_symbol('sys/personality.h', 'ADDR_NO_RANDOMIZE')
350userconf.set10('HAVE_DECL_ADDR_NO_RANDOMIZE', ok)
351
352lrt = []
353if not cc.has_function('clock_gettime', prefix: '#include <time.h>') and cc.has_header_symbol('features.h', '__GLIBC__')
354  lrt = cc.find_library('rt', required: true)
355endif
356
357foreach item : [
358    ['arc4random_uniform', '#include <stdlib.h>', []],
359    ['explicit_bzero', '#include <string.h>', []],
360    ['explicit_memset', '#include <string.h>', []],
361    ['clock_nanosleep', '#include <time.h>', []],
362    ['clock_gettime', '#include <time.h>', [lrt]],
363    ['sigaction', '#include <signal.h>', []]
364  ]
365  func = item[0]
366  ok = cc.has_function(func, prefix: item[1], dependencies: item[2])
367  userconf.set10('HAVE_@0@'.format(func.to_upper()), ok)
368endforeach
369
370r_userconf_h = configure_file(
371  input: 'libr/include/r_userconf.h.acr',
372  output: 'r_userconf.h',
373  configuration: userconf,
374  install_dir: join_paths(r2_incdir)
375)
376
377versionconf = configuration_data()
378versionconf.set('MESON_VERSION', meson.version())
379versionconf.set('VERSIONCOMMIT', version_commit)
380versionconf.set('R2_VERSION_MAJOR', r2_version_major)
381versionconf.set('R2_VERSION_MINOR', r2_version_minor)
382versionconf.set('R2_VERSION_PATCH', r2_version_patch)
383versionconf.set('R2_VERSION_NUMBER', r2_version_number)
384versionconf.set('R2_VERSION', r2_version)
385versionconf.set('R2_GITTAP', gittap)
386versionconf.set('R2_GITTIP', gittip)
387versionconf.set('R2_BIRTH', r2birth)
388r_version_h = configure_file(
389  input: 'libr/include/r_version.h.in',
390  output: 'r_version.h',
391  configuration: versionconf,
392  install_dir: join_paths(r2_incdir)
393)
394
395# Copy missing header
396run_command(py3_exe, '-c', '__import__("shutil").copyfile("shlr/spp/config.def.h", "shlr/spp/config.h")')
397
398pcconf = configuration_data()
399pcconf.set('PREFIX', get_option('prefix'))
400pcconf.set('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
401pcconf.set('VERSION', r2_version)
402libr_pc = configure_file(
403  input: 'libr/libr.pc.acr',
404  output: 'libr.pc',
405  configuration: pcconf,
406  install_dir: join_paths(get_option('libdir'), 'pkgconfig')
407)
408
409# handle zlib dependency
410zlib_dep = dependency('zlib', required: false)
411if not zlib_dep.found() or not get_option('use_sys_zlib')
412  message('Use bundled zlib')
413
414  zlib_files = [
415    'shlr/zip/zlib/adler32.c',
416    'shlr/zip/zlib/compress.c',
417    'shlr/zip/zlib/crc32.c',
418    'shlr/zip/zlib/deflate.c',
419    'shlr/zip/zlib/gzclose.c',
420    'shlr/zip/zlib/gzlib.c',
421    'shlr/zip/zlib/gzread.c',
422    'shlr/zip/zlib/gzwrite.c',
423    'shlr/zip/zlib/infback.c',
424    'shlr/zip/zlib/inffast.c',
425    'shlr/zip/zlib/inflate.c',
426    'shlr/zip/zlib/inftrees.c',
427    'shlr/zip/zlib/trees.c',
428    'shlr/zip/zlib/uncompr.c',
429    'shlr/zip/zlib/zutil.c'
430  ]
431
432  zlib_inc = [platform_inc, include_directories('shlr/zip/zlib')]
433
434  libr2zlib = static_library('r2zlib', zlib_files,
435    include_directories: zlib_inc,
436    implicit_include_directories: false
437  )
438
439  zlib_dep = declare_dependency(
440    link_with: libr2zlib,
441    include_directories: zlib_inc
442  )
443else
444  message('Use system-provided zlib library')
445endif
446
447
448# handle sdb dependency
449# NOTE: copying most of the stuff from sdb to here for the moment, since we
450# should use subpackages to handle this well
451sdb_files = [
452  'shlr/sdb/src/array.c',
453  'shlr/sdb/src/base64.c',
454  'shlr/sdb/src/buffer.c',
455  'shlr/sdb/src/set.c',
456  'shlr/sdb/src/cdb.c',
457  'shlr/sdb/src/cdb_make.c',
458  'shlr/sdb/src/dict.c',
459  'shlr/sdb/src/diff.c',
460  'shlr/sdb/src/disk.c',
461  'shlr/sdb/src/fmt.c',
462  'shlr/sdb/src/ht_uu.c',
463  'shlr/sdb/src/ht_up.c',
464  'shlr/sdb/src/ht_pp.c',
465  'shlr/sdb/src/ht_pu.c',
466  'shlr/sdb/src/journal.c',
467  'shlr/sdb/src/json.c',
468  'shlr/sdb/src/lock.c',
469  'shlr/sdb/src/ls.c',
470  'shlr/sdb/src/match.c',
471  'shlr/sdb/src/ns.c',
472  'shlr/sdb/src/num.c',
473  'shlr/sdb/src/query.c',
474  'shlr/sdb/src/sdb.c',
475  'shlr/sdb/src/sdbht.c',
476  'shlr/sdb/src/util.c',
477  'shlr/sdb/src/text.c'
478]
479
480sdb_inc = [platform_inc, include_directories('shlr/sdb/src')]
481
482# Create sdb_version.h
483r = run_command(py3_exe, 'sys/sdb_version.py', 'shlr/sdb/config.mk')
484if r.returncode() == 0
485  sdb_version = r.stdout().strip().split('\n')[0]
486else
487  sdb_version = 'unknown'
488endif
489run_command(py3_exe, '-c', 'with open("shlr/sdb/src/sdb_version.h", "w") as f: f.write("#define SDB_VERSION \"' + sdb_version + '\"")')
490
491sdb_inc_files = [
492  'shlr/sdb/src/buffer.h',
493  'shlr/sdb/src/cdb.h',
494  'shlr/sdb/src/set.h',
495  'shlr/sdb/src/cdb_make.h',
496  'shlr/sdb/src/config.h',
497  'shlr/sdb/src/dict.h',
498  'shlr/sdb/src/ht_inc.h',
499  'shlr/sdb/src/ht_pp.h',
500  'shlr/sdb/src/ht_up.h',
501  'shlr/sdb/src/ht_uu.h',
502  'shlr/sdb/src/ht_pu.h',
503  'shlr/sdb/src/ls.h',
504  'shlr/sdb/src/sdb.h',
505  'shlr/sdb/src/sdbht.h',
506  'shlr/sdb/src/sdb_version.h',
507  'shlr/sdb/src/types.h'
508]
509install_headers(sdb_inc_files, install_dir: join_paths(r2_incdir, 'sdb'))
510
511libr2sdb = static_library('r2sdb', sdb_files,
512  include_directories: sdb_inc,
513  implicit_include_directories: false,
514  c_args: host_machine.system() == 'windows' ? '-DSDB_IPI= -DSDB_API=__declspec(dllexport)' : [],
515)
516
517sdb_dep = declare_dependency(
518  link_whole: libr2sdb,
519  include_directories: sdb_inc
520)
521
522sdb_exe = executable('sdb', ['shlr/sdb/src/main.c'] + sdb_files,
523  include_directories: [
524    include_directories(['shlr/sdb/src'])
525  ],
526  implicit_include_directories: false,
527  native: true,
528)
529
530sdb_gen_cmd = [
531  sdb_exe,
532  '@OUTPUT@',
533  '==',
534  '@INPUT@'
535]
536
537# handle spp dependency
538spp_files = [
539  'shlr/spp/spp.c'
540]
541
542spp_inc = [platform_inc, include_directories('shlr/spp')]
543
544libr2spp = static_library('r2spp', spp_files,
545  dependencies: sdb_dep,
546  include_directories: spp_inc,
547  c_args: ['-DHAVE_R_UTIL', '-DUSE_R2=1'],
548  implicit_include_directories: false
549)
550
551spp_dep = declare_dependency(
552  link_with: libr2spp,
553  include_directories: spp_inc
554)
555
556pkgcfg_sanitize_libs = ''
557if get_option('b_sanitize').contains('address')
558  pkgcfg_sanitize_libs += ' -lasan'
559endif
560if get_option('b_sanitize').contains('undefined')
561  pkgcfg_sanitize_libs += ' -lubsan'
562endif
563
564rpath_exe = ''
565rpath_lib = ''
566if get_option('local') and get_option('default_library') == 'shared'
567  rpath_exe = '$ORIGIN/../' + get_option('libdir')
568  rpath_lib = '$ORIGIN'
569endif
570
571subdir('libr/util')
572subdir('libr/socket')
573subdir('libr/hash')
574subdir('libr/crypto')
575subdir('shlr')
576
577subdir('libr/cons')
578subdir('shlr/gdb')
579subdir('libr/io')
580subdir('libr/bp')
581subdir('libr/syscall')
582subdir('libr/search')
583subdir('libr/magic')
584subdir('libr/flag')
585subdir('libr/reg')
586subdir('libr/bin')
587subdir('libr/config')
588subdir('libr/parse')
589subdir('libr/lang')
590subdir('libr/asm')
591subdir('libr/anal')
592subdir('libr/egg')
593subdir('libr/fs')
594subdir('libr/debug')
595subdir('libr/core')
596
597subdir('libr/anal/d')
598subdir('libr/asm/d')
599subdir('libr/bin/d')
600subdir('libr/syscall/d')
601subdir('libr/cons/d')
602subdir('libr/magic/d')
603subdir('libr/flag/d')
604subdir('libr/main')
605
606cli_option = get_option('cli')
607if cli_option.auto()
608  cli_enabled = not meson.is_subproject()
609else
610  cli_enabled = cli_option.enabled()
611endif
612if cli_enabled
613  if get_option('blob')
614    subdir('binr/blob')
615  else
616    subdir('binr/rahash2')
617    subdir('binr/rarun2')
618    subdir('binr/rasm2')
619    subdir('binr/rabin2')
620    subdir('binr/radare2')
621    subdir('binr/ragg2')
622    subdir('binr/r2agent')
623    subdir('binr/radiff2')
624    subdir('binr/rafind2')
625    subdir('binr/rasign2')
626    subdir('binr/rax2')
627  endif
628  subdir('binr/r2pm')
629  subdir('binr/r2r')
630endif
631
632if meson.is_subproject()
633  libr2_dep = declare_dependency(
634    dependencies: [
635      r_anal_dep,
636      r_asm_dep,
637      r_bin_dep,
638      r_bp_dep,
639      r_config_dep,
640      r_cons_dep,
641      r_core_dep,
642      r_main_dep,
643      r_crypto_dep,
644      r_debug_dep,
645      r_egg_dep,
646      r_flag_dep,
647      r_fs_dep,
648      r_hash_dep,
649      r_io_dep,
650      r_lang_dep,
651      r_magic_dep,
652      r_parse_dep,
653      r_reg_dep,
654      r_search_dep,
655      r_socket_dep,
656      r_syscall_dep,
657      r_util_dep
658    ],
659    include_directories: include_directories('.', 'libr/include'),
660    version: r2_version
661  )
662endif
663
664if get_option('use_webui')
665  install_subdir('shlr/www',
666    install_dir: r2_wwwroot,
667    strip_directory: true
668  )
669endif
670
671subdir('test/unit')
672
673install_data(
674  'doc/fortunes.fun',
675  'doc/fortunes.tips',
676  install_dir: r2_fortunes
677)
678
679if cli_enabled
680  install_man(
681    'man/r2agent.1',
682    'man/r2-docker.1',
683    'man/r2pm.1',
684    'man/rabin2.1',
685    'man/radare2.1',
686    'man/radiff2.1',
687    'man/rafind2.1',
688    'man/ragg2.1',
689    'man/rahash2.1',
690    'man/rarun2.1',
691    'man/rasm2.1',
692    'man/rax2.1',
693    'man/esil.7'
694  )
695
696  install_data('doc/hud',
697    install_dir: r2_hud,
698    rename: 'main'
699  )
700
701  install_data(
702    'doc/zsh/_r2',
703    'doc/zsh/_rabin2',
704    'doc/zsh/_radiff2',
705    'doc/zsh/_rafind2',
706    'doc/zsh/_ragg2',
707    'doc/zsh/_rahash2',
708    'doc/zsh/_rasm2',
709    'doc/zsh/_rax2',
710    install_dir: r2_zsh_compdir
711  )
712
713  meson.add_install_script(host_machine.system() == 'windows' ? 'sys/create_r2.bat' : 'sys/create_r2.sh')
714endif
715