forked from capstone-engine/capstone
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmeson.build
150 lines (139 loc) · 4.53 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
project('capstone', 'c',
version: '5.0.1',
default_options: [
'c_std=c99',
],
)
available_archs = {
'arm': ['ARM', ['ARMDisassembler.c', 'ARMInstPrinter.c', 'ARMMapping.c', 'ARMModule.c']],
'arm64': ['AArch64', ['AArch64BaseInfo.c', 'AArch64Disassembler.c', 'AArch64InstPrinter.c', 'AArch64Mapping.c', 'AArch64Module.c']],
'bpf': ['BPF', ['BPFDisassembler.c', 'BPFInstPrinter.c', 'BPFMapping.c', 'BPFModule.c']],
'evm': ['EVM', ['EVMDisassembler.c', 'EVMInstPrinter.c', 'EVMMapping.c', 'EVMModule.c']],
'm680x': ['M680X', ['M680XDisassembler.c', 'M680XInstPrinter.c', 'M680XModule.c']],
'm68k': ['M68K', ['M68KDisassembler.c', 'M68KInstPrinter.c', 'M68KModule.c']],
'mips': ['Mips', ['MipsDisassembler.c', 'MipsInstPrinter.c', 'MipsMapping.c', 'MipsModule.c']],
'mos65xx': ['MOS65XX', ['MOS65XXDisassembler.c', 'MOS65XXModule.c']],
'powerpc': ['PowerPC', ['PPCDisassembler.c', 'PPCInstPrinter.c', 'PPCMapping.c', 'PPCModule.c']],
'riscv': ['RISCV', ['RISCVDisassembler.c', 'RISCVInstPrinter.c', 'RISCVMapping.c', 'RISCVModule.c']],
'sh': ['SH', ['SHDisassembler.c', 'SHInstPrinter.c', 'SHModule.c']],
'sparc': ['Sparc', ['SparcDisassembler.c', 'SparcInstPrinter.c', 'SparcMapping.c', 'SparcModule.c']],
'sysz': ['SystemZ', ['SystemZDisassembler.c', 'SystemZInstPrinter.c', 'SystemZMCTargetDesc.c', 'SystemZMapping.c', 'SystemZModule.c']],
'tms320c64x': ['TMS320C64x', ['TMS320C64xDisassembler.c', 'TMS320C64xInstPrinter.c', 'TMS320C64xMapping.c', 'TMS320C64xModule.c']],
'tricore': ['TriCore', ['TriCoreDisassembler.c', 'TriCoreInstPrinter.c', 'TriCoreMapping.c', 'TriCoreModule.c']],
'wasm': ['WASM', ['WASMDisassembler.c', 'WASMInstPrinter.c', 'WASMMapping.c', 'WASMModule.c']],
'x86': ['X86', ['X86ATTInstPrinter.c', 'X86Disassembler.c', 'X86DisassemblerDecoder.c', 'X86InstPrinterCommon.c', 'X86IntelInstPrinter.c', 'X86Mapping.c', 'X86Module.c']],
'xcore': ['XCore', ['XCoreDisassembler.c', 'XCoreInstPrinter.c', 'XCoreMapping.c', 'XCoreModule.c']],
}
desired_archs = get_option('archs')
if desired_archs.length() == 0 or 'all' in desired_archs
desired_archs = available_archs.keys()
endif
headers = []
header_names = [
'arm.h',
'arm64.h',
'bpf.h',
'capstone.h',
'evm.h',
'm680x.h',
'm68k.h',
'mips.h',
'mos65xx.h',
'platform.h',
'ppc.h',
'riscv.h',
'sh.h',
'sparc.h',
'systemz.h',
'tms320c64x.h',
'tricore.h',
'wasm.h',
'x86.h',
'xcore.h',
]
foreach name : header_names
headers += 'include' / 'capstone' / name
endforeach
sources = [
'cs.c',
'Mapping.c',
'MCInst.c',
'MCInstrDesc.c',
'MCRegisterInfo.c',
'SStream.c',
'utils.c',
]
foreach arch_id : desired_archs
spec = available_archs[arch_id]
arch_name = spec[0]
arch_sources = spec[1]
foreach source : arch_sources
sources += 'arch' / arch_name / source
endforeach
endforeach
defines = []
deps = []
profile = get_option('profile')
if profile != 'full'
defines += '-DCAPSTONE_DIET'
endif
if profile == 'tiny'
defines += '-DCAPSTONE_TINY'
if 'x86' in desired_archs
fadec_options = [
'archmode=' + ((host_machine.cpu_family() == 'x86_64') ? 'only64' : 'only32'),
'with_encode=false',
'tests=false',
]
deps += dependency('fadec', default_options: fadec_options)
endif
endif
foreach arch_id : desired_archs
defines += '-DCAPSTONE_HAS_' + arch_id.to_upper()
endforeach
available_flags = [
'use_arch_registration',
'use_sys_dyn_mem',
'x86_reduce',
'x86_att_disable',
'has_osxkernel',
]
foreach flag : available_flags
if get_option(flag)
defines += '-DCAPSTONE_' + flag.to_upper()
endif
endforeach
ndebug = get_option('b_ndebug')
if ndebug == 'false' or (ndebug == 'if-release' and get_option('debug'))
defines += '-DCAPSTONE_DEBUG'
endif
install_headers(headers, subdir: 'capstone')
include_dirs = include_directories('include')
capstone = library('capstone', sources,
c_args: defines,
include_directories: include_dirs,
dependencies: deps,
install: true,
)
capstone_dep = declare_dependency(
link_with: capstone,
include_directories: include_directories('include' / 'capstone'),
variables: {'includedir': meson.current_source_dir() / 'include'},
)
pkg = import('pkgconfig')
pkg.generate(capstone,
name: 'capstone',
description: 'Capstone disassembly engine',
url: 'https://www.capstone-engine.org',
subdirs: ['capstone'],
)
meson.override_dependency('capstone', capstone_dep)
cli_option = get_option('cli')
if cli_option.auto()
cli_enabled = profile == 'full' and not meson.is_subproject()
else
cli_enabled = cli_option.enabled()
endif
if cli_enabled
subdir('cstool')
endif