blob: fcdae6fd845b51f1ca2e18e9f41d537abee0306c [file] [log] [blame]
rscdbd7b9a2003-11-23 18:29:08 +00001#!/bin/sh
2
rsceea5f6a2005-01-17 20:57:57 +00003test -f $PLAN9/config && . $PLAN9/config
rscdbd7b9a2003-11-23 18:29:08 +00004usegcc()
5{
6 cc=gcc
rsc8f314992004-03-02 17:34:15 +00007 ngflags=" \
rscdbd7b9a2003-11-23 18:29:08 +00008 -O2 \
rscdbd7b9a2003-11-23 18:29:08 +00009 -c \
rscdbd7b9a2003-11-23 18:29:08 +000010 -Wall \
11 -Wno-parentheses \
12 -Wno-missing-braces \
13 -Wno-switch \
rscd51419b2004-02-09 19:33:05 +000014 -Wno-comment \
rsc37652832003-11-25 02:36:46 +000015 -Wno-sign-compare \
wkj115d4c02004-05-03 17:26:17 +000016 -Wno-unknown-pragmas \
rscbe36ff62004-04-29 17:13:24 +000017 -fno-omit-frame-pointer \
rscdbd7b9a2003-11-23 18:29:08 +000018 "
rscbe36ff62004-04-29 17:13:24 +000019 # want to put -fno-optimize-sibling-calls here but
20 # that option only works with gcc3+ it seems
rscdc9d0ff2004-03-02 19:29:39 +000021 cflags="$ngflags -ggdb"
rscdbd7b9a2003-11-23 18:29:08 +000022}
23
rsc8f314992004-03-02 17:34:15 +000024tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}"
rscdbd7b9a2003-11-23 18:29:08 +000025case "$tag" in
rsc7033e492004-12-28 23:14:43 +000026*BSD*) usegcc ;;
rsc53dbac92004-03-02 16:58:49 +000027*Darwin*) usegcc
rsc8f314992004-03-02 17:34:15 +000028 cflags="$ngflags -g3 -no-cpp-precomp" ;;
rscdbd7b9a2003-11-23 18:29:08 +000029*HP-UX*) cc=cc; cflags="-g -O -c -Ae" ;;
rsc282c88f2004-09-17 22:09:31 +000030*Linux*) usegcc
rscead3e312005-01-04 21:13:58 +000031 case "${SYSVERSION:-`uname -r`}" in
rscfa267622004-12-24 07:12:30 +000032 2.6.*)
rsc282c88f2004-09-17 22:09:31 +000033 cflags="$cflags -D__Linux26__"
34 ;;
35 esac
36 ;;
rscdbd7b9a2003-11-23 18:29:08 +000037*OSF1*) cc=cc; cflags="-g -O -c" ;;
rsc0f192bb2004-03-26 05:01:11 +000038*SunOS*-cc) cc=cc;
rsc9e863cf2005-01-07 07:16:53 +000039 cflags="-mt -g -O -c -xCC -D__sun__"
rsc0f192bb2004-03-26 05:01:11 +000040 u=`uname`
rsc1b431b12004-03-26 05:05:33 +000041 v=`uname -r`
42 s=`echo $u$v | tr '. ' '__'`
43 cflags="$cflags -D__$s__"
rsc0f192bb2004-03-26 05:01:11 +000044 ;;
45*SunOS*-gcc) usegcc
46 u=`uname`
rsc1b431b12004-03-26 05:05:33 +000047 v=`uname -r`
48 s=`echo $u$v | tr '. ' '__'`
rsc78802e62004-04-24 04:52:49 +000049 cflags="$ngflags -g"
rsc1b431b12004-03-26 05:05:33 +000050 cflags="$cflags -D__$s__"
rsc0f192bb2004-03-26 05:01:11 +000051 ;;
rscdbd7b9a2003-11-23 18:29:08 +000052*)
53 echo 9c does not know how to compile on "$tag" 1>&2
54 exit 1
55esac
56
rscead3e312005-01-04 21:13:58 +000057# N.B. Must use temp file to avoid pipe; pipe loses status.
58xtmp=/tmp/9c.$$.$USER.out
rscd756dc52005-01-07 07:15:31 +000059$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" >$xtmp 2>&1
60status=$?
61grep -v '__p9l_autolib_' $xtmp |
62sed 's/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g'
63rm -f $xtmp $xtmp.status
rscead3e312005-01-04 21:13:58 +000064exit $status