summaryrefslogtreecommitdiff
path: root/build_and_test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build_and_test.sh')
-rw-r--r--build_and_test.sh105
1 files changed, 69 insertions, 36 deletions
diff --git a/build_and_test.sh b/build_and_test.sh
index 627e062..873bacf 100644
--- a/build_and_test.sh
+++ b/build_and_test.sh
@@ -11,50 +11,83 @@ FLAG_OBJ="-c -o "
FLAG_EXE="-o "
LINK_FLAGS=
+if [ "$2" = "gcc" ]; then
+ COMPILE=gcc
+ COMPILEPP=g++
+elif [ "$2" = "clang" ]; then
+ COMPILE=clang
+ COMPILEPP=clang++
+elif [ "$2" = "msvc" ]; then
+ COMPILE=cl.exe
+ COMPILEPP=cl.exe
+ OBJ_POSTFIX=.obj
+ FLAG_OBJ="-c -Fo"
+ FLAG_EXE="-Fe"
+ LINK_FLAGS="Shlwapi.lib"
+elif [ "$2" != "" ]; then
+ echo "Unknown C compiler"
+ exit 1
+fi
+
+if [ "$2" != "" ]; then
+ if command -v $COMPILE >/dev/null 2>&1; then
+ echo "C compiler found"
+ else
+ echo "C compiler not found"
+ exit 1
+ fi
+fi
+
case $(uname | tr '[:upper:]' '[:lower:]') in
*darwin*)
- if command -v clang >/dev/null 2>&1; then
- echo "C compiler found - Clang"
- COMPILE=clang
- COMPILEPP=clang++
- elif command -v gcc >/dev/null 2>&1; then
- echo "C compiler found - GCC"
- else
- echo "C compiler not found"
- exit 1
+ if [ "$2" = "" ]; then
+ if command -v clang >/dev/null 2>&1; then
+ echo "C compiler found - Clang"
+ COMPILE=clang
+ COMPILEPP=clang++
+ elif command -v gcc >/dev/null 2>&1; then
+ echo "C compiler found - GCC"
+ else
+ echo "C compiler not found"
+ exit 1
+ fi
fi
;;
*msys*|*cygwin*|*mingw*|*nt*|*win*)
- if command -v cl.exe >/dev/null 2>&1; then
- echo "C compiler found - MSVC"
- COMPILE=cl.exe
- COMPILEPP=cl.exe
- OBJ_POSTFIX=.obj
- EXE_POSTFIX=.exe
- FLAG_OBJ="-c -Fo"
- FLAG_EXE="-Fe"
- LINK_FLAGS="Shlwapi.lib"
- elif command -v gcc >/dev/null 2>&1; then
- echo "C compiler found - GCC"
- elif command -v clang >/dev/null 2>&1; then
- echo "C compiler found - Clang"
- COMPILE=clang
- COMPILEPP=clang++
- else
- echo "C compiler not found"
- exit 1
+ EXE_POSTFIX=.exe
+ if [ "$2" = "" ]; then
+ if command -v cl.exe >/dev/null 2>&1; then
+ echo "C compiler found - MSVC"
+ COMPILE=cl.exe
+ COMPILEPP=cl.exe
+ OBJ_POSTFIX=.obj
+ FLAG_OBJ="-c -Fo"
+ FLAG_EXE="-Fe"
+ LINK_FLAGS="Shlwapi.lib"
+ elif command -v gcc >/dev/null 2>&1; then
+ echo "C compiler found - GCC"
+ elif command -v clang >/dev/null 2>&1; then
+ echo "C compiler found - Clang"
+ COMPILE=clang
+ COMPILEPP=clang++
+ else
+ echo "C compiler not found"
+ exit 1
+ fi
fi
;;
*)
- if command -v gcc >/dev/null 2>&1; then
- echo "C compiler found - GCC"
- elif command -v clang >/dev/null 2>&1; then
- echo "C compiler found - Clang"
- COMPILE=clang
- COMPILEPP=clang++
- else
- echo "C compiler not found"
- exit 1
+ if [ "$2" = "" ]; then
+ if command -v gcc >/dev/null 2>&1; then
+ echo "C compiler found - GCC"
+ elif command -v clang >/dev/null 2>&1; then
+ echo "C compiler found - Clang"
+ COMPILE=clang
+ COMPILEPP=clang++
+ else
+ echo "C compiler not found"
+ exit 1
+ fi
fi
;;
esac