aboutsummaryrefslogtreecommitdiff
path: root/bin/9c
blob: d7df56eba583637bd789aa3f1b6743f978973c40 (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

test -f $PLAN9/config && . $PLAN9/config
usegcc()
{
	cc=gcc
	ngflags=" \
		-O2 \
		-c \
		-Wall \
		-Wno-parentheses \
		-Wno-missing-braces \
		-Wno-switch \
		-Wno-comment \
		-Wno-sign-compare \
		-Wno-unknown-pragmas \
		-fno-omit-frame-pointer \
	"
	# want to put -fno-optimize-sibling-calls here but
	# that option only works with gcc3+ it seems
	cflags="$ngflags -ggdb"
}

tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}"
case "$tag" in
*BSD*)	usegcc ;;
*Darwin*)	usegcc 
		cflags="$ngflags -g3 -no-cpp-precomp" ;;
*HP-UX*)	cc=cc; cflags="-g -O -c -Ae" ;;
*Linux*)	usegcc 
		case "${CC9:-gcc}" in
		tcc)
			cc=tcc
			cflags="-c -g"
			;;
		esac
		case "${SYSVERSION:-`uname -r`}" in
		2.4.*)
			cflags="$cflags -D__Linux24__"
			;;
		2.6.*)
			cflags="$cflags -D__Linux26__"
			;;
		esac
		;;
*OSF1*)		cc=cc; cflags="-g -O -c" ;;
*SunOS*-cc)	cc=cc;
		cflags="-mt -g -O -c -xCC -D__sun__" 
		u=`uname`
		v=`uname -r`
		s=`echo $u$v | tr '. ' '__'`
		cflags="$cflags -D__${s}__"
		;;
*SunOS*-gcc)	usegcc
		u=`uname`
		v=`uname -r`
		s=`echo $u$v | tr '. ' '__'`
		cflags="$ngflags -g"
		cflags="$cflags -D__${s}__"
		;;
*)
	echo 9c does not know how to compile on "$tag" 1>&2
	exit 1
esac

# N.B. Must use temp file to avoid pipe; pipe loses status.
# The uniq at the end is for gcc's strcmp/etc. built-in nonsense,
# which multiplies single errors as a result of its expansion.
xtmp=/tmp/9c.$$.$USER.out
$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp
status=$?
grep -v '__p9l_autolib_' $xtmp |
egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|In file included from|        from|use of C99 long long|ISO C forbids conversion' |
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
uniq 1>&2
rm -f $xtmp $xtmp.status
exit $status