[BACK]Return to cpp.sh CVS log [TXT][DIR] Up to [local] / src / usr.bin / cpp

Annotation of src/usr.bin/cpp/cpp.sh, Revision 1.9

1.9     ! guenther    1: #!/bin/ksh
        !             2: #      $OpenBSD: cpp.sh,v 1.8 2010/05/03 18:34:01 drahn Exp $
1.2       deraadt     3:
1.1       deraadt     4: #
                      5: # Copyright (c) 1990 The Regents of the University of California.
                      6: # All rights reserved.
                      7: #
                      8: # This code is derived from software contributed to Berkeley by
                      9: # the Systems Programming Group of the University of Utah Computer
                     10: # Science Department.
                     11: #
                     12: # Redistribution and use in source and binary forms, with or without
                     13: # modification, are permitted provided that the following conditions
                     14: # are met:
                     15: # 1. Redistributions of source code must retain the above copyright
                     16: #    notice, this list of conditions and the following disclaimer.
                     17: # 2. Redistributions in binary form must reproduce the above copyright
                     18: #    notice, this list of conditions and the following disclaimer in the
                     19: #    documentation and/or other materials provided with the distribution.
1.6       millert    20: # 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    21: #    may be used to endorse or promote products derived from this software
                     22: #    without specific prior written permission.
                     23: #
                     24: # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27: # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34: # SUCH DAMAGE.
                     35: #
                     36: #      @(#)usr.bin.cpp.sh      6.5 (Berkeley) 4/1/91
                     37: #
                     38: # Transitional front end to CCCP to make it behave like (Reiser) CCP:
                     39: #      specifies -traditional
                     40: #      doesn't search gcc-include
                     41: #
                     42: PATH=/usr/bin:/bin
1.7       espie      43: TRAD=-traditional
1.8       drahn      44: DGNUC="@GNUC@"
1.7       espie      45: STDINC="-I/usr/include"
1.9     ! guenther   46: set -A OPTS
        !            47: set -A INCS -- "-nostdinc"
1.7       espie      48: FOUNDFILES=false
1.1       deraadt    49:
                     50: CPP=/usr/libexec/cpp
                     51: if [ ! -x $CPP ]; then
1.3       niklas     52:        CPP=`cc -print-search-dirs | sed -ne '/^install: /s/install: \(.*\)/\1cpp/p'`;
                     53:        if [ ! -x $CPP ]; then
                     54:                echo "$0: installation problem: $CPP not found/executable" >&2
                     55:                exit 1
                     56:        fi
1.1       deraadt    57: fi
                     58:
                     59: while [ $# -gt 0 ]
                     60: do
                     61:        A="$1"
                     62:        shift
                     63:
                     64:        case $A in
                     65:        -nostdinc)
1.7       espie      66:                STDINC=
1.1       deraadt    67:                ;;
                     68:        -traditional)
1.7       espie      69:                TRAD=-traditional
                     70:                ;;
                     71:        -notraditional)
                     72:                TRAD=
1.1       deraadt    73:                ;;
1.9     ! guenther   74:        # options that take an argument and that should be sorted before
        !            75:        # the $STDINC option
        !            76:        -I | -imacros | -include | -idirafter | -iprefix | -iwithprefix | \
        !            77:        -iwithprefixbefore | -isysroot | -imultilib | -isystem | -iquote)
        !            78:                INCS[${#INCS[@]}]=$A
        !            79:                INCS[${#INCS[@]}]=$1
        !            80:                shift
        !            81:                ;;
1.1       deraadt    82:        -I*)
1.9     ! guenther   83:                INCS[${#INCS[@]}]=$A
        !            84:                ;;
        !            85:        # other options that take an argument
        !            86:        -MF | -MT | -MQ | -x | -D | -U | -o | -A)
        !            87:                OPTS[${#OPTS[@]}]=$A
        !            88:                OPTS[${#OPTS[@]}]=$1
        !            89:                shift
1.5       espie      90:                ;;
                     91:        -U__GNUC__)
1.7       espie      92:                DGNUC=
1.9     ! guenther   93:                OPTS[${#OPTS[@]}]=$A
1.1       deraadt    94:                ;;
                     95:        -*)
1.9     ! guenther   96:                OPTS[${#OPTS[@]}]=$A
1.1       deraadt    97:                ;;
                     98:        *)
1.7       espie      99:                FOUNDFILES=true
1.9     ! guenther  100:                $CPP $TRAD $DGNUC "${INCS[@]}" $STDINC "${OPTS[@]}" "$A" ||
        !           101:                        exit
1.1       deraadt   102:                ;;
                    103:        esac
                    104: done
                    105:
1.7       espie     106: if ! $FOUNDFILES
1.1       deraadt   107: then
                    108:        # read standard input
1.9     ! guenther  109:        exec $CPP $TRAD $DGNUC "${INCS[@]}" $STDINC "${OPTS[@]}"
1.1       deraadt   110: fi
                    111:
                    112: exit 0