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