Commit | Line | Data |
---|---|---|
959f3c4c JH |
1 | ?RCS: $Id: Cppsym.U,v 3.0.1.5 1995/05/12 11:59:11 ram Exp $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi | |
4 | ?RCS: | |
5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, | |
6 | ?RCS: as specified in the README file that comes with the distribution. | |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root | |
9 | ?RCS: of the source tree for dist 3.0. | |
10 | ?RCS: | |
11 | ?RCS: $Log: Cppsym.U,v $ | |
12 | ?RCS: Revision 3.0.1.5 1995/05/12 11:59:11 ram | |
13 | ?RCS: patch54: split awk command onto two lines for older awks (ADO) | |
14 | ?RCS: | |
15 | ?RCS: Revision 3.0.1.4 1995/01/11 14:55:57 ram | |
16 | ?RCS: patch45: new cc vs. cpp symbol checking suggested by JHI | |
17 | ?RCS: patch45: added more cpp symbols (JHI) | |
18 | ?RCS: | |
19 | ?RCS: Revision 3.0.1.3 1994/10/29 15:51:32 ram | |
20 | ?RCS: patch36: added ?F: line for metalint file checking | |
21 | ?RCS: patch36: new symbols ardent and titan (ADO) | |
22 | ?RCS: | |
23 | ?RCS: Revision 3.0.1.2 1994/06/20 06:53:32 ram | |
24 | ?RCS: patch30: extended cpp symbol lookup list (JHI) | |
25 | ?RCS: patch30: renamed attrlist symbol into al for brevity | |
26 | ?RCS: | |
27 | ?RCS: Revision 3.0.1.1 1993/12/15 08:14:14 ram | |
28 | ?RCS: patch15: added new cpp symbols __bsdi__ and BSD_NET2 | |
29 | ?RCS: | |
30 | ?RCS: Revision 3.0 1993/08/18 12:04:50 ram | |
31 | ?RCS: Baseline for dist 3.0 netwide release. | |
32 | ?RCS: | |
33 | ?X: | |
34 | ?X: This unit produces a shell script called Cppsym, which can be used to | |
35 | ?X: determine whether any in a list of symbols is defined by the C compilation | |
36 | ?X: chain (C preprocessor symbols plus C compiler native ones). | |
37 | ?X: It can determine the status of any symbol, though the symbols in $al | |
38 | ?X: are more easily determined. If you want to add to $al you can do | |
39 | ?X: it in Myinit.U. | |
40 | ?X: | |
41 | ?MAKE:Cppsym ccsymbols cppsymbols cppccsymbols: \ | |
42 | eunicefix Guess cppstdin awk cat tr sed sort grep rm startsh osname \ | |
43 | contains cppminus +cc +gccversion test comm uniq echo n c Options trnl | |
44 | ?MAKE: -pick add $@ %< | |
45 | ?F:./Cppsym | |
46 | ?T:sym list unknown status also symbols i postprocess_cc_v | |
47 | ?V:al | |
48 | ?X: | |
49 | ?X: The symbol list is in alpha order for ease of maintenance... | |
50 | ?X: | |
51 | ?X: Lots of new symbols (mostly rummaged from gcc), courtesy of | |
52 | ?X: Jarkko Hietaniemi <jhi@snakemail.hut.fi> -- RAM, 06/06/94 | |
53 | ?X: | |
54 | ?INIT:: list of known cpp symbols, sorted alphabetically | |
55 | ?INIT:al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2" | |
56 | ?INIT:al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH" | |
57 | ?INIT:al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS" | |
58 | ?INIT:al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM" | |
59 | ?INIT:al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX" | |
60 | ?INIT:al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX" | |
61 | ?INIT:al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4" | |
62 | ?INIT:al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300" | |
63 | ?INIT:al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek" | |
64 | ?INIT:al="$al VMS Xenix286" | |
65 | ?INIT:al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI" | |
66 | ?INIT:al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER" | |
67 | ?INIT:al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3" | |
68 | ?INIT:al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000" | |
69 | ?INIT:al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4" | |
70 | ?INIT:al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS" | |
71 | ?INIT:al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__" | |
72 | ?INIT:al="$al __DGUX__ __DPX2__ __H3050R __H3050RX" | |
73 | ?INIT:al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__" | |
74 | ?INIT:al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__" | |
75 | ?INIT:al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__" | |
76 | ?INIT:al="$al __SVR4_2__ __UMAXV__" | |
77 | ?INIT:al="$al ____386BSD____ __alpha __alpha__ __amiga" | |
78 | ?INIT:al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__" | |
79 | ?INIT:al="$al __host_mips__" | |
80 | ?INIT:al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500" | |
81 | ?INIT:al="$al __hp9000s500 __hp9000s700 __hp9000s800" | |
82 | ?INIT:al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__" | |
83 | ?INIT:al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__" | |
84 | ?INIT:al="$al __m68k __m68k__ __m88100__ __m88k __m88k__" | |
85 | ?INIT:al="$al __mc68000 __mc68000__ __mc68020 __mc68020__" | |
86 | ?INIT:al="$al __mc68030 __mc68030__ __mc68040 __mc68040__" | |
87 | ?INIT:al="$al __mc88100 __mc88100__ __mips __mips__" | |
88 | ?INIT:al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__" | |
89 | ?INIT:al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__" | |
90 | ?INIT:al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__" | |
91 | ?INIT:al="$al _host_mips _mips _unix" | |
92 | ?INIT:al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent" | |
93 | ?INIT:al="$al apollo ardent att386 att3b" | |
94 | ?INIT:al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull" | |
95 | ?INIT:al="$al cadmus clipper concurrent convex cray ctix" | |
96 | ?INIT:al="$al dmert encore gcos gcx gimpel gould" | |
97 | ?INIT:al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800" | |
98 | ?INIT:al="$al hp9000 hp9000s300 hp9000s400 hp9000s500" | |
99 | ?INIT:al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux" | |
100 | ?INIT:al="$al i186 i286 i386 i486 i8086" | |
101 | ?INIT:al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k" | |
102 | ?INIT:al="$al ksr1 linux luna luna88k m68k m88100 m88k" | |
103 | ?INIT:al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030" | |
104 | ?INIT:al="$al mc68040 mc68060 mc68k mc68k32 mc700" | |
105 | ?INIT:al="$al mc88000 mc88100 merlin mert mips mvs n16" | |
106 | ?INIT:al="$al ncl_el ncl_mr" | |
107 | ?INIT:al="$al news1500 news1700 news1800 news1900 news3700" | |
108 | ?INIT:al="$al news700 news800 news900 ns16000 ns32000" | |
109 | ?INIT:al="$al ns32016 ns32332 ns32k nsc32000 os osf" | |
110 | ?INIT:al="$al parisc pc532 pdp11 plexus posix pyr" | |
111 | ?INIT:al="$al riscix riscos scs sequent sgi sinix sony sony_news" | |
112 | ?INIT:al="$al sonyrisc sparc sparclite spectrum stardent stratos" | |
113 | ?INIT:al="$al sun sun3 sun386 svr4 sysV68 sysV88" | |
114 | ?INIT:al="$al titan tower tower32 tower32_200 tower32_600 tower32_700" | |
115 | ?INIT:al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200" | |
116 | ?INIT:al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms" | |
117 | ?INIT:al="$al xenix z8000" | |
118 | ?INIT: | |
119 | ?S:ccsymbols: | |
120 | ?S: The variable contains the symbols defined by the C compiler alone. | |
121 | ?S: The symbols defined by cpp or by cc when it calls cpp are not in | |
122 | ?S: this list, see cppsymbols and cppccsymbols. | |
123 | ?S: The list is a space-separated list of symbol=value tokens. | |
124 | ?S:. | |
125 | ?S:cppsymbols: | |
126 | ?S: The variable contains the symbols defined by the C preprocessor | |
127 | ?S: alone. The symbols defined by cc or by cc when it calls cpp are | |
128 | ?S: not in this list, see ccsymbols and cppccsymbols. | |
129 | ?S: The list is a space-separated list of symbol=value tokens. | |
130 | ?S:. | |
131 | ?S:cppccsymbols: | |
132 | ?S: The variable contains the symbols defined by the C compiler when | |
133 | ?S: when it calls cpp. The symbols defined by the cc alone or cpp | |
134 | ?S: alone are not in this list, see ccsymbols and cppsymbols. | |
135 | ?S: The list is a space-separated list of symbol=value tokens. | |
136 | ?S:. | |
137 | ?F:!Cppsym.true | |
138 | ?F:!ccsym.com | |
139 | ?F:!ccsym.cpp | |
140 | ?F:!ccsym.own | |
141 | : get C preprocessor symbols handy | |
142 | echo " " | |
143 | $echo $n "Hmm... $c" | |
144 | ?X: The following used to be tr '[ - ]' ... but this was rejected by AIX 3.2 | |
145 | ?X: since the endpoints where the same (from patch 12u8 to patch). | |
146 | echo $al | $tr ' ' $trnl >Cppsym.know | |
147 | $cat <<EOSS >Cppsym | |
148 | $startsh | |
149 | case "\$1" in | |
150 | -l) list=true | |
151 | shift | |
152 | ;; | |
153 | esac | |
154 | unknown='' | |
155 | case "\$list\$#" in | |
156 | 1|2) | |
157 | for sym do | |
158 | if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then | |
159 | exit 0 | |
160 | elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then | |
161 | : | |
162 | else | |
163 | unknown="\$unknown \$sym" | |
164 | fi | |
165 | done | |
166 | set X \$unknown | |
167 | shift | |
168 | ;; | |
169 | esac | |
170 | case \$# in | |
171 | 0) exit 1;; | |
172 | esac | |
173 | echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\ | |
174 | #ifdef \1\\ | |
175 | exit 0; _ _ _ _\1\\ \1\\ | |
176 | #endif\\ | |
177 | /' >Cppsym\$\$ | |
178 | echo "exit 1; _ _ _" >>Cppsym\$\$ | |
179 | $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _' >Cppsym2\$\$ | |
180 | case "\$list" in | |
181 | true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;; | |
182 | *) | |
183 | sh Cppsym2\$\$ | |
184 | status=\$? | |
185 | ;; | |
186 | esac | |
187 | $rm -f Cppsym\$\$ Cppsym2\$\$ | |
188 | exit \$status | |
189 | EOSS | |
190 | chmod +x Cppsym | |
191 | $eunicefix Cppsym | |
192 | ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true | |
193 | ||
194 | : now check the C compiler for additional symbols | |
195 | ?X: suggested by Jarkko Hietaniemi <jhi@snakemail.hut.fi>, thanks! | |
196 | postprocess_cc_v='' | |
197 | case "$osname" in | |
198 | aix) postprocess_cc_v="|$tr , ' '" ;; | |
199 | esac | |
200 | $cat >ccsym <<EOS | |
201 | $startsh | |
202 | $cat >tmp.c <<EOF | |
203 | extern int foo; | |
204 | EOF | |
205 | for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\` | |
206 | do | |
207 | case "\$i" in | |
208 | -D*) echo "\$i" | $sed 's/^-D//';; | |
209 | -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';; | |
210 | esac | |
211 | done | |
212 | $rm -f try.c | |
213 | EOS | |
214 | postprocess_cc_v='' | |
215 | chmod +x ccsym | |
216 | $eunicefix ccsym | |
217 | ./ccsym > ccsym1.raw | |
218 | ?X: AIX complains if $uniq is passed an empty file. ($sort apparently | |
219 | ?X: doesn't care.) --AD 14 July 1998 | |
220 | if $test -s ccsym1.raw; then | |
221 | $sort ccsym1.raw | $uniq >ccsym.raw | |
222 | else | |
223 | mv ccsym1.raw ccsym.raw | |
224 | fi | |
225 | ||
226 | ?X: canonicalize symbols for easier sort/uniq/comm usage: append =1 if no = sign | |
227 | ?X: the awk script must be on two lines for older awk programs, sigh! -- ADO | |
228 | $awk '/\=/ { print $0; next } | |
229 | { print $0"=1" }' ccsym.raw >ccsym.list | |
230 | $awk '{ print $0"=1" }' Cppsym.true >ccsym.true | |
231 | $comm -13 ccsym.true ccsym.list >ccsym.own | |
232 | $comm -12 ccsym.true ccsym.list >ccsym.com | |
233 | $comm -23 ccsym.true ccsym.list >ccsym.cpp | |
234 | also='' | |
235 | if $test -z ccsym.raw; then | |
236 | echo "Your C compiler doesn't seem to define any symbols!" >&4 | |
237 | echo " " | |
238 | echo "However, your C preprocessor defines the following symbols:" | |
239 | $cat Cppsym.true | |
240 | ccsymbols='' | |
241 | cppsymbols=`$cat Cppsym.true` | |
242 | cppsymbols=`echo $cppsymbols` | |
243 | cppccsymbols="$cppsymbols" | |
244 | else | |
245 | if $test -s ccsym.com; then | |
246 | echo "Your C compiler and pre-processor define these symbols:" | |
247 | $sed -e 's/\(.*\)=.*/\1/' ccsym.com | |
248 | also='also ' | |
249 | symbols='ones' | |
250 | cppccsymbols=`$cat ccsym.com` | |
251 | cppccsymbols=`echo $cppccsymbols` | |
252 | $test "$silent" || sleep 1 | |
253 | fi | |
254 | if $test -s ccsym.cpp; then | |
255 | $test "$also" && echo " " | |
256 | echo "Your C pre-processor ${also}defines the following symbols:" | |
257 | $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp | |
258 | also='further ' | |
259 | cppsymbols=`$cat ccsym.cpp` | |
260 | cppsymbols=`echo $cppsymbols` | |
261 | $test "$silent" || sleep 1 | |
262 | fi | |
263 | if $test -s ccsym.own; then | |
264 | $test "$also" && echo " " | |
265 | echo "Your C compiler ${also}defines the following cpp symbols:" | |
266 | $sed -e 's/\(.*\)=1/\1/' ccsym.own | |
267 | $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true | |
268 | ccsymbols=`$cat ccsym.own` | |
269 | ccsymbols=`echo $ccsymbols` | |
270 | $test "$silent" || sleep 1 | |
271 | fi | |
272 | fi | |
273 | $rm -f ccsym* | |
274 |