9c (3596B)
1 #!/bin/sh 2 3 test -f "$PLAN9/config" && . "$PLAN9/config" 4 usegcc() 5 { 6 cc=${CC9:-gcc} 7 cflags=" \ 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 -Wno-misleading-indentation \ 18 -Wno-stringop-truncation \ 19 -Wno-stringop-overflow \ 20 -Wno-format-truncation \ 21 -Wno-deprecated-pragma \ 22 -Wno-unused-but-set-variable \ 23 -Wno-deprecated-declarations \ 24 -fno-omit-frame-pointer \ 25 -fsigned-char \ 26 -fcommon \ 27 " 28 # want to put -fno-optimize-sibling-calls here but 29 # that option only works with gcc3+ it seems 30 cflags="$cflags -ggdb" 31 cflags="$cflags $CC9FLAGS" 32 } 33 34 quiet() 35 { 36 # The uniq at the end is for gcc's strcmp/etc. built-in nonsense, 37 # which multiplies single errors as a result of its expansion. 38 # The "Cursor. is deprecated" kills off warnings from Apple 39 # about using SetCursor/InitCursor. (Okay, they're deprecated, 40 # but you could at least tell us what to use instead, Apple!) 41 42 ignore=': error: .Each undeclared identifier' 43 ignore=$ignore'|: error: for each function it appears' 44 ignore=$ignore'|is dangerous, better use' 45 ignore=$ignore'|is almost always misused' 46 ignore=$ignore'|: In function ' 47 ignore=$ignore'|: At top level:' 48 ignore=$ignore'|support .long long.' 49 ignore=$ignore'|In file included from' 50 ignore=$ignore'| from' 51 ignore=$ignore'|use of C99 long long' 52 ignore=$ignore'|ISO C forbids conversion' 53 ignore=$ignore'|marked deprecated' 54 ignore=$ignore'|is deprecated' 55 ignore=$ignore'|warn_unused_result' 56 ignore=$ignore'|expanded from macro' 57 58 grep -v '__p9l_autolib_' "$1" | 59 egrep -v "$ignore" | 60 sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' | 61 $(which uniq) 1>&2 # avoid built-in uniq on SunOS 62 } 63 64 useclang() 65 { 66 cc=${CC9:-clang} 67 cflags=" \ 68 -O2 \ 69 -c \ 70 -Wall \ 71 -Wno-parentheses \ 72 -Wno-missing-braces \ 73 -Wno-switch \ 74 -Wno-comment \ 75 -Wno-sign-compare \ 76 -Wno-unknown-pragmas \ 77 -Wno-empty-body \ 78 -Wno-unused-value \ 79 -Wno-array-bounds \ 80 -Wno-gnu-designator \ 81 -Wno-array-bounds \ 82 -Wno-unneeded-internal-declaration \ 83 -Wno-deprecated-pragma \ 84 -Wno-unused-but-set-variable \ 85 -fsigned-char \ 86 -fno-caret-diagnostics \ 87 -fcommon \ 88 " 89 cflags="$cflags -g" 90 cflags="$cflags $CC9FLAGS" 91 } 92 93 usexlc() 94 { 95 cc=${CC9:-xlc_r} 96 cflags=" \ 97 -c \ 98 -O2 \ 99 -qmaxmem=-1 \ 100 -qsuppress=1506-236 \ 101 -qsuppress=1506-358 \ 102 -qsuppress=1500-010 \ 103 -qsuppress=1506-224 \ 104 -qsuppress=1506-1300 \ 105 -qsuppress=1506-342 \ 106 " 107 cflags="$cflags -g -qdbxextra -qfullpath" 108 cflags="$cflags $CC9FLAGS" 109 } 110 111 tag="${SYSNAME:-`uname`}-${CC9:-cc}" 112 case "$tag" in 113 *DragonFly*gcc*|*BSD*gcc*) usegcc ;; 114 *DragonFly*clang|*BSD*clang*) useclang ;; 115 *Darwin*) 116 useclang 117 cflags="$cflags -g3 -m64" 118 ;; 119 *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; 120 *Linux*) usegcc 121 case "${CC9:-gcc}" in 122 tcc) 123 cc=tcc 124 cflags="-c -g" 125 ;; 126 esac 127 ;; 128 *OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;; 129 *SunOS*-cc) cc=cc; 130 cflags="-mt -g -O -c -xCC -D__sun__" 131 u=`uname` 132 v=`uname -r` 133 s=`echo $u$v | tr '. ' '__'` 134 cflags="$cflags -D__${s}__" 135 ;; 136 *SunOS*-gcc) usegcc 137 u=`uname` 138 v=`uname -r` 139 s=`echo $u$v | tr '. ' '__'` 140 cflags="$cflags -g" 141 cflags="$cflags -D__sun__ -D__${s}__" 142 ;; 143 *AIX*) usexlc 144 cflags="$cflags -g -D__AIX__" 145 ;; 146 *) 147 echo 9c does not know how to compile on "$tag" 1>&2 148 exit 1 149 esac 150 151 # Must use temp file to avoid pipe; pipe loses status. 152 xtmp=${TMPDIR-/tmp}/9c.$$.$USER.out 153 $cc -DPLAN9PORT -I"$PLAN9/include" $cflags "$@" 2>"$xtmp" 154 status=$? 155 quiet "$xtmp" 156 rm -f "$xtmp" 157 exit $status