home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gcc-2.4.5 / c++ < prev    next >
Encoding:
Text File  |  1993-02-26  |  2.4 KB  |  110 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 | -lmath)
  55.      # Because libg++ uses things from the math library, make sure it
  56.     # always comes before the math library.  We recognize both -lm
  57.     # and -lmath, since on some systems (e.g. m88k SVR3), it
  58.     # doesn't call it libm.a for some reason.
  59.     set "$@" $library
  60.     library=""
  61.     ;;
  62.       -[bBVDUoeTuIYmLiA] | -Tdata)
  63.     # these switches take following word as argument,
  64.     # so don't treat it as a file name.
  65.     quote=$arg
  66.     ;;
  67.       -[cSEM] | -MM)
  68.     # Don't specify libraries if we won't link,
  69.     # since that would cause a warning.
  70.     library=
  71.     ;;
  72.       -x*)
  73.     speclang=$arg
  74.     ;;
  75.       -v)
  76.     # catch `g++ -v'
  77.     if [ $numargs = 1 ] ; then library="" ; fi
  78.     ;;
  79.       -*)
  80.     # Pass other options through; they don't need -x and aren't inputs.
  81.     ;;
  82.       *)
  83.     # If file ends in .c or .i, put options around it.
  84.     # But not if a specified -x option is currently active.
  85.     case "$speclang $arg" in -xnone\ *.[ci])
  86.       set "$@" -xc++ "'$arg'" -xnone
  87.       continue
  88.     esac
  89.     ;;
  90.     esac
  91.   fi
  92.   set "$@" "'$arg'"
  93. done
  94.  
  95. # Get rid of that initial 1st arg
  96. if [ $first = no ]; then
  97.   shift
  98. else
  99.   echo "$0: No input files specified."
  100.   exit 1
  101. fi
  102.  
  103. if [ x$quote != x ]
  104. then
  105.   echo "$0: argument to \`$quote' missing"
  106.   exit 1
  107. fi
  108.  
  109. eval $gcc "$@" $library
  110.