-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeson.build
195 lines (163 loc) · 4.63 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
project(
'tcc',
'c',
version: '0.9.28vs-rc',
meson_version: '>= 1.1',
)
cc = meson.get_compiler('c')
sources = [
'libtcc.c',
'tccpp.c',
'tccgen.c',
'tccelf.c',
'tccasm.c',
'tccdbg.c',
'tccrun.c',
]
cdata = configuration_data()
cdata.set_quoted('TCC_VERSION', meson.project_version())
tccdir = get_option('prefix') / get_option('libdir') / get_option('cross_prefix') + 'tcc'
cdata.set_quoted('CONFIG_TCCDIR', tccdir)
# Configure crosscompiling
host_os = get_option('cross_os')
if host_os == ''
host_os = host_machine.system()
endif
host_arch = get_option('cross_arch')
if host_arch == ''
host_arch = host_machine.cpu_family()
endif
# Configure compiling arch and os
if host_os == 'windows'
sources += 'tccpe.c'
cdata.set('TCC_TARGET_PE', true)
elif host_os == 'darwin'
sources += 'tccmacho.c'
cdata.set('TCC_TARGET_MACHO', true)
endif
if host_arch == 'x86'
sources += [
'i386-gen.c',
'i386-link.c',
'i386-asm.c',
]
cdata.set('TCC_TARGET_I386', true)
elif host_arch == 'x86_64'
sources += [
'x86_64-gen.c',
'x86_64-link.c',
'i386-asm.c',
]
if host_os != 'windows'
sources += 'lib/va_list.c'
endif
cdata.set('TCC_TARGET_X86_64', true)
elif host_arch == 'riscv64'
sources += ['riscv64-gen.c', 'riscv64-link.c', 'riscv64-asm.c']
cdata.set('TCC_TARGET_RISCV64', true)
elif host_arch == 'arm'
sources += [
'arm-gen.c',
'arm-link.c',
'arm-asm.c',
]
cdata.set('TCC_TARGET_ARM', true)
cdata.set('TCC_ARM_EABI', true)
cdata.set('TCC_ARM_VFP', true)
is_hardfloat_src = '''
#ifndef __ARM_PCS_VFP
# error Not hardfloat
#endif
'''
if cc.compiles(is_hardfloat_src, name: 'hardfloat ABI')
cdata.set('TCC_ARM_HARDFLOAT', true)
endif
elif host_arch == 'aarch64'
sources += [
'arm64-gen.c',
'arm64-link.c',
'arm-asm.c',
]
cdata.set('TCC_TARGET_ARM64', true)
have_ptrauth_src = '''
#ifdef __clang__
# if __has_feature(ptrauth_calls)
# define HAVE_PTRAUTH 1
# endif
#endif
#ifndef HAVE_PTRAUTH
# error Pointer authentication not supported
#endif
'''
if cc.compiles(have_ptrauth_src, name: 'pointer authentication')
cdata.set('HAVE_PTRAUTH', true)
endif
endif
install_headers('libtcc.h')
runtime_headers = [
'include/float.h',
'include/stdalign.h',
'include/stdarg.h',
'include/stdatomic.h',
'include/stdbool.h',
'include/stddef.h',
'include/stdnoreturn.h',
'include/tccdefs.h',
'include/tgmath.h',
'include/varargs.h',
]
install_headers(runtime_headers, install_dir: tccdir / 'include')
configure_file(
output: 'config.h',
configuration: cdata,
)
threads_dep = dependency('threads')
dl_dep = cc.find_library('dl', required: false)
libtcc = library(
get_option('cross_prefix') + 'tcc',
sources,
c_args: ['-DONE_SOURCE=0'],
install: true,
dependencies: [threads_dep, dl_dep],
)
libtcc_dep = declare_dependency(
link_with: libtcc,
include_directories: include_directories('./meson-include/'),
variables: {'libdir': get_option('libdir')},
)
tcc = executable(
get_option('cross_prefix') + 'tcc',
sources: ['tcc.c'],
link_with: libtcc,
install: not meson.is_subproject(),
)
makeinfo = find_program('makeinfo', required: false)
if makeinfo.found()
# custom_target('docs-html', output: 'tcc-doc.html', input: 'tcc-doc.texi', command:['makeinfo','@INPUT@','--no-split','--html','--number-sections','-o','@OUTPUT@'], install: not meson.is_subproject(), install_dir : get_option('datadir'))
# custom_target('docs-info', output: 'tcc-doc.info', input: 'tcc-doc.texi', command:['makeinfo','@INPUT@','-o','@OUTPUT@'], install: not meson.is_subproject(), install_dir : get_option('infodir'))
endif
#perl = find_program('perl', required:false)
#if perl.found()
# pod = custom_target('docs-pod', output: 'tcc-doc.pod', input: 'tcc-doc.texi', command:['perl','./texi2pod.pl','@INPUT@','@OUTPUT@'])
# #TODO Add entry for common.texi
#
# pod2man = find_program('pod2man', required:false)
# if pod2man.found()
# #custom_target('docs-man', depends: [pod], output: 'tcc.doc.1', input: 'tcc-doc.pod', command:['pod2man','--section=1', '--center="Tiny C Compiler"', '--release="'+meson.project_version()+'"','@INPUT@','@OUTPUT@'], install: not meson.is_subproject(), install_dir : get_option('mandir'))
# endif
#endif
#Not complete yet
#subdir('lib')
if get_option('tests')
subdir(['./tests/'])
endif
if get_option('override_dependency')
pkg = import('pkgconfig')
pkg.generate(
libtcc,
name: get_option('cross_prefix') + 'libtcc',
description: 'Tiny C Compiler',
url: 'https://bellard.org/tcc/',
)
meson.override_dependency(get_option('cross_prefix') + 'libtcc', libtcc_dep)
endif