Annotation of gcc/c++, revision 1.1.1.4

1.1       root        1: #!/bin/sh
                      2: # Compile programs, treating .c files as C++.
1.1.1.2   root        3: : || exec /bin/sh -f $0 $argv:q
1.1       root        4: 
1.1.1.4 ! root        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++.
1.1       root       27: library=-lg++
1.1.1.4 ! root       28: numargs=$#
1.1       root       29: 
1.1.1.4 ! root       30: # ash requires the newline before `do'.
        !            31: for arg
1.1       root       32: do
1.1.1.4 ! root       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 ]
1.1       root       45:   then
1.1.1.4 ! root       46:     quote=
1.1       root       47:   else
1.1.1.4 ! root       48:     quote=
1.1       root       49:     case $arg in
                     50:       -nostdlib)
                     51:        # Inhibit linking with -lg++.
                     52:        library=
                     53:        ;;
1.1.1.4 ! root       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:        ;;
1.1       root       60:       -[bBVDUoeTuIYmLiA] | -Tdata)
                     61:        # these switches take following word as argument,
                     62:        # so don't treat it as a file name.
1.1.1.4 ! root       63:        quote=$arg
1.1       root       64:        ;;
1.1.1.3   root       65:       -[cSEM] | -MM)
1.1       root       66:        # Don't specify libraries if we won't link,
                     67:        # since that would cause a warning.
                     68:        library=
                     69:        ;;
                     70:       -x*)
1.1.1.4 ! root       71:        speclang=$arg
        !            72:        ;;
        !            73:       -v)
        !            74:        # catch `g++ -v'
        !            75:        if [ $numargs = 1 ] ; then library="" ; fi
1.1       root       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.
1.1.1.4 ! root       83:        case "$speclang $arg" in -xnone\ *.[ci])
        !            84:          set "$@" -xc++ "'$arg'" -xnone
        !            85:          continue
        !            86:        esac
1.1       root       87:        ;;
                     88:     esac
                     89:   fi
1.1.1.4 ! root       90:   set "$@" "'$arg'"
1.1       root       91: done
                     92: 
1.1.1.4 ! root       93: # Get rid of that initial 1st arg
        !            94: if [ $first = no ]; then
        !            95:   shift
        !            96: else
        !            97:   echo "$0: No input files specified."
1.1       root       98:   exit 1
                     99: fi
                    100: 
1.1.1.4 ! root      101: if [ x$quote != x ]
1.1       root      102: then
1.1.1.4 ! root      103:   echo "$0: argument to \`$quote' missing"
        !           104:   exit 1
1.1       root      105: fi
1.1.1.4 ! root      106: 
        !           107: eval $gcc "$@" $library

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.