?RCS: $Id: Cppsym.U,v 3.0.1.5 1995/05/12 11:59:11 ram Exp $ ?RCS: ?RCS: Copyright (c) 1991-1993, Raphael Manfredi ?RCS: ?RCS: You may redistribute only under the terms of the Artistic Licence, ?RCS: as specified in the README file that comes with the distribution. ?RCS: You may reuse parts of this distribution only within the terms of ?RCS: that same Artistic Licence; a copy of which may be found at the root ?RCS: of the source tree for dist 3.0. ?RCS: ?RCS: $Log: Cppsym.U,v $ ?RCS: Revision 3.0.1.5 1995/05/12 11:59:11 ram ?RCS: patch54: split awk command onto two lines for older awks (ADO) ?RCS: ?RCS: Revision 3.0.1.4 1995/01/11 14:55:57 ram ?RCS: patch45: new cc vs. cpp symbol checking suggested by JHI ?RCS: patch45: added more cpp symbols (JHI) ?RCS: ?RCS: Revision 3.0.1.3 1994/10/29 15:51:32 ram ?RCS: patch36: added ?F: line for metalint file checking ?RCS: patch36: new symbols ardent and titan (ADO) ?RCS: ?RCS: Revision 3.0.1.2 1994/06/20 06:53:32 ram ?RCS: patch30: extended cpp symbol lookup list (JHI) ?RCS: patch30: renamed attrlist symbol into al for brevity ?RCS: ?RCS: Revision 3.0.1.1 1993/12/15 08:14:14 ram ?RCS: patch15: added new cpp symbols __bsdi__ and BSD_NET2 ?RCS: ?RCS: Revision 3.0 1993/08/18 12:04:50 ram ?RCS: Baseline for dist 3.0 netwide release. ?RCS: ?X: ?X: This unit produces a shell script called Cppsym, which can be used to ?X: determine whether any in a list of symbols is defined by the C compilation ?X: chain (C preprocessor symbols plus C compiler native ones). ?X: It can determine the status of any symbol, though the symbols in $al ?X: are more easily determined. If you want to add to $al you can do ?X: it in Myinit.U. ?X: ?MAKE:Cppsym: eunicefix Guess cppstdin awk cat tr sed sort grep rm startsh \ contains cppminus +cc +gccversion test comm uniq echo n c Options ?MAKE: -pick add $@ %< ?F:./Cppsym ?T:sym list unknown status also symbols i ?V:al ?X: ?X: The symbol list is in alpha order for ease of maintenance... ?X: ?X: Lots of new symbols (mostly rummaged from gcc), courtesy of ?X: Jarkko Hietaniemi -- RAM, 06/06/94 ?X: ?INIT:: list of known cpp symbols, sorted alphabetically ?INIT:al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2" ?INIT:al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH" ?INIT:al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS" ?INIT:al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM" ?INIT:al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX" ?INIT:al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX" ?INIT:al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4" ?INIT:al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300" ?INIT:al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek" ?INIT:al="$al VMS Xenix286" ?INIT:al="$al _AIX _AIX32 _AIX370 _AM29000 _COFF _CRAY _CX_UX _EPI" ?INIT:al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET" ?INIT:al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3" ?INIT:al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000" ?INIT:al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4" ?INIT:al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS" ?INIT:al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__" ?INIT:al="$al __DGUX__ __DPX2__ __H3050R __H3050RX" ?INIT:al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__" ?INIT:al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__" ?INIT:al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__" ?INIT:al="$al __SVR4_2__ __UMAXV__" ?INIT:al="$al ____386BSD____ __alpha __alpha__ __amiga" ?INIT:al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__" ?INIT:al="$al __host_mips__" ?INIT:al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500" ?INIT:al="$al __hp9000s500 __hp9000s700 __hp9000s800" ?INIT:al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__" ?INIT:al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__" ?INIT:al="$al __m68k __m68k__ __m88100__ __m88k __m88k__" ?INIT:al="$al __mc68000 __mc68000__ __mc68020 __mc68020__" ?INIT:al="$al __mc68030 __mc68030__ __mc68040 __mc68040__" ?INIT:al="$al __mc88100 __mc88100__ __mips __mips__" ?INIT:al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__" ?INIT:al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__" ?INIT:al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__" ?INIT:al="$al _host_mips _mips _unix" ?INIT:al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent" ?INIT:al="$al apollo ardent att386 att3b" ?INIT:al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull" ?INIT:al="$al cadmus clipper concurrent convex cray ctix" ?INIT:al="$al dmert encore gcos gcx gimpel gould" ?INIT:al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800" ?INIT:al="$al hp9000 hp9000s300 hp9000s400 hp9000s500" ?INIT:al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux" ?INIT:al="$al i186 i286 i386 i486 i8086" ?INIT:al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k" ?INIT:al="$al ksr1 linux luna luna88k m68k m88100 m88k" ?INIT:al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030" ?INIT:al="$al mc68040 mc68060 mc68k mc68k32 mc700" ?INIT:al="$al mc88000 mc88100 merlin mert mips mvs n16" ?INIT:al="$al ncl_el ncl_mr" ?INIT:al="$al news1500 news1700 news1800 news1900 news3700" ?INIT:al="$al news700 news800 news900 ns16000 ns32000" ?INIT:al="$al ns32016 ns32332 ns32k nsc32000 os osf" ?INIT:al="$al parisc pc532 pdp11 plexus posix pyr" ?INIT:al="$al riscix riscos scs sequent sgi sinix sony sony_news" ?INIT:al="$al sonyrisc sparc sparclite spectrum stardent stratos" ?INIT:al="$al sun sun3 sun386 svr4 sysV68 sysV88" ?INIT:al="$al titan tower tower32 tower32_200 tower32_600 tower32_700" ?INIT:al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200" ?INIT:al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms" ?INIT:al="$al xenix z8000" ?INIT: : get C preprocessor symbols handy echo " " $echo $n "Hmm... $c" ?X: The following used to be tr '[ - ]' ... but this was rejected by AIX 3.2 ?X: since the endpoints where the same (from patch 12u8 to patch). echo $al | $tr ' ' '\012' >Cppsym.know $cat <Cppsym $startsh case "\$1" in -l) list=true shift ;; esac unknown='' case "\$list\$#" in 1|2) for sym do if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then exit 0 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then : else unknown="\$unknown \$sym" fi done set X \$unknown shift ;; esac case \$# in 0) exit 1;; esac echo \$* | $tr ' ' '\012' | $sed -e 's/\(.*\)/\\ #ifdef \1\\ exit 0; _ _ _ _\1\\ \1\\ #endif\\ /' >Cppsym\$\$ echo "exit 1; _ _ _" >>Cppsym\$\$ $cppstdin $cppminus Cppsym2\$\$ case "\$list" in true) $awk 'NF > 5 {print substr(\$6,2,100)}' Cppsym.true : now check the C compiler for additional symbols ?X: suggested by Jarkko Hietaniemi , thanks! $cat >ccsym <tmp.c <&1\` do case "\$i" in -D*) echo "\$i" | $sed 's/^-D//';; -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';; esac done $rm -f try.c EOS chmod +x ccsym $eunicefix ccsym ./ccsym | $sort | $uniq >ccsym.raw ?X: canonicalize symbols for easier sort/uniq/comm usage: append =1 if no = sign ?X: the awk script must be on two lines for older awk programs, sigh! -- ADO $awk '/\=/ { print $0; next } { print $0"=1" }' ccsym.raw >ccsym.list $awk '{ print $0"=1" }' Cppsym.true >ccsym.true $comm -13 ccsym.true ccsym.list >ccsym.own $comm -12 ccsym.true ccsym.list >ccsym.com $comm -23 ccsym.true ccsym.list >ccsym.cpp also='' symbols='symbols' if $test -z ccsym.raw; then echo "Your C compiler doesn't seem to define any symbol!" >&4 echo " " echo "However, your C preprocessor defines the following ones:" $cat Cppsym.true else if $test -s ccsym.com; then echo "Your C compiler and pre-processor define these symbols:" $sed -e 's/\(.*\)=.*/\1/' ccsym.com also='also ' symbols='ones' $test "$silent" || sleep 1 fi if $test -s ccsym.cpp; then $test "$also" && echo " " echo "Your C pre-processor ${also}defines the following $symbols:" $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp also='further ' $test "$silent" || sleep 1 fi if $test -s ccsym.own; then $test "$also" && echo " " echo "Your C compiler ${also}defines the following cpp variables:" $sed -e 's/\(.*\)=1/\1/' ccsym.own $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true $test "$silent" || sleep 1 fi fi $rm -f ccsym*