source: mainline/tools/xcw/bin/helenos-cc@ 7e53c37

Last change on this file since 7e53c37 was 7e53c37, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 4 years ago

Update files with /bin/bash shebang

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/bin/bash
2#
3# SPDX-FileCopyrightText: 2018 Jiri Svoboda
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7# C Compiler (cc) wrapper
8# HelenOS Cross Compiler Wrapper (XCW)
9# Facilitate cross-compiling external software to HelenOS
10#
11
12
13
14XCW="$(dirname "$0")"
15BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")"
16if [ -z "$EXPORT_DIR" ]; then
17 EXPORT_DIR="$BUILD_ROOT/export"
18fi
19
20HELENOS_EXPORT_ROOT="$EXPORT_DIR"
21
22source "${EXPORT_DIR}/config.sh"
23
24# CC is a compilation driver, so we should check which stage of compilation
25# is actually running and select which flags to provide. This makes no
26# difference for GCC, but e.g. clang warns when a flag is provided that is
27# unused
28
29needs_cflags=true
30needs_ldflags=true
31
32for flag in "$@"; do
33 case "$flag" in
34 -E)
35 needs_cflags=false
36 needs_ldflags=false
37 break
38 ;;
39 -c|-S)
40 needs_ldflags=false
41 break
42 ;;
43 esac
44done
45
46flags="-fwide-exec-charset=UTF-32LE -finput-charset=UTF-8 -fexec-charset=UTF-8"
47flags="$flags -isystem ${HELENOS_EXPORT_ROOT}/include/libc -idirafter ${HELENOS_EXPORT_ROOT}/include"
48
49if $needs_cflags; then
50 flags="$flags -O3 \
51 -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
52 -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings -ggdb"
53
54 flags="$flags $HELENOS_CFLAGS"
55fi
56
57if $needs_ldflags; then
58 flags="$flags $HELENOS_LDFLAGS"
59fi
60
61flags="$flags $@"
62
63if $needs_ldflags; then
64 flags="$flags $HELENOS_LDLIBS"
65fi
66
67echo "helenos-cc" "$@"
68PATH="$HELENOS_CROSS_PATH:$PATH" "${HELENOS_TARGET}-gcc" $flags
Note: See TracBrowser for help on using the repository browser.