| 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 | if CONFIG_DEVEL_FILES
|
|---|
| 30 | # If devel files are requested, we have to install libgcc.
|
|---|
| 31 | # We have to explicitly use gcc for this, because clang only prints
|
|---|
| 32 | # file name instead of whole path.
|
|---|
| 33 | libgcc = run_command(cc_path / cc_arch + '-helenos-gcc',
|
|---|
| 34 | arch_uspace_c_args, '-print-libgcc-file-name',
|
|---|
| 35 | check: true,
|
|---|
| 36 | ).stdout().strip()
|
|---|
| 37 |
|
|---|
| 38 | install_files += [[ 'lib', libgcc, 'libgcc.a' ]]
|
|---|
| 39 | install_deps += [ files(libgcc) ]
|
|---|
| 40 | endif
|
|---|
| 41 |
|
|---|
| 42 | # Collect and install copyright information.
|
|---|
| 43 | copyrights_file = custom_target('COPYRIGHT',
|
|---|
| 44 | output: 'COPYRIGHT',
|
|---|
| 45 | command: cpc,
|
|---|
| 46 | capture: true,
|
|---|
| 47 | )
|
|---|
| 48 |
|
|---|
| 49 | install_files += [[ '', copyrights_file.full_path(), 'COPYRIGHT' ]]
|
|---|
| 50 | install_deps += [ copyrights_file ]
|
|---|
| 51 |
|
|---|
| 52 | # Emit the install script.
|
|---|
| 53 |
|
|---|
| 54 | install_script_text = []
|
|---|
| 55 |
|
|---|
| 56 | # Copy uspace/dist.
|
|---|
| 57 | _uspace = meson.source_root() / 'uspace'
|
|---|
| 58 | install_script_text += 'cp -r -L -T -u "@0@/dist" "${DESTDIR}"'.format(_uspace)
|
|---|
| 59 |
|
|---|
| 60 | # Copy uspace/overlay
|
|---|
| 61 | install_script_text += 'if ls @0@/overlay/* >/dev/null 2>/dev/null; then'.format(_uspace)
|
|---|
| 62 | install_script_text += 'cp -r -L @0@/overlay/* "${DESTDIR}"'.format(_uspace)
|
|---|
| 63 | install_script_text += 'fi'
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | foreach f : install_files
|
|---|
| 67 | _cmd = 'mkdir -p "${DESTDIR}@0@" && cp -L -T "@1@" "${DESTDIR}@0@/@2@"'
|
|---|
| 68 | install_script_text += _cmd.format(f[0], f[1], f[2])
|
|---|
| 69 | endforeach
|
|---|
| 70 |
|
|---|
| 71 | if CONFIG_DEVEL_FILES
|
|---|
| 72 | install_script_text += uspace_lib_devel_install_script_text
|
|---|
| 73 | endif
|
|---|
| 74 |
|
|---|
| 75 | install_devel_script = configure_file(
|
|---|
| 76 | configuration: { 'text' : '\n'.join(uspace_lib_devel_install_script_text) },
|
|---|
| 77 | input: 'install_devel.sh.in',
|
|---|
| 78 | output: 'install_devel.sh',
|
|---|
| 79 | )
|
|---|
| 80 |
|
|---|
| 81 | install_script_text += uspace_lib_install_script_text
|
|---|
| 82 |
|
|---|
| 83 | install_script = configure_file(
|
|---|
| 84 | configuration: { 'text' : '\n'.join(install_script_text) },
|
|---|
| 85 | input: 'install.sh.in',
|
|---|
| 86 | output: 'install.sh',
|
|---|
| 87 | )
|
|---|
| 88 |
|
|---|
| 89 | # Build up dist
|
|---|
| 90 |
|
|---|
| 91 | dist_dir = meson.build_root() / 'dist/'
|
|---|
| 92 |
|
|---|
| 93 | run_target('devel-headers',
|
|---|
| 94 | command: [ sh, install_devel_script, dist_dir ],
|
|---|
| 95 | )
|
|---|
| 96 |
|
|---|
| 97 | dist = custom_target('DIST',
|
|---|
| 98 | output: 'dist.tag',
|
|---|
| 99 | input: [ install_script, install_deps ],
|
|---|
| 100 | command: [ sh, '@INPUT0@', '@OUTPUT@', dist_dir ],
|
|---|
| 101 | build_always_stale: true,
|
|---|
| 102 | )
|
|---|
| 103 |
|
|---|
| 104 | # Build initrd image
|
|---|
| 105 |
|
|---|
| 106 | if RDFMT == 'tmpfs'
|
|---|
| 107 | initrd_cmd = [ 'tar', '-c', '-f', '@OUTPUT@', '-C', dist_dir, '.' ]
|
|---|
| 108 | elif RDFMT == 'fat'
|
|---|
| 109 | initrd_cmd = [ mkfat, '1048576', dist_dir, '@OUTPUT@' ]
|
|---|
| 110 | elif RDFMT == 'ext4fs'
|
|---|
| 111 | initrd_cmd = [ mkext4, '1048576', dist_dir, '@OUTPUT@' ]
|
|---|
| 112 | else
|
|---|
| 113 | error('Unknown RDFMT: ' + RDFMT)
|
|---|
| 114 | endif
|
|---|
| 115 |
|
|---|
| 116 | initrd_img = custom_target('initrd.img',
|
|---|
| 117 | output: 'initrd.img',
|
|---|
| 118 | input: dist,
|
|---|
| 119 | command: initrd_cmd,
|
|---|
| 120 | )
|
|---|
| 121 |
|
|---|
| 122 | rd_init_binaries += [[ initrd_img, 'boot/initrd.img' ]]
|
|---|