d0cef6004335a9a9b6ad0a49923c384a4feaa3d8
[buftee] / tests / build.sh
1 #!/bin/bash
2 # Test building with different compilers.
3 # Copyright (c) 2013 Emil Mikulic <emikulic@gmail.com>
4 #
5 BOLD=$(tput bold)
6 NORMAL=$(tput sgr0)
7 RED=$(tput setf 9)
8 GRAY=$(tput setf 8)
9 RULER=${GRAY}$(for i in $(seq $(tput cols)); do echo -n -; done)${NORMAL}
10 notice() { echo "${BOLD}==> $*${NORMAL}"; }
11 fatal() { echo "${RED}==> FATAL: $*${NORMAL}" >&2; exit 1; }
12 report() {
13 local RET=$?
14 echo -n "${BOLD}==> $*: "
15 if [[ $RET = 0 ]]; then
16 echo success
17 else
18 echo "${RED}FAILURE"
19 fi
20 echo "${RULER}"
21 }
22
23 # Local hack:
24 MY_CLANG=$HOME/llvm/install/bin/clang
25 if [[ -z $CLANG ]]; then
26 # No CLANG env var set, try to guess.
27 if [[ -e $MY_CLANG ]]; then
28 CLANG=$MY_CLANG
29 else
30 CLANG=clang
31 fi
32 fi
33 if ! which $CLANG >/dev/null; then
34 fatal "can't find clang as [$CLANG]"
35 fi
36 notice "clang is [$CLANG]"
37
38 RUNDIR=$PWD
39 notice "[$0] run from [$RUNDIR]"
40 cd $RUNDIR || exit 1
41 SRCDIR=$(cd $(dirname $0)/..; pwd)
42 notice "src dir is [$SRCDIR]"
43 cd $SRCDIR || exit 1
44
45 notice build: standard
46 rm -f buftee
47 make
48 report build: standard
49
50 notice build: gcc with all the warnings
51 rm -f buftee
52 CFLAGS="-fdiagnostics-show-option --all-warnings --extra-warnings -O"
53 env CC=gcc "CFLAGS=$CFLAGS" make
54 report build: gcc with all the warnings
55
56 notice build: clang with all the warnings
57 rm -f buftee
58 env CC=$CLANG "CFLAGS=-Weverything" make
59 report build: clang
60
61 notice finished