home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / perl / patch / U / Cppsym.U < prev    next >
Encoding:
Text File  |  1995-12-06  |  8.5 KB  |  230 lines

  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: eunicefix Guess cppstdin awk cat tr sed sort grep rm startsh \
  42.     contains cppminus +cc +gccversion test comm uniq echo n c Options
  43. ?MAKE:    -pick add $@ %<
  44. ?F:./Cppsym
  45. ?T:sym list unknown status also symbols i
  46. ?V:al
  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:
  53. ?INIT:: list of known cpp symbols, sorted alphabetically
  54. ?INIT:al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
  55. ?INIT:al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
  56. ?INIT:al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
  57. ?INIT:al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
  58. ?INIT:al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
  59. ?INIT:al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
  60. ?INIT:al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
  61. ?INIT:al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
  62. ?INIT:al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
  63. ?INIT:al="$al VMS Xenix286"
  64. ?INIT:al="$al _AIX _AIX32 _AIX370 _AM29000 _COFF _CRAY _CX_UX _EPI"
  65. ?INIT:al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET"
  66. ?INIT:al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
  67. ?INIT:al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
  68. ?INIT:al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
  69. ?INIT:al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
  70. ?INIT:al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
  71. ?INIT:al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
  72. ?INIT:al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
  73. ?INIT:al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
  74. ?INIT:al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
  75. ?INIT:al="$al __SVR4_2__ __UMAXV__"
  76. ?INIT:al="$al ____386BSD____ __alpha __alpha__ __amiga"
  77. ?INIT:al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
  78. ?INIT:al="$al __host_mips__"
  79. ?INIT:al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
  80. ?INIT:al="$al __hp9000s500 __hp9000s700 __hp9000s800"
  81. ?INIT:al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
  82. ?INIT:al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
  83. ?INIT:al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
  84. ?INIT:al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
  85. ?INIT:al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
  86. ?INIT:al="$al __mc88100 __mc88100__ __mips __mips__"
  87. ?INIT:al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
  88. ?INIT:al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
  89. ?INIT:al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
  90. ?INIT:al="$al _host_mips _mips _unix"
  91. ?INIT:al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
  92. ?INIT:al="$al apollo ardent att386 att3b"
  93. ?INIT:al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
  94. ?INIT:al="$al cadmus clipper concurrent convex cray ctix"
  95. ?INIT:al="$al dmert encore gcos gcx gimpel gould"
  96. ?INIT:al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
  97. ?INIT:al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
  98. ?INIT:al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
  99. ?INIT:al="$al i186 i286 i386 i486 i8086"
  100. ?INIT:al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
  101. ?INIT:al="$al ksr1 linux luna luna88k m68k m88100 m88k"
  102. ?INIT:al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
  103. ?INIT:al="$al mc68040 mc68060 mc68k mc68k32 mc700"
  104. ?INIT:al="$al mc88000 mc88100 merlin mert mips mvs n16"
  105. ?INIT:al="$al ncl_el ncl_mr"
  106. ?INIT:al="$al news1500 news1700 news1800 news1900 news3700"
  107. ?INIT:al="$al news700 news800 news900 ns16000 ns32000"
  108. ?INIT:al="$al ns32016 ns32332 ns32k nsc32000 os osf"
  109. ?INIT:al="$al parisc pc532 pdp11 plexus posix pyr"
  110. ?INIT:al="$al riscix riscos scs sequent sgi sinix sony sony_news"
  111. ?INIT:al="$al sonyrisc sparc sparclite spectrum stardent stratos"
  112. ?INIT:al="$al sun sun3 sun386 svr4 sysV68 sysV88"
  113. ?INIT:al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
  114. ?INIT:al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
  115. ?INIT:al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
  116. ?INIT:al="$al xenix z8000"
  117. ?INIT:
  118. : get C preprocessor symbols handy
  119. echo " "
  120. $echo $n "Hmm... $c"
  121. ?X: The following used to be tr '[ - ]' ... but this was rejected by AIX 3.2
  122. ?X: since the endpoints where the same (from patch 12u8 to patch).
  123. echo $al | $tr ' ' '\012' >Cppsym.know
  124. $cat <<EOSS >Cppsym
  125. $startsh
  126. case "\$1" in
  127. -l) list=true
  128.     shift
  129.     ;;
  130. esac
  131. unknown=''
  132. case "\$list\$#" in
  133. 1|2)
  134.     for sym do
  135.         if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
  136.             exit 0
  137.         elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
  138.             :
  139.         else
  140.             unknown="\$unknown \$sym"
  141.         fi
  142.     done
  143.     set X \$unknown
  144.     shift
  145.     ;;
  146. esac
  147. case \$# in
  148. 0) exit 1;;
  149. esac
  150. echo \$* | $tr ' ' '\012' | $sed -e 's/\(.*\)/\\
  151. #ifdef \1\\
  152. exit 0; _ _ _ _\1\\     \1\\
  153. #endif\\
  154. /' >Cppsym\$\$
  155. echo "exit 1; _ _ _" >>Cppsym\$\$
  156. $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
  157. case "\$list" in
  158. true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
  159. *)
  160.     sh Cppsym2\$\$
  161.     status=\$?
  162.     ;;
  163. esac
  164. $rm -f Cppsym\$\$ Cppsym2\$\$
  165. exit \$status
  166. EOSS
  167. chmod +x Cppsym
  168. $eunicefix Cppsym
  169. ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
  170.  
  171. : now check the C compiler for additional symbols
  172. ?X: suggested by Jarkko Hietaniemi <jhi@snakemail.hut.fi>, thanks!
  173. $cat >ccsym <<EOS
  174. $startsh
  175. $cat >tmp.c <<EOF
  176. extern int foo;
  177. EOF
  178. for i in \`$cc -v -c tmp.c 2>&1\`
  179. do
  180.     case "\$i" in
  181.     -D*) echo "\$i" | $sed 's/^-D//';;
  182.     -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
  183.     esac
  184. done
  185. $rm -f try.c
  186. EOS
  187. chmod +x ccsym
  188. $eunicefix ccsym
  189. ./ccsym | $sort | $uniq >ccsym.raw
  190. ?X: canonicalize symbols for easier sort/uniq/comm usage: append =1 if no = sign
  191. ?X: the awk script must be on two lines for older awk programs, sigh! -- ADO
  192. $awk '/\=/ { print $0; next }
  193.     { print $0"=1" }' ccsym.raw >ccsym.list
  194. $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
  195. $comm -13 ccsym.true ccsym.list >ccsym.own
  196. $comm -12 ccsym.true ccsym.list >ccsym.com
  197. $comm -23 ccsym.true ccsym.list >ccsym.cpp
  198. also=''
  199. symbols='symbols'
  200. if $test -z ccsym.raw; then
  201.     echo "Your C compiler doesn't seem to define any symbol!" >&4
  202.     echo " "
  203.     echo "However, your C preprocessor defines the following ones:"
  204.     $cat Cppsym.true
  205. else
  206.     if $test -s ccsym.com; then
  207.         echo "Your C compiler and pre-processor define these symbols:"
  208.         $sed -e 's/\(.*\)=.*/\1/' ccsym.com
  209.         also='also '
  210.         symbols='ones'
  211.         $test "$silent" || sleep 1
  212.     fi
  213.     if $test -s ccsym.cpp; then
  214.         $test "$also" && echo " "
  215.         echo "Your C pre-processor ${also}defines the following $symbols:"
  216.         $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
  217.         also='further '
  218.         $test "$silent" || sleep 1
  219.     fi
  220.     if $test -s ccsym.own; then
  221.         $test "$also" && echo " "
  222.         echo "Your C compiler ${also}defines the following cpp variables:"
  223.         $sed -e 's/\(.*\)=1/\1/' ccsym.own
  224.         $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
  225.         $test "$silent" || sleep 1
  226.     fi
  227. fi
  228. $rm -f ccsym*
  229.  
  230.