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 | |
b163fa82 | 55 | ?INIT:al="a29k ABI64 aegis AES_SOURCE AIX AIX32 AIX370" |
8a77dbe2 JH |
56 | ?INIT:al="$al AIX41 AIX42 AIX43 AIX_SOURCE aixpc ALL_SOURCE" |
57 | ?INIT:al="$al alliant alpha am29000 AM29000 amiga AMIGAOS AMIX" | |
58 | ?INIT:al="$al ansi ANSI_C_SOURCE apollo ardent atarist att386 att3b BeOS" | |
59 | ?INIT:al="$al BIG_ENDIAN BIT_MSF bsd BSD bsd43 bsd4_2 bsd4_3 BSD4_3 bsd4_4" | |
60 | ?INIT:al="$al BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES BSDCOMPAT bsdi" | |
61 | ?INIT:al="$al bull c cadmus clipper CMU COFF COMPILER_VERSION" | |
62 | ?INIT:al="$al concurrent convex cpu cray CRAY CRAYMPP ctix CX_UX" | |
63 | ?INIT:al="$al CYGWIN DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO" | |
64 | ?INIT:al="$al Dynix DynixPTX ELF encore EPI EXTENSIONS FILE_OFFSET_BITS" | |
65 | ?INIT:al="$al FreeBSD GCC_NEW_VARARGS gcos gcx gimpel" | |
66 | ?INIT:al="$al GNU_SOURCE GNUC GNUC_MINOR GO32 gould GOULD_PN" | |
67 | ?INIT:al="$al H3050R H3050RX hbullx20 hcx host_mips" | |
68 | ?INIT:al="$al hp200 hp300 hp700 HP700 hp800 hp9000" | |
69 | ?INIT:al="$al hp9000s200 hp9000s300 hp9000s400 hp9000s500" | |
70 | ?INIT:al="$al hp9000s700 hp9000s800 hp9k8 hp_osf hppa hpux HPUX_SOURCE" | |
71 | ?INIT:al="$al i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960" | |
72 | ?INIT:al="$al iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64" | |
73 | ?INIT:al="$al INLINE_INTRINSICS INTRINSICS INT64 interdata is68k ksr1" | |
74 | ?INIT:al="$al LANGUAGE_C LARGE_FILE_API LARGEFILE64_SOURCE" | |
75 | ?INIT:al="$al LARGEFILE_SOURCE LFS64_LARGEFILE LFS_LARGEFILE" | |
76 | ?INIT:al="$al Linux LITTLE_ENDIAN LONG64 LONG_DOUBLE LONG_LONG" | |
77 | ?INIT:al="$al LONGDOUBLE LONGLONG LP64 luna luna88k Lynx" | |
78 | ?INIT:al="$al M68000 m68k m88100 m88k M88KBCS_TARGET M_COFF" | |
79 | ?INIT:al="$al M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM M_SYS3" | |
80 | ?INIT:al="$al M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX MACH machine MachTen" | |
81 | ?INIT:al="$al MATH_HAS_NO_SIDE_EFFECTS" | |
82 | ?INIT:al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030 mc68040" | |
83 | ?INIT:al="$al mc68060 mc68k mc68k32 mc700 mc88000 mc88100 merlin" | |
84 | ?INIT:al="$al mert MiNT mips MIPS_FPSET MIPS_ISA MIPS_SIM MIPS_SZINT" | |
85 | ?INIT:al="$al MIPS_SZLONG MIPS_SZPTR MIPSEB MIPSEL MODERN_C motorola" | |
86 | ?INIT:al="$al mpeix MSDOS MTXINU MULTIMAX mvs MVS n16 ncl_el ncl_mr" | |
87 | ?INIT:al="$al NetBSD news1500 news1700 news1800 news1900 news3700" | |
88 | ?INIT:al="$al news700 news800 news900 NeXT NLS ns16000 ns32000" | |
89 | ?INIT:al="$al ns32016 ns32332 ns32k nsc32000" | |
90 | ?INIT:al="$al OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE" | |
91 | ?INIT:al="$al pa_risc PA_RISC1_1 PA_RISC2_0 PARAGON parisc" | |
92 | ?INIT:al="$al pc532 pdp11 PGC PIC plexus PORTAR posix" | |
93 | ?INIT:al="$al POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE" | |
94 | ?INIT:al="$al POSIX_C_SOURCE POSIX_SOURCE POWER" | |
95 | ?INIT:al="$al PROTOTYPES PWB pyr QNX R3000 REENTRANT RES Rhapsody RISC6000" | |
96 | ?INIT:al="$al riscix riscos RT scs SCO sequent sgi SGI_SOURCE sinix" | |
97 | ?INIT:al="$al SIZE_INT SIZE_LONG SIZE_PTR SOCKET_SOURCE SOCKETS_SOURCE" | |
98 | ?INIT:al="$al sony sony_news sonyrisc sparc sparclite spectrum" | |
99 | ?INIT:al="$al stardent stdc STDC_EXT stratos sun sun3 sun386" | |
100 | ?INIT:al="$al Sun386i svr3 svr4 SVR4_2 SVR4_SOURCE svr5" | |
101 | ?INIT:al="$al SX system SYSTYPE_BSD SYSTYPE_BSD43 SYSTYPE_BSD44" | |
102 | ?INIT:al="$al SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3 SYSV4 SYSV5" | |
103 | ?INIT:al="$al sysV68 sysV88 Tek4132 Tek4300 titan" | |
104 | ?INIT:al="$al tower tower32 tower32_200 tower32_600 tower32_700" | |
105 | ?INIT:al="$al tower32_800 tower32_850 tss" | |
106 | ?INIT:al="$al u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5" | |
107 | ?INIT:al="$al ultrix UMAXV UnicomPBB UnicomPBD UNICOS UNICOSMK" | |
108 | ?INIT:al="$al unix UNIX95 UNIX99 unixpc unos USGr4 USGr4_2" | |
109 | ?INIT:al="$al Utek UTek UTS UWIN uxpm uxps vax venix VMESA vms xenix Xenix286" | |
110 | ?INIT:al="$al XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2 XPG2_EXTENDED" | |
111 | ?INIT:al="$al XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED" | |
112 | ?INIT:al="$al z8000" | |
959f3c4c JH |
113 | ?INIT: |
114 | ?S:ccsymbols: | |
115 | ?S: The variable contains the symbols defined by the C compiler alone. | |
116 | ?S: The symbols defined by cpp or by cc when it calls cpp are not in | |
117 | ?S: this list, see cppsymbols and cppccsymbols. | |
118 | ?S: The list is a space-separated list of symbol=value tokens. | |
119 | ?S:. | |
120 | ?S:cppsymbols: | |
121 | ?S: The variable contains the symbols defined by the C preprocessor | |
122 | ?S: alone. The symbols defined by cc or by cc when it calls cpp are | |
123 | ?S: not in this list, see ccsymbols and cppccsymbols. | |
124 | ?S: The list is a space-separated list of symbol=value tokens. | |
125 | ?S:. | |
126 | ?S:cppccsymbols: | |
edd6115f | 127 | ?S: The variable contains the symbols defined by the C compiler |
959f3c4c JH |
128 | ?S: when it calls cpp. The symbols defined by the cc alone or cpp |
129 | ?S: alone are not in this list, see ccsymbols and cppsymbols. | |
130 | ?S: The list is a space-separated list of symbol=value tokens. | |
131 | ?S:. | |
132 | ?F:!Cppsym.true | |
133 | ?F:!ccsym.com | |
134 | ?F:!ccsym.cpp | |
135 | ?F:!ccsym.own | |
b163fa82 JH |
136 | ?T:startsym |
137 | ?T:stopsym | |
138 | ?T:symbols | |
959f3c4c JH |
139 | : get C preprocessor symbols handy |
140 | echo " " | |
ebebf7f4 | 141 | $echo "Guessing which symbols your C compiler and preprocessor define..." >&4 |
959f3c4c JH |
142 | ?X: The following used to be tr '[ - ]' ... but this was rejected by AIX 3.2 |
143 | ?X: since the endpoints where the same (from patch 12u8 to patch). | |
8a77dbe2 JH |
144 | echo $al $osname | $tr ' ' $trnl >Cppsym.know |
145 | ./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a | |
146 | ./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b | |
147 | cat Cppsym.a Cppsym.b >> Cppsym.know | |
148 | $sed 's/^/_/' < Cppsym.know > Cppsym.a | |
149 | $sed 's/^/__/' < Cppsym.know > Cppsym.b | |
150 | $sed 's/\(.*\)/__\1__/' < Cppsym.know > Cppsym.c | |
151 | $cat Cppsym.know Cppsym.a Cppsym.b Cppsym.c | sort | uniq > Cppsym.d | |
152 | mv Cppsym.d Cppsym.know | |
153 | rm Cppsym.? | |
959f3c4c JH |
154 | $cat <<EOSS >Cppsym |
155 | $startsh | |
156 | case "\$1" in | |
157 | -l) list=true | |
158 | shift | |
159 | ;; | |
160 | esac | |
161 | unknown='' | |
162 | case "\$list\$#" in | |
163 | 1|2) | |
164 | for sym do | |
165 | if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then | |
166 | exit 0 | |
167 | elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then | |
168 | : | |
169 | else | |
170 | unknown="\$unknown \$sym" | |
171 | fi | |
172 | done | |
173 | set X \$unknown | |
174 | shift | |
175 | ;; | |
176 | esac | |
177 | case \$# in | |
178 | 0) exit 1;; | |
179 | esac | |
180 | echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\ | |
181 | #ifdef \1\\ | |
182 | exit 0; _ _ _ _\1\\ \1\\ | |
183 | #endif\\ | |
184 | /' >Cppsym\$\$ | |
185 | echo "exit 1; _ _ _" >>Cppsym\$\$ | |
186 | $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _' >Cppsym2\$\$ | |
187 | case "\$list" in | |
188 | true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;; | |
189 | *) | |
190 | sh Cppsym2\$\$ | |
191 | status=\$? | |
192 | ;; | |
193 | esac | |
194 | $rm -f Cppsym\$\$ Cppsym2\$\$ | |
195 | exit \$status | |
196 | EOSS | |
197 | chmod +x Cppsym | |
198 | $eunicefix Cppsym | |
b163fa82 JH |
199 | $rm -f Cppsym.true |
200 | startsym=1 | |
201 | stopsym=500 | |
202 | symbols=`wc -l < Cppsym.know` | |
203 | while test $startsym -le $symbols | |
204 | do | |
205 | $sed -n "$startsym,$stopsym p" Cppsym.know > Cppsym.batch | |
206 | ./Cppsym -l `cat Cppsym.batch` | $sort | $grep -v '^$' >>Cppsym.true | |
207 | startsym=`expr $startsym + 500` | |
208 | stopsym=`expr $stopsym + 500` | |
209 | done | |
210 | $rm -f Cppsym.batch | |
959f3c4c JH |
211 | |
212 | : now check the C compiler for additional symbols | |
213 | ?X: suggested by Jarkko Hietaniemi <jhi@snakemail.hut.fi>, thanks! | |
214 | postprocess_cc_v='' | |
215 | case "$osname" in | |
216 | aix) postprocess_cc_v="|$tr , ' '" ;; | |
217 | esac | |
218 | $cat >ccsym <<EOS | |
219 | $startsh | |
220 | $cat >tmp.c <<EOF | |
221 | extern int foo; | |
222 | EOF | |
223 | for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\` | |
224 | do | |
225 | case "\$i" in | |
226 | -D*) echo "\$i" | $sed 's/^-D//';; | |
227 | -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';; | |
228 | esac | |
229 | done | |
230 | $rm -f try.c | |
231 | EOS | |
232 | postprocess_cc_v='' | |
233 | chmod +x ccsym | |
234 | $eunicefix ccsym | |
235 | ./ccsym > ccsym1.raw | |
236 | ?X: AIX complains if $uniq is passed an empty file. ($sort apparently | |
237 | ?X: doesn't care.) --AD 14 July 1998 | |
238 | if $test -s ccsym1.raw; then | |
239 | $sort ccsym1.raw | $uniq >ccsym.raw | |
240 | else | |
241 | mv ccsym1.raw ccsym.raw | |
242 | fi | |
243 | ||
244 | ?X: canonicalize symbols for easier sort/uniq/comm usage: append =1 if no = sign | |
245 | ?X: the awk script must be on two lines for older awk programs, sigh! -- ADO | |
246 | $awk '/\=/ { print $0; next } | |
247 | { print $0"=1" }' ccsym.raw >ccsym.list | |
248 | $awk '{ print $0"=1" }' Cppsym.true >ccsym.true | |
249 | $comm -13 ccsym.true ccsym.list >ccsym.own | |
250 | $comm -12 ccsym.true ccsym.list >ccsym.com | |
251 | $comm -23 ccsym.true ccsym.list >ccsym.cpp | |
252 | also='' | |
253 | if $test -z ccsym.raw; then | |
254 | echo "Your C compiler doesn't seem to define any symbols!" >&4 | |
255 | echo " " | |
256 | echo "However, your C preprocessor defines the following symbols:" | |
257 | $cat Cppsym.true | |
258 | ccsymbols='' | |
259 | cppsymbols=`$cat Cppsym.true` | |
260 | cppsymbols=`echo $cppsymbols` | |
261 | cppccsymbols="$cppsymbols" | |
262 | else | |
263 | if $test -s ccsym.com; then | |
264 | echo "Your C compiler and pre-processor define these symbols:" | |
265 | $sed -e 's/\(.*\)=.*/\1/' ccsym.com | |
266 | also='also ' | |
267 | symbols='ones' | |
268 | cppccsymbols=`$cat ccsym.com` | |
269 | cppccsymbols=`echo $cppccsymbols` | |
270 | $test "$silent" || sleep 1 | |
271 | fi | |
272 | if $test -s ccsym.cpp; then | |
273 | $test "$also" && echo " " | |
274 | echo "Your C pre-processor ${also}defines the following symbols:" | |
275 | $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp | |
276 | also='further ' | |
277 | cppsymbols=`$cat ccsym.cpp` | |
278 | cppsymbols=`echo $cppsymbols` | |
279 | $test "$silent" || sleep 1 | |
280 | fi | |
281 | if $test -s ccsym.own; then | |
282 | $test "$also" && echo " " | |
283 | echo "Your C compiler ${also}defines the following cpp symbols:" | |
284 | $sed -e 's/\(.*\)=1/\1/' ccsym.own | |
285 | $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true | |
286 | ccsymbols=`$cat ccsym.own` | |
287 | ccsymbols=`echo $ccsymbols` | |
288 | $test "$silent" || sleep 1 | |
289 | fi | |
290 | fi | |
291 | $rm -f ccsym* | |
292 |