source: mainline/meson.build@ 41408d94

lfn serial ticket/834-toolchain-update topic/fix-logger-deadlock topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 41408d94 was 41408d94, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

sparc64

  • Property mode set to 100644
File size: 8.4 KB
Line 
1# TODO: Use vcs_tag() to generate version string
2# TODO: jobfile
3# TODO: lto
4# TODO: CONFIG_BUILD_SHARED_LIBS
5# TODO: fix clang build
6
7project(
8 'HelenOS',
9 [ 'c', 'cpp' ],
10 default_options : ['buildtype=plain', 'c_std=gnu11', 'cpp_std=c++17', 'warning_level=3', 'werror=false', 'b_staticpic=false', 'default_library=shared', 'prefix=/' ],
11)
12
13cc = meson.get_compiler('c')
14basename = find_program('basename')
15dirname = find_program('dirname')
16find = find_program('find')
17grep = find_program('grep')
18mkarray = find_program('tools/mkarray_for_meson.sh')
19objdump = find_program('objdump')
20sed = find_program('sed')
21unzip = find_program('unzip')
22which = find_program('which')
23
24autocheck = generator(find_program('tools/autocheck.awk'),
25 arguments: [ '@INPUT@' ],
26 output: '@PLAINNAME@.check.c',
27 capture: true,
28)
29
30
31if get_option('default_library') == 'both'
32 error('You must use either shared or static for default_library.')
33endif
34
35debug_options = false
36
37# Output compiler flags for use by third-party builds.
38# NOTE: See $srcroot/meson/cross/$arch for architecture-specific compiler flags.
39
40if debug_options
41 message('Cross c_args:')
42 message(meson.get_cross_property('c_args'))
43 message('Cross cpp_args:')
44 message(meson.get_cross_property('cpp_args'))
45 message('Cross c_link_args:')
46 message(meson.get_cross_property('c_link_args'))
47 message('Cross cpp_link_args:')
48 message(meson.get_cross_property('cpp_link_args'))
49endif
50
51# Read some variables from Makefile.common
52config_variables = [
53 # Uspace and kernel
54 'CONFIG_BAREBONE',
55 'CONFIG_BUILD_SHARED_LIBS',
56 'CONFIG_DEBUG',
57 'CONFIG_DEVEL_FILES',
58 'CONFIG_FPU',
59 'CONFIG_LINE_DEBUG',
60 'CONFIG_PCUT_SELF_TESTS',
61 'CONFIG_PCUT_TESTS',
62 'CONFIG_RTLD',
63 'CONFIG_STRIP_BINARIES',
64 'CONFIG_UBSAN',
65 'CONFIG_USE_SHARED_LIBS',
66 'OPTIMIZATION',
67 'PROCESSOR',
68 'QUADFLOAT',
69 'RDFMT',
70
71 # Kernel only
72 'CONFIG_ACPI',
73 'CONFIG_AM335X_TIMERS',
74 'CONFIG_ASID',
75 'CONFIG_ASID_FIFO',
76 'CONFIG_AT_KBD',
77 'CONFIG_BCM2835_MAILBOX',
78 'CONFIG_DSRLNIN',
79 'CONFIG_DSRLNOUT',
80 'CONFIG_EGA',
81 'CONFIG_FB',
82 'CONFIG_GICV2',
83 'CONFIG_I8042',
84 'CONFIG_I8259',
85 'CONFIG_IOMAP_BITMAP',
86 'CONFIG_IOMAP_DUMMY',
87 'CONFIG_KCONSOLE',
88 'CONFIG_MAC_KBD',
89 'CONFIG_MULTIBOOT',
90 'CONFIG_NS16550',
91 'CONFIG_OFW_PCI',
92 'CONFIG_OFW_TREE',
93 'CONFIG_OMAP_UART',
94 'CONFIG_PAGE_HT',
95 'CONFIG_PAGE_PT',
96 'CONFIG_PC_KBD',
97 'CONFIG_PL011_UART',
98 'CONFIG_PL050',
99 'CONFIG_S3C24XX_IRQC',
100 'CONFIG_S3C24XX_UART',
101 'CONFIG_SMP',
102 'CONFIG_SOFTINT',
103 'CONFIG_SRLN',
104 'CONFIG_SUN_KBD',
105 'CONFIG_SYMTAB',
106 'CONFIG_TEST',
107 'CONFIG_TRACE',
108 'CONFIG_TSB',
109 'CONFIG_UDEBUG',
110 'CONFIG_VIA_CUDA',
111 'MACHINE',
112 'MEMORY_MODEL',
113]
114
115foreach varname : config_variables
116 result = run_command(grep, '^' + varname + '\\b', meson.source_root() / 'Makefile.config')
117 if result.returncode() != 0
118 # TODO: Output negative/inapplicable variables too in config, so that we can check for typos here.
119 #warning('Missing configuration variable ' + varname + ' in Makefile.config')
120 set_variable(varname, false)
121 continue
122 endif
123
124 value = result.stdout().split('\n')[0].strip().split('=')[1].strip()
125 if value == 'y'
126 value = true
127 elif value == 'n'
128 value = false
129 endif
130
131 set_variable(varname, value)
132 if debug_options
133 message([ varname, value ])
134 endif
135endforeach
136
137# Also read version information.
138version_variables = [
139 'COPYRIGHT',
140 'NAME',
141 'PATCHLEVEL',
142 'SUBLEVEL',
143 'VERSION',
144]
145
146foreach varname : version_variables
147 line = run_command(grep, '^' + varname + '\\b', meson.source_root() / 'version', check: true).stdout().strip()
148 value = line.split('=')[1].strip()
149 set_variable('HELENOS_' + varname, value)
150 if debug_options
151 message([ 'HELENOS_' + varname, value ])
152 endif
153endforeach
154
155HELENOS_RELEASE = HELENOS_VERSION + '.' + HELENOS_PATCHLEVEL + '.' + HELENOS_SUBLEVEL
156
157h_arch = meson.get_cross_property('h_arch')
158
159meson.add_install_script('install.sh', CONFIG_DEVEL_FILES.to_string())
160
161add_project_arguments(
162 # TODO: Remove from project arguments and only use where needed.
163 '-imacros', join_paths(meson.source_root(), 'config.h'),
164 language : [ 'c' ],
165)
166
167add_project_link_arguments(
168 cc.get_supported_link_arguments([
169 '-Wl,--gc-sections',
170 '-Wl,--warn-common',
171 ]),
172 '-Wl,--fatal-warnings',
173 language : [ 'c', 'cpp' ],
174)
175
176# TODO: enable more warnings
177# FIXME: -fno-builtin-strftime works around seemingly spurious format warning.
178# We should investigate what's going on there.
179
180extra_common_flags = [
181 '-O' + OPTIMIZATION,
182 '-fexec-charset=UTF-8',
183 '-finput-charset=UTF-8',
184
185 '-D_HELENOS_SOURCE',
186 '-Wa,--fatal-warnings',
187
188 '-Wall',
189 '-Wextra',
190
191 '-Werror-implicit-function-declaration',
192
193 '-Wwrite-strings',
194 '-Wsystem-headers',
195 '-Wunknown-pragmas',
196
197 '-Wno-unused-parameter',
198
199 '-pipe',
200 '-ffunction-sections',
201
202 '-fno-common',
203
204 '-fdebug-prefix-map=' + meson.source_root() + '=.',
205]
206
207if h_arch != 'ia64'
208 extra_common_flags += [ '-fvar-tracking-assignments' ]
209endif
210
211if CONFIG_DEBUG
212 extra_common_flags += [ '-Werror' ]
213endif
214
215if CONFIG_LINE_DEBUG
216 extra_common_flags += [ '-gdwarf-4', '-g3' ]
217endif
218
219extra_cflags = extra_common_flags + [
220 '-imacros', join_paths(meson.source_root(), 'config.h'),
221
222 '-Wmissing-prototypes',
223
224 '-Wno-missing-braces',
225 '-Wno-missing-field-initializers',
226 '-Wno-unused-command-line-argument',
227 '-Wno-unused-parameter',
228 '-Wno-typedef-redefinition',
229 '-Wno-clobbered',
230 '-Wno-nonnull-compare',
231
232 '-fno-builtin-strftime',
233]
234
235if CONFIG_UBSAN
236 extra_cflags += '-fsanitize=undefined'
237endif
238
239extra_cppflags = extra_common_flags + [
240 '-fno-exceptions',
241 '-frtti',
242]
243
244w_flags = {
245 'c': extra_cflags,
246 'cpp': extra_cppflags,
247}
248
249# Process flags. Only sets those that compiler supports.
250foreach lang : [ 'c', 'cpp' ]
251 extra_cflags = meson.get_compiler(lang).get_supported_arguments(w_flags.get(lang))
252 add_project_arguments(extra_cflags, language : [ lang ])
253 add_project_link_arguments(extra_cflags, language : [ lang ])
254endforeach
255
256# Init binaries.
257rd_init = [
258 'app/init',
259 'srv/bd/rd',
260 'srv/fs/' + RDFMT,
261 'srv/loader',
262 'srv/locsrv',
263 'srv/logger',
264 'srv/ns',
265 'srv/vfs',
266]
267
268# Binaries allowed on the initrd image when CONFIG_BAREBONE is enabled.
269rd_essential = rd_init + [
270 'app/bdsh',
271 'app/getterm',
272 'app/kio',
273
274 'srv/devman',
275 'srv/fs/locfs',
276 'srv/hid/input',
277 'srv/hid/output',
278 'srv/hid/compositor',
279 'srv/hid/console',
280 'srv/klog',
281
282 'drv/root/root',
283 'drv/root/virt',
284 'drv/fb/kfb',
285]
286
287if CONFIG_FB
288 rd_essential += [
289 'app/vlaunch',
290 'app/vterm',
291 ]
292endif
293
294
295## The at-sign
296#
297# The `atsign` variable holds the ASCII character representing the at-sign
298# ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
299# don't use '@' for starting a comment, `atsign` is merely '@'. However, on
300# those that do use it for starting a comment (e.g. arm32), `atsign` must be
301# defined as the percentile-sign ('%') in the architecture-dependent files.
302#
303atsign = '@'
304
305## Some architectures need a particular string at the beginning of assembly files.
306kernel_as_prolog = ''
307uspace_as_prolog = ''
308
309subdir('meson' / 'arch' / h_arch)
310
311subdir('kernel')
312subdir('uspace')
313
314
315## Generate config.mk
316
317# Get the directory where the compiler resides.
318
319cc_fullname = run_command(which, meson.get_compiler('c').cmd_array()[0].split(' ')[0], check: true).stdout().strip()
320cc_path = run_command(dirname, cc_fullname, check: true).stdout().strip()
321
322message(['Compiler directory is:', cc_path])
323
324export_cppflags = [
325 '-isystem', '$(HELENOS_EXPORT_ROOT)/include/posix',
326 '-isystem', '$(HELENOS_EXPORT_ROOT)/include/libc',
327 '-idirafter', '$(HELENOS_EXPORT_ROOT)/include',
328]
329
330export_ldflags = [
331 '-nostdlib',
332 '-L$(HELENOS_EXPORT_ROOT)/lib',
333 '-Wl,--whole-archive',
334 '$(HELENOS_EXPORT_ROOT)/lib/libstartfiles.a',
335 '-Wl,--no-whole-archive',
336]
337
338export_ldlibs = [
339 '-Wl,--as-needed',
340 '-lposix',
341 '-lmath',
342 '-lc',
343 '-lgcc',
344 '-Wl,--no-as-needed',
345]
346
347cc_arch = meson.get_cross_property('cc_arch')
348
349conf_data = configuration_data({
350 'HELENOS_CROSS_PATH' : cc_path,
351 'HELENOS_ARCH' : cc_arch,
352 'HELENOS_CFLAGS' : ' '.join(arch_uspace_c_args),
353 'HELENOS_CXXFLAGS' : ' '.join(arch_uspace_c_args),
354 'HELENOS_CPPFLAGS' : ' '.join(export_cppflags),
355 'HELENOS_LDFLAGS' : ' '.join(export_ldflags),
356 'HELENOS_LDLIBS' : ' '.join(export_ldlibs),
357 'HELENOS_TARGET' : cc_arch + '-helenos',
358})
359
360config_mk = configure_file(
361 input: 'config.mk.in',
362 output: 'config.mk',
363 configuration: conf_data,
364 install: true,
365 install_dir: 'config',
366)
367
368custom_target('config.sh',
369 input: config_mk,
370 output: 'config.sh',
371 command: [ sed, 's:$(HELENOS_EXPORT_ROOT):${HELENOS_EXPORT_ROOT}:g', '@INPUT@' ],
372 capture: true,
373 install: true,
374 install_dir: 'config',
375)
376
377install_data('Makefile.common', 'Makefile.config', install_dir: 'config')
Note: See TracBrowser for help on using the repository browser.