home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / GCC 1.37.1r15 / Scripts / gCPlus < prev   
Encoding:
Text File  |  1990-11-28  |  6.5 KB  |  255 lines  |  [TEXT/MPS ]

  1. # This script runs CFront and gC with appropriate options.
  2. #
  3. # Copyright © 1990 Apple Computer, Inc.
  4.  
  5. set echo 0  # Build turns echo on, grumble.
  6. set exit 0  # Have to be able to clean up after failed commands.
  7.  
  8. # Default is to run everything.
  9. set cfront-only 0
  10.  
  11. If ¬ "{CPlusScratch}" ; Set CPlusScratch ':' ; End
  12. set output-filename ""
  13. set cfront-options "-w3 -z3 -y {CPlusScratch}"
  14. set gc-options ""
  15. set tmp ":"
  16.  
  17. set echo-cmds 1
  18. set quiet-flag 1
  19.  
  20. set dash-mc68020 0
  21. set dash-m 0
  22.  
  23. # Scan all the command line arguments, distributing them to the appropriate
  24. # programs' command lines, translating when necessary.
  25. loop
  26.      break if {#} == 0
  27.     if "{1}" =~ /-a?*/
  28.         if "{1}" =~ /-a[01]«0,1»/
  29.             set cfront-options "{cfront-options} {1}"
  30.         else if "{1}" =~ /-ansi/
  31.             set gc-options "{gc-options} -ansi"
  32.         else if "{1}" =~ /-asm/
  33.             set gc-options "{gc-options} -asm"
  34.         end
  35.     else if "{1}" =~ /-b?*/
  36.         if "{1}" =~ /-b/
  37.             set gc-options "{gc-options} -b"
  38.         else if "{1}" =~ /-b2/
  39.             echo Warning: -b2 ignored, substituting -b
  40.             set gc-options "{gc-options} -b"
  41.         else if "{1}" =~ /-b3/
  42.             echo Warning: -b3 ignored, substituting -b
  43.             set gc-options "{gc-options} -b"
  44.         else if "{1}" =~ /-bigseg/
  45.             echo Warning: Ignoring -bigseg
  46.         end
  47.     else if "{1}" =~ /-c/
  48.         set cfront-only 1
  49.     else if "{1}" =~ /-d?*/
  50.         if "{1}" =~ /-d/
  51.             shift 1
  52.             set cfront-options "{cfront-options} -d {1}"
  53.         else if "{1}" =~ /-d?+/
  54.             set gc-options "{gc-options} {1}"
  55.         end
  56.     else if "{1}" =~ /-e?*/
  57.         if "{1}" =~ /-e/
  58.             set cfront-only 1
  59.             set cfront-options "{cfront-options} -e"
  60.         else if "{1}" =~ /-e2/
  61.             set cfront-only 1
  62.             set cfront-options "{cfront-options} -e2"
  63.         else if "{1}" =~ /-elems881/
  64.             set cfront-options "{cfront-options} -elems881"
  65.             set gc-options "{gc-options} -elems881"
  66.         end
  67.     else if "{1}" =~ /-f?*/
  68.         if "{1}" =~ /-f/
  69.             shift 1
  70.             set cfront-options "{cfront-options} -f '{1}'"
  71.         else if "{1}" =~ /-fx/
  72.             shift 1
  73.             if "{1}" =~ /30/
  74.                 set gc-options "{gc-options} -fx 30 -mnoseg"
  75.             else
  76.                 echo Warning: -fx {1} being ignored
  77.             end
  78.         else if "{1}" =~ /-f?+/
  79.             set gc-options "{gc-options} {1}"
  80.         end
  81.     else if "{1}" =~ /-i/
  82.         shift 1
  83.         set cfront-options "{cfront-options} -i '{1}'"
  84.         # at least in theory, cfront output does no inclusion
  85.     else if "{1}" =~ /-k/
  86.         shift 1
  87.         echo Warning: Ignoring -k
  88.     else if "{1}" =~ /-m?*/
  89.         if "{1}" =~ /-m/
  90.             set dash-m 1
  91.         else if "{1}" =~ /-maxerrors/
  92.             shift 1
  93.             set cfront-options "{cfront-options} -maxerrors {1}"
  94.         else if "{1}" =~ /-mbg/
  95.             shift 1
  96.             if "{1}" =~ /off/
  97.                 set cfront-options "{cfront-options} -mbg {1}"
  98.                 set gc-options "{gc-options} -mbg {1}"
  99.             else if "{1}" =~ /full/
  100.                 # default case
  101.             else
  102.                 echo Warning: only -mbg off and -mbg full are understood
  103.             end
  104.         else if "{1}" =~ /-mc68020/
  105.             set dash-mc68020 1
  106.         else if "{1}" =~ /-mc68881/
  107.             set cfront-options "{cfront-options} -mc68881"
  108.             set gc-options "{gc-options} -mc68881"
  109.         else if "{1}" =~ /-mf/
  110.             set cfront-options "{cfront-options} -mf"
  111.         else if "{1}" =~ /-mnoseg/
  112.             set gc-options "{gc-options} -mnoseg"
  113.         else if "{1}" =~ /-mtbl[01]/
  114.             set cfront-options "{cfront-options} {1}"
  115.         end
  116.     else if "{1}" =~ /-notonce/
  117.         echo Warning: -notonce being ignored
  118.     else if "{1}" =~ /-n/
  119.         echo Warning: -n being ignored
  120.     else if "{1}" =~ /-o?*/
  121.         if "{1}" =~ /-opt/
  122.             shift 1
  123.             set gc-options "{gc-options} -opt '{1}'"
  124.         else if "{1}" =~ /-o/
  125.             shift 1
  126.             set output-filename "{1}"
  127.         end
  128.     else if "{1}" =~ /-p?*/
  129.         if "{1}" =~ /-p/
  130.             set cfront-options "{cfront-options} -v"
  131.             set quiet-flag 0
  132.             set gc-options "{gc-options} -p"
  133.             set echo-cmds 1
  134.         else if "{1}" =~ /-pedantic/
  135.             set gc-options "{gc-options} -pedantic"
  136.         end
  137.     else if "{1}" =~ /-s?*/
  138.         if "{1}" =~ /-s/
  139.             shift 1
  140.             set gc-options "{gc-options} -s '{1}'"
  141.         else if "{1}" =~ /-sym/
  142.             shift 1
  143.             set gc-options "{gc-options} -sym {1}"
  144.         end
  145.     else if "{1}" =~ /-t?*/
  146.         if "{1}" =~ /-trace/
  147.             shift 1
  148.             set gc-options "{gc-options} -trace '{1}'"
  149.         else if "{1}" =~ /-t/
  150.             set quiet-flag 0
  151.         else if "{1}" =~ /-tools/
  152.             shift 1
  153.             set gc-options "{gc-options} -tools {1}" 
  154.         else if "{1}" =~ /-traditional/
  155.             set gc-options "{gc-options} -traditional {1}" 
  156.         end
  157.     else if "{1}" =~ /-u/
  158.         shift 1
  159.         set cfront-options "{cfront-options} -u '{1}'"
  160.     else if "{1}" =~ /-vtbl[01]/
  161.         set cfront-options "{cfront-options} {1}"
  162.     else if "{1}" =~ /-w?*/
  163.         if "{1}" =~ /-w[2]«0,1»/
  164.             set cfront-options "{cfront-options} {1}"
  165.             set gc-options "{gc-options} -w" 
  166.         else if "{1}" =~ /-w[13]/
  167.             set cfront-options "{cfront-options} {1}"
  168.         end
  169.     else if "{1}" =~ /-y/
  170.         shift 1
  171.         set cfront-options "{cfront-options} -y '{1}'"
  172.         set gc-options "{gc-options} -y '{1}'"
  173.         set tmp "{1}"
  174.     else if "{1}" =~ /-z?+/
  175.         set cfront-options "{cfront-options} {1}"
  176.     else if "{1}" =~ /-?+/
  177.         set gc-options "{gc-options} {1}"  # pass random stuff to gC
  178.     else
  179.         set input-filename "{1}"
  180.     end
  181.     shift 1
  182. end
  183.  
  184. if {dash-m}
  185.         set gc-options "{gc-options} -m"
  186.     if (! {dash-mc68020})
  187.         echo Warning: -m implies -mc68020
  188.     end
  189. end
  190.  
  191. if {dash-mc68020} || {dash-m}
  192.     set cfront-options "{cfront-options} -mc68020"
  193.     set gc-options "{gc-options} -mc68020"
  194. end
  195.  
  196. # Fix up details of parameters to the tools.
  197. if "{input-filename}" == ""
  198.     set tmp-filename "{tmp}stdin"
  199. else
  200.     if "{input-filename}" =~ /:*([¬:]+:*)*([¬:]+)®1/
  201.         set tmp-filename "{tmp}{®1}"
  202.     else
  203.         echo "### {0} - can’t parse “{input-filename}”"
  204.     exit 2
  205.     end
  206. end
  207.  
  208. if {cfront-only}
  209.     set cf-filename ""
  210.     set cfront-redirect ""
  211. else
  212.     set cf-filename "{tmp-filename}".cf
  213.     set cfront-redirect ">"
  214.     if "{output-filename}" == ""
  215.         set output-filename "{input-filename}".o
  216.     end
  217. end
  218.  
  219. # Run the two things in order
  220. if {echo-cmds}
  221.     echo "CFront {cfront-options} -c '{input-filename}'  {cfront-redirect}  '{cf-filename}'" > dev:stderr
  222. end
  223.         CFront {cfront-options} -c "{input-filename}"  {cfront-redirect}  "{cf-filename}"
  224. set cfront-status {status}
  225. exit {cfront-status} if {cfront-only}
  226.  
  227. if {cfront-status} == 0
  228.     if {echo-cmds}
  229.         echo "gC {gc-options} '{cf-filename}' -o '{output-filename}'" > dev:stderr
  230.     end
  231.     gC {gc-options} "{cf-filename}" -o "{output-filename}"
  232.     if {status} == 0
  233.         # complete success
  234.         if `exists -f "{tmp}"C.pipe.obj2`
  235.             Lib -o "{tmp}"Lib.out "{output-filename}" "{tmp}"C.pipe.obj2
  236.             duplicate -y "{tmp}"Lib.out "{output-filename}"
  237.             delete -i "{tmp}"Lib.out
  238.             delete -i "{tmp}"C.pipe.obj2
  239.         end
  240.         delete -i "{cf-filename}"
  241.         delete -i "{tmp}"C.pipe.cmnd
  242.     else
  243.         delete -i "{cf-filename}"
  244.         delete -i "{tmp}"C.pipe.cmnd
  245.         delete -i "{tmp}"C.pipe.obj2
  246.         delete -i "{output-filename}"
  247.     exit 2
  248.     end
  249. else
  250.     delete -i "{cf-filename}"
  251.     delete -i "{tmp}"C.pipe.cmnd
  252.     delete -i "{tmp}"C.pipe.obj2
  253.     exit 2
  254. end
  255.