home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / l / lnx_99c1.zip / GCC233.TPZ / GCC233.tar / usr / bin / c++ next >
Text File  |  1992-12-29  |  2KB  |  108 lines

  1. #!/bin/sh
  2. # Compile programs, treating .c files as C++.
  3. : || exec /bin/sh -f $0 $argv:q
  4.  
  5. # The compiler name might be different when doing cross-compilation
  6. # (this should be configured)
  7. gcc_name=gcc
  8. speclang=-xnone
  9.  
  10. # replace the command name by the name of the new command
  11. progname=`basename $0`
  12. case "$0" in
  13.   */*)
  14.     gcc=`echo $0 | sed -e "s;/[^/]*$;;"`/$gcc_name
  15.     ;;
  16.   *)
  17.     gcc=$gcc_name
  18.     ;;
  19. esac
  20.  
  21. # $first is yes for first arg, no afterwards.
  22. first=yes
  23. # If next arg is the argument of an option, $quote is non-empty.
  24. # More precisely, it is the option that wants an argument.
  25. quote=
  26. # $library is made empty to disable use of libg++.
  27. library=-lg++
  28. numargs=$#
  29.  
  30. # ash requires the newline before `do'.
  31. for arg
  32. do
  33.   if [ $first = yes ]
  34.   then
  35.     # Need some 1st arg to `set' which does not begin with `-'.
  36.     # We get rid of it after the loop ends.
  37.     set gcc
  38.     first=no
  39.   fi
  40.   # If you have to ask what this does, you should not edit this file. :-)
  41.   # The ``S'' at the start is so that echo -nostdinc does not eat the
  42.   # -nostdinc.
  43.   arg=`echo "S$arg" | sed "s/^S//; s/'/'\\\\\\\\''/g"`
  44.   if [ x$quote != x ]
  45.   then
  46.     quote=
  47.   else
  48.     quote=
  49.     case $arg in
  50.       -nostdlib)
  51.     # Inhibit linking with -lg++.
  52.     library=
  53.     ;;
  54.       -lm)
  55.     # Because libg++ uses things from the math library, make sure it
  56.     # always comes before the math library.
  57.     set "$@" $library
  58.     library=""
  59.     ;;
  60.       -[bBVDUoeTuIYmLiA] | -Tdata)
  61.     # these switches take following word as argument,
  62.     # so don't treat it as a file name.
  63.     quote=$arg
  64.     ;;
  65.       -[cSEM] | -MM)
  66.     # Don't specify libraries if we won't link,
  67.     # since that would cause a warning.
  68.     library=
  69.     ;;
  70.       -x*)
  71.     speclang=$arg
  72.     ;;
  73.       -v)
  74.     # catch `g++ -v'
  75.     if [ $numargs = 1 ] ; then library="" ; fi
  76.     ;;
  77.       -*)
  78.     # Pass other options through; they don't need -x and aren't inputs.
  79.     ;;
  80.       *)
  81.     # If file ends in .c or .i, put options around it.
  82.     # But not if a specified -x option is currently active.
  83.     case "$speclang $arg" in -xnone\ *.[ci])
  84.       set "$@" -xc++ "'$arg'" -xnone
  85.       continue
  86.     esac
  87.     ;;
  88.     esac
  89.   fi
  90.   set "$@" "'$arg'"
  91. done
  92.  
  93. # Get rid of that initial 1st arg
  94. if [ $first = no ]; then
  95.   shift
  96. else
  97.   echo "$0: No input files specified."
  98.   exit 1
  99. fi
  100.  
  101. if [ x$quote != x ]
  102. then
  103.   echo "$0: argument to \`$quote' missing"
  104.   exit 1
  105. fi
  106.  
  107. eval $gcc "$@" $library
  108.