summaryrefslogtreecommitdiff
path: root/clang/do_clang
blob: 364e2ced1a001cf77307b3f6ea3578e22e0b410d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/sh
#
#  This script automates running clang-analyzer on RTEMS.
# 
# NOTE:
#    + clang/scan does not support -B option so no code which needs bsp.h
#    + clang/scan has bug about embedded space in RHS of -D option.
# 

#
# TODO:
#   + parse arguments for some of the hard-coded items.
#   + better instructions on setup. Where to download, etc.
#

OUTPUTDIR=/home/joel/rtems-4.11-work/build/clang/output
RTEMS_BIN=/opt/rtems-4.11/bin
RTEMS_TARGET=sparc-rtems4.11
RTEMS_BSP=sis
#RTEMS_TARGET=i386-rtems4.11
#RTEMS_BSP=pc386

#
#  Checks the status returned by executables and exits if it is non-zero.
#
check_fatal()
{
  if [ $1 -ne 0 ] ; then
    shift
    echo "ERROR: $*" >&2
    exit 1
  fi
}

type ${RTEMS_TARGET}-gcc
check_fatal $? "gcc not in path"

type scan-build >/dev/null 2>&1
check_fatal $? "scan-build not in PATH"

# How many jobs in parallel
if [ -r /usr/bin/getconf ] ; then
  cpus=`/usr/bin/getconf _NPROCESSORS_ONLN`
  cpus=`expr ${cpus} + 1`
else
  cpus=2
fi
# Clean build directory and start over
rm     -rf  b-clang-${RTEMS_TARGET}
check_fatal $? "Could not remove build directory"
mkdir  -p   b-clang-${RTEMS_TARGET}
check_fatal $? "Could not make build directory"
cd          b-clang-${RTEMS_TARGET}
check_fatal $? "Could not cd to build directory"

# Configure RTEMS
#$r/configure --target=${RTEMS_TARGET} --enable-multilib \
#  --disable-networking --disable-itron --disable-tests \
#  --enable-rtemsbsp=${RTEMS_BSP} >c.log 2>&1
$r/configure --target=${RTEMS_TARGET} --disable-multilib \
  --disable-networking --disable-itron --disable-tests \
  --enable-rtemsbsp=${RTEMS_BSP} >c.log 2>&1
check_fatal $? "could not configure RTEMS"

# Build RTEMS
BASE=`pwd`
#cd ${RTEMS_TARGET}/cpukit 
#check_fatal $? "could not cd ${RTEMS_TARGET}/cpukit"

scan-build -o ${OUTPUTDIR} --experimental-checks \
  --use-cc ${RTEMS_TARGET}-gcc \
  --use-c++ ${RTEMS_TARGET}-g++ \
  make -j${cpus} >${BASE}/b.log 2>&1
check_fatal $? "could not make RTEMS"

# Ran completed OK
exit 0