1#!/bin/bash
2[ "$TRAVIS_CI" != "" ] && { [ -z "$(which scan-build)" ] && { echo "installing clang"; sudo apt-get install clang -y -qq; }; } || true
3
4if [ "$#" = "5" -a "$(echo $3 | grep -v 'makefile[.]')" = "" ]; then
5    echo "only run $0 for the regular makefile, early exit success"
6    exit 0
7fi
8
9# output version
10bash printinfo.sh
11
12make clean > /dev/null
13
14scan_build=$(which scan-build)
15[ -z "$scan_build" ] && scan_build=$(find /usr/bin/ -name 'scan-build-*' | sort -nr | head -n1) || true
16[ -z "$scan_build" ] && { echo "couldn't find clang scan-build"; exit 1; } || echo "run $scan_build"
17export CFLAGS="-DUSE_LTM -DLTM_DESC -I/usr/include"
18export EXTRALIBS="-ltommath"
19$scan_build --status-bugs make -f makefile.unix all CFLAGS="$CFLAGS" EXTRALIBS="$EXTRALIBS"
20