| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 test -f $PLAN9/config && . $PLAN9/config | 3 test -f $PLAN9/config && . $PLAN9/config |
| 4 usegcc() | 4 usegcc() |
| 5 { | 5 { |
| 6 » cc=gcc | 6 » cc=${CC9:-gcc} |
| 7 ngflags=" \ | 7 ngflags=" \ |
| 8 -O2 \ | 8 -O2 \ |
| 9 -c \ | 9 -c \ |
| 10 -Wall \ | 10 -Wall \ |
| 11 -Wno-parentheses \ | 11 -Wno-parentheses \ |
| 12 -Wno-missing-braces \ | 12 -Wno-missing-braces \ |
| 13 -Wno-switch \ | 13 -Wno-switch \ |
| 14 -Wno-comment \ | 14 -Wno-comment \ |
| 15 -Wno-sign-compare \ | 15 -Wno-sign-compare \ |
| 16 -Wno-unknown-pragmas \ | 16 -Wno-unknown-pragmas \ |
| 17 -fno-omit-frame-pointer \ | 17 -fno-omit-frame-pointer \ |
| 18 " | 18 " |
| 19 # want to put -fno-optimize-sibling-calls here but | 19 # want to put -fno-optimize-sibling-calls here but |
| 20 # that option only works with gcc3+ it seems | 20 # that option only works with gcc3+ it seems |
| 21 cflags="$ngflags -ggdb" | 21 cflags="$ngflags -ggdb" |
| 22 } | 22 } |
| 23 | 23 |
| 24 weedgcc() |
| 25 { |
| 26 # The uniq at the end is for gcc's strcmp/etc. built-in nonsense, |
| 27 # which multiplies single errors as a result of its expansion. |
| 28 # The "Cursor. is deprecated" kills off warnings from Apple |
| 29 # about using SetCursor/InitCursor. (Okay, they're deprecated, |
| 30 # but you could at least tell us what to use instead, Apple!) |
| 31 |
| 32 ignore=': error: .Each undeclared identifier' |
| 33 ignore=$ignore'|: error: for each function it appears' |
| 34 ignore=$ignore'|is dangerous, better use' |
| 35 ignore=$ignore'|is almost always misused' |
| 36 ignore=$ignore'|: In function ' |
| 37 ignore=$ignore'|: At top level:' |
| 38 ignore=$ignore'|support .long long.' |
| 39 ignore=$ignore'|In file included from' |
| 40 ignore=$ignore'| from' |
| 41 ignore=$ignore'|use of C99 long long' |
| 42 ignore=$ignore'|ISO C forbids conversion' |
| 43 ignore=$ignore'|is deprecated' |
| 44 ignore=$ignore'|warn_unused_result' |
| 45 |
| 46 grep -v '__p9l_autolib_' $1 | |
| 47 egrep -v "$ignore" | |
| 48 sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([ 0-9][0-9]*\)/\1:\2/g' | |
| 49 uniq 1>&2 |
| 50 } |
| 51 |
| 52 useclang() |
| 53 { |
| 54 cc=${CC9:-clang} |
| 55 ngflags=" \ |
| 56 -O2 \ |
| 57 -c \ |
| 58 -Wall \ |
| 59 -Wno-comment \ |
| 60 -Wno-empty-body \ |
| 61 -Wno-parentheses \ |
| 62 -Wno-unknown-pragmas \ |
| 63 -Wno-unused-value \ |
| 64 " |
| 65 cflags="$ngflags -g" |
| 66 } |
| 67 |
| 24 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" | 68 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" |
| 25 case "$tag" in | 69 case "$tag" in |
| 70 *FreeBSD*gcc*) usegcc ;; |
| 71 *FreeBSD*clang*) useclang ;; |
| 26 *BSD*) usegcc ;; | 72 *BSD*) usegcc ;; |
| 27 *Darwin*) usegcc· | 73 *Darwin*) usegcc· |
| 28 cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; | 74 cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; |
| 29 *HP-UX*)» cc=cc; cflags="-g -O -c -Ae" ;; | 75 *HP-UX*)» cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; |
| 30 *Linux*) usegcc· | 76 *Linux*) usegcc· |
| 31 case "${CC9:-gcc}" in | 77 case "${CC9:-gcc}" in |
| 32 tcc) | 78 tcc) |
| 33 cc=tcc | 79 cc=tcc |
| 34 cflags="-c -g" | 80 cflags="-c -g" |
| 35 ;; | 81 ;; |
| 36 esac | 82 esac |
| 37 case "${SYSVERSION:-`uname -r`}" in | 83 case "${SYSVERSION:-`uname -r`}" in |
| 38 2.4.*) | 84 2.4.*) |
| 39 cflags="$cflags -D__Linux24__" | 85 cflags="$cflags -D__Linux24__" |
| 40 ;; | 86 ;; |
| 41 2.6.*) | 87 2.6.*) |
| 42 cflags="$cflags -D__Linux26__" | 88 cflags="$cflags -D__Linux26__" |
| 43 ;; | 89 ;; |
| 44 esac | 90 esac |
| 45 ;; | 91 ;; |
| 46 *OSF1*)»» cc=cc; cflags="-g -O -c" ;; | 92 *OSF1*)»» cc=${CC9:-cc}; cflags="-g -O -c" ;; |
| 47 *SunOS*-cc) cc=cc; | 93 *SunOS*-cc) cc=cc; |
| 48 cflags="-mt -g -O -c -xCC -D__sun__"· | 94 cflags="-mt -g -O -c -xCC -D__sun__"· |
| 49 u=`uname` | 95 u=`uname` |
| 50 v=`uname -r` | 96 v=`uname -r` |
| 51 s=`echo $u$v | tr '. ' '__'` | 97 s=`echo $u$v | tr '. ' '__'` |
| 52 cflags="$cflags -D__${s}__" | 98 cflags="$cflags -D__${s}__" |
| 53 ;; | 99 ;; |
| 54 *SunOS*-gcc) usegcc | 100 *SunOS*-gcc) usegcc |
| 55 u=`uname` | 101 u=`uname` |
| 56 v=`uname -r` | 102 v=`uname -r` |
| 57 s=`echo $u$v | tr '. ' '__'` | 103 s=`echo $u$v | tr '. ' '__'` |
| 58 cflags="$ngflags -g" | 104 cflags="$ngflags -g" |
| 59 cflags="$cflags -D__sun__ -D__${s}__" | 105 cflags="$cflags -D__sun__ -D__${s}__" |
| 60 ;; | 106 ;; |
| 61 *AIX*) usegcc | 107 *AIX*) usegcc |
| 62 cflags="$ngflags -g -D__AIX__" | 108 cflags="$ngflags -g -D__AIX__" |
| 63 ;; | 109 ;; |
| 64 *) | 110 *) |
| 65 echo 9c does not know how to compile on "$tag" 1>&2 | 111 echo 9c does not know how to compile on "$tag" 1>&2 |
| 66 exit 1 | 112 exit 1 |
| 67 esac | 113 esac |
| 68 | 114 |
| 69 # N.B. Must use temp file to avoid pipe; pipe loses status. | 115 # N.B. Must use temp file to avoid pipe; pipe loses status. |
| 70 # The uniq at the end is for gcc's strcmp/etc. built-in nonsense, | |
| 71 # which multiplies single errors as a result of its expansion. | |
| 72 # The "Cursor. is deprecated" kills off warnings from Apple | |
| 73 # about using SetCursor/InitCursor. (Okay, they're deprecated, | |
| 74 # but you could at least tell us what to use instead, Apple!) | |
| 75 xtmp=/tmp/9c.$$.$USER.out | 116 xtmp=/tmp/9c.$$.$USER.out |
| 76 $cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp | 117 $cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp |
| 77 status=$? | 118 status=$? |
| 78 grep -v '__p9l_autolib_' $xtmp | | 119 |
| 79 egrep -v ': error: .Each undeclared identifier|: error: for each function it app ears|is dangerous, better use|is almost always misused|: In function |: At top l evel:|support .long long.|In file included from| from|use of C99 long lon g|ISO C forbids conversion|is deprecated|warn_unused_result' | | 120 case $cc in |
| 80 sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9 ]*\)/\1:\2/g' | | 121 *gcc*)» weedgcc $xtmp ;; |
| 81 uniq 1>&2 | 122 *)» cat $xtmp ;; |
| 123 esac |
| 124 |
| 82 rm -f $xtmp $xtmp.status | 125 rm -f $xtmp $xtmp.status |
| 83 exit $status | 126 exit $status |
| OLD | NEW |