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