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