Blob


1 #!/bin/sh
3 test -f $PLAN9/config && . $PLAN9/config
4 usegcc()
5 {
6 cc=gcc
7 ngflags=" \
8 -O2 \
9 -c \
10 -Wall \
11 -Wno-parentheses \
12 -Wno-missing-braces \
13 -Wno-switch \
14 -Wno-comment \
15 -Wno-sign-compare \
16 -Wno-unknown-pragmas \
17 -fno-omit-frame-pointer \
18 "
19 # want to put -fno-optimize-sibling-calls here but
20 # that option only works with gcc3+ it seems
21 cflags="$ngflags -ggdb"
22 }
24 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}"
25 case "$tag" in
26 *BSD*) usegcc ;;
27 *Darwin*) usegcc
28 cflags="$ngflags -g3 -no-cpp-precomp" ;;
29 *HP-UX*) cc=cc; cflags="-g -O -c -Ae" ;;
30 *Linux*) usegcc
31 case "${SYSVERSION:-`uname -r`}" in
32 2.6.*)
33 cflags="$cflags -D__Linux26__"
34 ;;
35 esac
36 ;;
37 *OSF1*) cc=cc; cflags="-g -O -c" ;;
38 *SunOS*-cc) cc=cc;
39 cflags="-mt -g -O -c -xCC -D__sun__"
40 u=`uname`
41 v=`uname -r`
42 s=`echo $u$v | tr '. ' '__'`
43 cflags="$cflags -D__${s}__"
44 ;;
45 *SunOS*-gcc) usegcc
46 u=`uname`
47 v=`uname -r`
48 s=`echo $u$v | tr '. ' '__'`
49 cflags="$ngflags -g"
50 cflags="$cflags -D__${s}__"
51 ;;
52 *)
53 echo 9c does not know how to compile on "$tag" 1>&2
54 exit 1
55 esac
57 # N.B. Must use temp file to avoid pipe; pipe loses status.
58 # The uniq at the end is for gcc's strcmp/etc. built-in nonsense,
59 # which multiplies single errors as a result of its expansion.
60 xtmp=/tmp/9c.$$.$USER.out
61 $cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" >$xtmp 2>&1
62 status=$?
63 grep -v '__p9l_autolib_' $xtmp |
64 egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|: In function `|: At top level:' |
65 sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
66 uniq
67 rm -f $xtmp $xtmp.status
68 exit $status