2 # Copyright (c) 2006 Martin Decky
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
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.
29 subdir('arch' / BARCH)
31 if POSTBUILD == 'uboot'
32 boot_image_format = 'binary'
37 modules = [ 'boot/kernel.elf' ] + rd_init + [ 'boot/initrd.img' ]
41 # Collect binary references in the correct order.
44 foreach bin : rd_init_binaries
47 _newname = run_command(basename, bin[1], check: true).stdout().strip()
48 _oldname = run_command(basename, bin[0].full_path(), check: true).stdout().strip()
50 if CONFIG_COMPRESSED_INIT
51 _dep = custom_target(_newname + '.gz',
52 output: _newname + '.gz',
62 name_transform += 's:.*/@0@:@1@:;'.format(_oldname, _newname)
69 error('Could not find dependency ' + m)
74 boot_include_dirs = include_directories(
76 'arch'/BARCH/'include',
78 '../abi/arch'/BARCH/'include',
84 '-imacros', meson.build_root() / 'config.h',
87 '-DHELENOS_RELEASE=' + HELENOS_RELEASE,
88 '-DHELENOS_COPYRIGHT=' + HELENOS_COPYRIGHT,
89 '-DHELENOS_CODENAME=' + HELENOS_CODENAME,
90 '-D__@0@_BITS__'.format(meson.get_cross_property('bits')),
93 boot_c_args = arch_boot_c_args + boot_defs + [
97 boot_link_args = arch_boot_link_args + [
100 '-T', meson.current_build_dir()/'_link.ld',
103 if cc.get_id() == 'clang'
105 '-fno-stack-protector',
107 # '-mllvm', '-asm-macro-max-nesting-depth=1000',
111 boot_files = static_library('bootfiles', boot_src,
112 include_directories: boot_include_dirs,
113 implicit_include_directories: false,
116 build_by_default: true,
119 # Preprocess linker script using C preprocessor.
120 boot_ldscript = custom_target('_link.ld',
121 input: 'arch'/KARCH/'_link.ld.in',
126 '-I' + meson.current_source_dir()/'arch'/KARCH/'include',
135 build_by_default: true
138 # Create empty object file.
139 boot_empty_o = custom_target('empty.o',
151 boot_comps_tar = custom_target('components.tar',
153 output: 'components.tar',
154 command: [ tar, '--transform', name_transform ],
157 # Add .payload section to the empty object.
158 boot_comps_o = custom_target('components.o',
159 output: 'components.o',
160 input: [ boot_comps_tar, boot_empty_o ],
163 '--add-section', '.payload=@INPUT0@',
169 boot_image_name = 'image.boot'
170 boot_image_map_path = meson.current_build_dir()/boot_image_name + '.map'
172 boot_elf = executable(boot_image_name + '.elf', boot_comps_o,
173 include_directories: boot_include_dirs,
175 link_args: boot_c_args + boot_link_args + [
176 '-Wl,-Map,' + boot_image_map_path,
178 link_depends: boot_ldscript,
179 link_whole: boot_files,
181 build_by_default: false,
184 if boot_image_format == 'elf'
185 boot_image = boot_elf
188 if boot_image_format == 'binary'
189 # Some platforms can't ELF.
190 boot_image = custom_target(boot_image_name + '.bin',
192 output: boot_image_name + '.bin',
193 command: [ objcopy, '-O', 'binary', '@INPUT@', '@OUTPUT@' ],
198 if POSTBUILD == 'raw'
199 POST_INPUT = boot_image
202 if POSTBUILD == 'grub'
206 if POSTBUILD == 'yaboot'
210 if POSTBUILD == 'silo'
214 if POSTBUILD == 'uboot'
215 IMAGE_NAME = 'HelenOS-' + HELENOS_RELEASE
217 POST_INPUT = custom_target('uboot-image',
218 output: 'uboot-image.bin',
225 '-ostype', UIMAGE_OS,