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