1 | #
|
---|
2 | # Copyright (c) 2019 Jiří Zárevúcky
|
---|
3 | # All rights reserved.
|
---|
4 | #
|
---|
5 | # Redistribution and use in source and binary forms, with or without
|
---|
6 | # modification, are permitted provided that the following conditions
|
---|
7 | # are met:
|
---|
8 | #
|
---|
9 | # - Redistributions of source code must retain the above copyright
|
---|
10 | # notice, this list of conditions and the following disclaimer.
|
---|
11 | # - Redistributions in binary form must reproduce the above copyright
|
---|
12 | # notice, this list of conditions and the following disclaimer in the
|
---|
13 | # documentation and/or other materials provided with the distribution.
|
---|
14 | # - The name of the author may not be used to endorse or promote products
|
---|
15 | # derived from this software without specific prior written permission.
|
---|
16 | #
|
---|
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | #
|
---|
28 |
|
---|
29 | ## Generate config.mk, config.sh
|
---|
30 |
|
---|
31 | # Get the directory where the compiler resides.
|
---|
32 |
|
---|
33 | cc_fullname = run_command(which, meson.get_compiler('c').cmd_array()[0].split(' ')[0], check: true).stdout().strip()
|
---|
34 | cc_path = run_command(dirname, cc_fullname, check: true).stdout().strip()
|
---|
35 |
|
---|
36 | message(['Compiler directory is:', cc_path])
|
---|
37 |
|
---|
38 | export_cppflags = [
|
---|
39 | '-isystem', '$(HELENOS_EXPORT_ROOT)/include/libposix',
|
---|
40 | '-isystem', '$(HELENOS_EXPORT_ROOT)/include/libc',
|
---|
41 | '-idirafter', '$(HELENOS_EXPORT_ROOT)/include',
|
---|
42 | ]
|
---|
43 |
|
---|
44 | export_ldflags = [
|
---|
45 | '-nostdlib',
|
---|
46 | '-L$(HELENOS_EXPORT_ROOT)/lib',
|
---|
47 | '-Wl,--whole-archive',
|
---|
48 | '$(HELENOS_EXPORT_ROOT)/lib/libstartfiles.a',
|
---|
49 | '-Wl,--no-whole-archive',
|
---|
50 | ]
|
---|
51 |
|
---|
52 | export_ldlibs = [
|
---|
53 | '-Wl,--as-needed',
|
---|
54 | '-lposix',
|
---|
55 | '-lmath',
|
---|
56 | '-lc',
|
---|
57 | '-lgcc',
|
---|
58 | '-Wl,--no-as-needed',
|
---|
59 | ]
|
---|
60 |
|
---|
61 | cc_arch = meson.get_cross_property('cc_arch')
|
---|
62 |
|
---|
63 | conf_data = configuration_data({
|
---|
64 | 'HELENOS_OVERLAY_PATH' : meson.source_root() / 'uspace/overlay',
|
---|
65 | 'HELENOS_CROSS_PATH' : cc_path,
|
---|
66 | 'HELENOS_ARCH' : cc_arch,
|
---|
67 | 'HELENOS_CFLAGS' : ' '.join(arch_uspace_c_args),
|
---|
68 | 'HELENOS_CXXFLAGS' : ' '.join(arch_uspace_c_args),
|
---|
69 | 'HELENOS_CPPFLAGS' : ' '.join(export_cppflags),
|
---|
70 | 'HELENOS_LDFLAGS' : ' '.join(export_ldflags),
|
---|
71 | 'HELENOS_LDLIBS' : ' '.join(export_ldlibs),
|
---|
72 | 'HELENOS_TARGET' : cc_arch + '-helenos',
|
---|
73 | })
|
---|
74 |
|
---|
75 | config_mk = configure_file(
|
---|
76 | input: 'config.mk.in',
|
---|
77 | output: 'config.mk',
|
---|
78 | configuration: conf_data,
|
---|
79 | )
|
---|
80 |
|
---|
81 | config_sh = custom_target('config.sh',
|
---|
82 | input: config_mk,
|
---|
83 | output: 'config.sh',
|
---|
84 | command: [ sed, 's:$(HELENOS_EXPORT_ROOT):${HELENOS_EXPORT_ROOT}:g', '@INPUT@' ],
|
---|
85 | capture: true,
|
---|
86 | )
|
---|