#!/bin/sh # Generate a wrapper for Gilbraltar (G)CC, ld, objcopy and any other binutil # Expected argument: the tool to generate # Expected environment variables: # ARCH: the target architecture (x86_64 or aarch64) # TOOL_CFLAGS and TOOL_LDFLAGS: extra flags # GILBRALTAR_TOOLCHAIN: the target for the wrapped Gilbraltar toolchain # OTHERTOOLPREFIX: the prefix for tools not in the Gilbraltar toolchain # TARGET_X: overrides the command for binutil X gen_cc() { # Note that -nostdlib is not required, as it is injected by Solo5' cc, ld CFLAGS="$TOOL_CFLAGS" LDFLAGS="$TOOL_LDFLAGS" EXTRALIBS="" case "$ARCH" in aarch64) EXTRALIBS="-lgcc" ;; esac # Add the -Wno-unused-command-line-argument option for clang, as we always # give it compiling options, even if it will be only linking # Reuse the test from Solo5 to detect clang if "$SOLO5_TOOLCHAIN-cc" -dM -E - /dev/null; then TOOL="$SOLO5_TOOLCHAIN-$TOOL" else case "$TOOL" in as) TOOL="$SOLO5_TOOLCHAIN-cc -c" ;; *) if command -v -- "$OTHERTOOLPREFIX$TOOL" > /dev/null; then TOOL="$OTHERTOOLPREFIX$TOOL" fi ;; esac fi cat << EOF #!/bin/sh exec $TOOL "\$@" EOF } case "$1" in cc|gcc) gen_cc ;; *) gen_tool "$1" ;; esac