diff --git a/scripts/clang-target-wrapper b/scripts/clang-target-wrapper new file mode 100755 index 0000000..58043e1 --- /dev/null +++ b/scripts/clang-target-wrapper @@ -0,0 +1,42 @@ +#!/bin/sh +# PROJECT: XTchain +# LICENSE: See the COPYING.md in the top level directory +# FILE: scripts/clang-target-wrapper +# DESCRIPTION: CLANG Wrapper +# DEVELOPERS: Martin Storsjo +# Rafal Kupiec + + +# Set basic variables +DIR="$(cd $(dirname $0) && pwd)" +CLANG="$DIR/clang" +BASENAME="$(basename $0)" +TARGET="${BASENAME%-*}" +EXECUTABLE="${BASENAME##*-}" +DEFAULT_TARGET="x86_64-w64-mingw32" +ARCH="${TARGET%%-*}" + +# Set proper target +if [ "${TARGET}" = "${BASENAME}" ]; then + TARGET="${DEFAULT_TARGET}" +fi + +# Set lang-specific flags +case ${EXECUTABLE} in + "clang++"|"g++"|"c++") + FLAGS="$FLAGS --driver-mode=g++" + ;; + *) + FLAGS="" + ;; +esac + +# Set compiler flags +FLAGS="${FLAGS} -target ${TARGET}" +FLAGS="${FLAGS} -rtlib=compiler-rt" +FLAGS="${FLAGS} -stdlib=libc++" +FLAGS="${FLAGS} -fuse-ld=lld" +FLAGS="${FLAGS} -Qunused-arguments" + +# Launch the compiler +$CLANG $FLAGS "$@" diff --git a/scripts/dlltool-wrapper b/scripts/dlltool-wrapper new file mode 100755 index 0000000..09db3a3 --- /dev/null +++ b/scripts/dlltool-wrapper @@ -0,0 +1,42 @@ +#!/bin/sh +# PROJECT: XTchain +# LICENSE: See the COPYING.md in the top level directory +# FILE: scripts/dlltool-wrapper +# DESCRIPTION: DLLTOOL Wrapper +# DEVELOPERS: Martin Storsjo +# Rafal Kupiec + + +# Set basic variables +DIR="$(cd $(dirname $0) && pwd)" +BASENAME="$(basename $0)" +TARGET="${BASENAME%-*}" +DEFAULT_TARGET="x86_64-w64-mingw32" + +# Update PATH +export PATH="$DIR":"$PATH" + +# Set proper target +if [ "${TARGET}" = "${BASENAME}" ]; then + TARGET="${DEFAULT_TARGET}" +fi + +# Set target machine +ARCH="${TARGET%%-*}" +case $ARCH in + aarch64) + M="arm64" + ;; + armv7) + M="arm" + ;; + i686) + M="i386" + ;; + x86_64) + M="i386:x86-64" + ;; +esac + +# Launch the utility +llvm-dlltool -m ${M} "$@" diff --git a/scripts/ld-wrapper b/scripts/ld-wrapper new file mode 100755 index 0000000..6fa9d39 --- /dev/null +++ b/scripts/ld-wrapper @@ -0,0 +1,42 @@ +#!/bin/sh +# PROJECT: XTchain +# LICENSE: See the COPYING.md in the top level directory +# FILE: scripts/ld-wrapper +# DESCRIPTION: LLD Wrapper +# DEVELOPERS: Martin Storsjo +# Rafal Kupiec + + +# Set basic variables +DIR="$(cd $(dirname $0) && pwd)" +BASENAME="$(basename $0)" +TARGET="${BASENAME%-*}" +DEFAULT_TARGET="x86_64-w64-mingw32" + +# Update PATH +export PATH="${DIR}":"${PATH}" + +# Set proper target +if [ "${TARGET}" = "${BASENAME}" ]; then + TARGET="${DEFAULT_TARGET}" +fi + +# Set target machine +ARCH="${TARGET%%-*}" +case ${ARCH} in + aarch64) + M="arm64pe" + ;; + armv7) + M="thumb2pe" + ;; + i686) + M="i386pe" + ;; + x86_64) + M="i386pep" + ;; +esac + +# Launch the linker +ld.lld -m ${M} "$@" diff --git a/scripts/objdump-wrapper b/scripts/objdump-wrapper new file mode 100755 index 0000000..977551c --- /dev/null +++ b/scripts/objdump-wrapper @@ -0,0 +1,46 @@ +#!/bin/sh +# PROJECT: XTchain +# LICENSE: See the COPYING.md in the top level directory +# FILE: scripts/objdump-wrapper +# DESCRIPTION: OBJDUMP Wrapper +# DEVELOPERS: Martin Storsjo +# Rafal Kupiec + + +# Set basic variables +DIR="$(cd $(dirname $0) && pwd)" + +# Update PATH +export PATH="$DIR":"$PATH" + +# Libtool can try to run objdump -f and wants to see certain strings in +# the output, to accept it being a valid windows (import) library +if [ "$1" = "-f" ]; then + llvm-readobj $2 | while read -r line; do + case $line in + File:*) + file=$(echo $line | awk '{print $2}') + ;; + Format:*) + format=$(echo $line | awk '{print $2}') + case $format in + COFF-i386) + format=pe-i386 + ;; + COFF-x86-64) + format=pe-x86-64 + ;; + COFF-ARM*) + # This is wrong; modern COFF armv7 isn't pe-arm-wince, and + # arm64 definitely isn't, but libtool wants to see this + # string (or some of the others) in order to accept it. + format=pe-arm-wince + ;; + esac + echo $file: file format $format + ;; + esac + done +else + llvm-objdump "$@" +fi diff --git a/scripts/xtchain b/scripts/xtchain new file mode 100755 index 0000000..63f6015 --- /dev/null +++ b/scripts/xtchain @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# PROJECT: XTchain +# LICENSE: See the COPYING.md in the top level directory +# FILE: scripts/xtchain +# DESCRIPTION: XTchain Entry Script +# DEVELOPERS: Rafal Kupiec + + +# Check if script launched as root +if [ "$(whoami)" = "root" ]; then + echo "This script cannot be run as root!" + exit 1 +fi + +# Get the absolute path to the XTchain +export XTCDIR="$(realpath $(dirname ${0}))" + +# Read the XTchain version +export XTCVER="$(cat ${XTCDIR}/Version)" + +# Load the library +source ${XTCDIR}/lib/xtchain/xtclib + +# Set the target architecture +: ${TARGET:=${1}} +: ${TARGET:=amd64} + +# Save the source directory +export SRCDIR="${2:-${PWD}}" + +# Make sure the compiler flags are clean +export HOST= +export CFLAGS= +export CXXFLAGS= +export LDFLAGS= + +# Update PATH +export PATH="${XTCDIR}/bin:${PATH}" + +# Display banner +version + +# Invoke shell with fancy prompt +export PFMAT1="\[\033[0;1;97;44m\]" +export PFMAT2="\[\033[0;34;104m\]" +export PFMAT3="\[\033[0;1;97;104m\]" +export PFMAT4="\[\033[0;94;49m\]" +export PFMAT5="\[\033[1;38;5;74m\]" +export PROMPT="\n${PFMAT1} XT Toolchain ${PFMAT2}${PFMAT3} \w ${PFMAT4}${PFMAT5} " +bash --rcfile <(echo 'source ~/.bashrc && export PS1="${PROMPT}" && cd ${SRCDIR}') diff --git a/scripts/xtclib b/scripts/xtclib new file mode 100755 index 0000000..c98f3e9 --- /dev/null +++ b/scripts/xtclib @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# PROJECT: XTchain +# LICENSE: See the COPYING.md in the top level directory +# FILE: scripts/xtclib +# DESCRIPTION: XTchain library +# DEVELOPERS: Rafal Kupiec + + +# Sets the target architecture +charch() +{ + if [ "x${1}" == "x" ]; then + echo "Syntax: charch [architecture]" + return + fi + case ${1} in + "aarch64"|"arm64") + export TARGET="aarch64" + ;; + "arm"|"armv7") + export TARGET="armv7" + ;; + "i386"|"i486"|"i586"|"i686"|"x86") + export TARGET="i686" + ;; + "amd64"|"x64"|"x86_64") + export TARGET="amd64" + ;; + *) + export TARGET="UNKNOWN" + esac + echo "Target Architecture: ${TARGET}" +} +export -f charch + +# Displays version banner +version() +{ + echo "###############################################################################" + echo "# XT Toolchain v${XTCVER} for Linux #" + echo "# by Rafal Kupiec #" + echo "###############################################################################" + echo + echo + echo "LLVM Compiler Version: $(${XTCDIR}/bin/clang --version | grep 'clang version' | cut -d' ' -f3)" + echo "LLVM Windres Utility Version: $(${XTCDIR}/generic-w64-mingw32/bin/windres-wrapper -V | cut -d' ' -f7)" + echo "Mingw IDL Compiler Version: $(${XTCDIR}/bin/i686-w64-mingw32-widl -V | grep 'version' | cut -d' ' -f5)" + echo "Wine Message Compiler Version: $(${XTCDIR}/bin/wmc -V | grep 'version' | cut -d' ' -f5)" + echo "Wine Resource Compiler Version: $(${XTCDIR}/bin/wrc --version | grep 'version' | cut -d' ' -f5)" + echo + charch ${TARGET} + echo + echo +} +export -f version