#!/usr/bin/env bash
# resolve python-version to use
-if [ "$PYTHON" == "" ] ; then
- if which python >/dev/null 2>&1
- then
+if [ "$PYTHON" == "" ]; then
+ if hash python 2>/dev/null; then
PYTHON=python
- elif which python2 >/dev/null 2>&1
- then
+ elif hash python2 2>/dev/null; then
PYTHON=python2
- elif which python2.7 >/dev/null 2>&1
- then
+ elif hash python2.7 2>/dev/null; then
PYTHON=python2.7
else
echo "Unable to locate build-dependency python2.x!" 1>&2
# validate python-dependency
# useful in case of explicitly set option.
-if ! which $PYTHON > /dev/null 2>&1
-then
+if ! hash $PYTHON 2>/dev/null; then
echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2
exit 1
fi
if [ $__UseNinja == 1 ]; then
generator="ninja"
buildFile="build.ninja"
- if which ninja >/dev/null 2>&1; then
+ if hash ninja 2>/dev/null; then
buildTool="ninja"
- elif which ninja-build >/dev/null 2>&1; then
+ elif hash ninja-build 2>/dev/null; then
buildTool="ninja-build"
else
echo "Unable to locate ninja!" 1>&2
if [ ! -e $__DOTNET_PATH ]; then
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.
- which curl > /dev/null 2> /dev/null
- if [ $? -ne 0 ]; then
- mkdir -p "$__DOTNET_PATH"
- wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
- echo "wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL"
+ if hash curl 2>/dev/null; then
+ curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
+ echo "curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL"
else
- curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
- echo "curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL"
+ mkdir -p "$__DOTNET_PATH"
+ wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
+ echo "wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL"
fi
+
cd $__DOTNET_PATH
tar -xf $__DOTNET_PATH/dotnet.tar
if [ -n "$BUILDTOOLS_OVERRIDE_RUNTIME" ]; then
# This file invokes cmake and generates the build system for Clang.
#
-if [ $# -lt 4 -o $# -gt 8 ]
-then
- echo "Usage..."
- echo "gen-buildsys-clang.sh <path to top level CMakeLists.txt> <ClangMajorVersion> <ClangMinorVersion> <Architecture> [build flavor] [coverage] [ninja] [cmakeargs]"
- echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
- echo "Specify the clang version to use, split into major and minor version"
- echo "Specify the target architecture."
- echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG."
- echo "Optionally specify 'coverage' to enable code coverage build."
- echo "Target ninja instead of make. ninja must be on the PATH."
- echo "Pass additional arguments to CMake call."
- exit 1
+if [ $# -lt 4 -o $# -gt 8 ]; then
+ echo "Usage..."
+ echo "gen-buildsys-clang.sh <path to top level CMakeLists.txt> <ClangMajorVersion> <ClangMinorVersion> <Architecture> [build flavor] [coverage] [ninja] [cmakeargs]"
+ echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
+ echo "Specify the clang version to use, split into major and minor version"
+ echo "Specify the target architecture."
+ echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG."
+ echo "Optionally specify 'coverage' to enable code coverage build."
+ echo "Target ninja instead of make. ninja must be on the PATH."
+ echo "Pass additional arguments to CMake call."
+ exit 1
fi
# Set up the environment to be used for building with clang.
-if which "clang-$2.$3" > /dev/null 2>&1
- then
- export CC="$(which clang-$2.$3)"
- export CXX="$(which clang++-$2.$3)"
-elif which "clang$2$3" > /dev/null 2>&1
- then
- export CC="$(which clang$2$3)"
- export CXX="$(which clang++$2$3)"
-elif which clang > /dev/null 2>&1
- then
- export CC="$(which clang)"
- export CXX="$(which clang++)"
+if hash "clang-$2.$3" 2>/dev/null; then
+ export CC="clang-$2.$3"
+ export CXX="clang++-$2.$3"
+elif hash "clang$2$3" 2>/dev/null; then
+ export CC="clang$2$3"
+ export CXX="clang++$2$3"
+elif hash clang 2>/dev/null; then
+ export CC="clang"
+ export CXX="clang++"
else
- echo "Unable to find Clang Compiler"
+ echo "Unable to find Clang compiler"
exit 1
fi
OS=`uname`
# Locate llvm
-# This can be a little complicated, because the common use-case of Ubuntu with
+#
+# This can be a little complicated, because the common use case of Ubuntu with
# llvm-3.5 installed uses a rather unusual llvm installation with the version
-# number postfixed (i.e. llvm-ar-3.5), so we check for that first.
-# On FreeBSD the version number is appended without point and dash (i.e.
-# llvm-ar35).
-# Additionally, OSX doesn't use the llvm- prefix.
+# number postfixed (e.g. llvm-ar-3.5), so we check for that first.
+#
+# On FreeBSD, the version number is appended to the name without the dot and
+# the dash (e.g. llvm-ar35).
+#
+# OS X doesn't use the llvm- prefix.
if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then
- llvm_prefix="llvm-"
+ llvm_prefix="llvm-"
elif [ $OS = "Darwin" ]; then
- llvm_prefix=""
+ llvm_prefix=""
else
- echo "Unable to determine build platform"
- exit 1
+ echo "Unable to determine build platform"
+ exit 1
fi
desired_llvm_major_version=$2
elif [ $OS = "SunOS" ]; then
desired_llvm_version=""
else
- desired_llvm_version="-$desired_llvm_major_version.$desired_llvm_minor_version"
+ desired_llvm_version="-$desired_llvm_major_version.$desired_llvm_minor_version"
fi
-locate_llvm_exec() {
- if which "$llvm_prefix$1$desired_llvm_version" > /dev/null 2>&1
- then
- echo "$(which $llvm_prefix$1$desired_llvm_version)"
- elif which "$llvm_prefix$1" > /dev/null 2>&1
- then
- echo "$(which $llvm_prefix$1)"
- else
- exit 1
- fi
+
+locate_llvm_exec()
+{
+ if hash "$llvm_prefix$1$desired_llvm_version" 2>/dev/null; then
+ echo "$(command -v $llvm_prefix$1$desired_llvm_version)"
+ elif hash "$llvm_prefix$1" 2>/dev/null; then
+ echo "$(command -v $llvm_prefix$1)"
+ else
+ exit 1
+ fi
}
llvm_ar="$(locate_llvm_exec ar)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; }
+
llvm_link="$(locate_llvm_exec link)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; }
+
llvm_nm="$(locate_llvm_exec nm)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; }
+
if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then
llvm_objdump="$(locate_llvm_exec objdump)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; }