180cb8463Sguenther#!/bin/ksh 2*1a49fa34Sajacoutot# $OpenBSD: cpp.sh,v 1.10 2019/09/28 17:30:07 ajacoutot Exp $ 31258a77dSderaadt 439827acfSderaadt# 539827acfSderaadt# Copyright (c) 1990 The Regents of the University of California. 639827acfSderaadt# All rights reserved. 739827acfSderaadt# 839827acfSderaadt# This code is derived from software contributed to Berkeley by 939827acfSderaadt# the Systems Programming Group of the University of Utah Computer 1039827acfSderaadt# Science Department. 1139827acfSderaadt# 1239827acfSderaadt# Redistribution and use in source and binary forms, with or without 1339827acfSderaadt# modification, are permitted provided that the following conditions 1439827acfSderaadt# are met: 1539827acfSderaadt# 1. Redistributions of source code must retain the above copyright 1639827acfSderaadt# notice, this list of conditions and the following disclaimer. 1739827acfSderaadt# 2. Redistributions in binary form must reproduce the above copyright 1839827acfSderaadt# notice, this list of conditions and the following disclaimer in the 1939827acfSderaadt# documentation and/or other materials provided with the distribution. 20f75387cbSmillert# 3. Neither the name of the University nor the names of its contributors 2139827acfSderaadt# may be used to endorse or promote products derived from this software 2239827acfSderaadt# without specific prior written permission. 2339827acfSderaadt# 2439827acfSderaadt# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2539827acfSderaadt# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2639827acfSderaadt# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2739827acfSderaadt# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2839827acfSderaadt# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2939827acfSderaadt# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3039827acfSderaadt# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3139827acfSderaadt# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3239827acfSderaadt# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3339827acfSderaadt# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3439827acfSderaadt# SUCH DAMAGE. 3539827acfSderaadt# 3639827acfSderaadt# @(#)usr.bin.cpp.sh 6.5 (Berkeley) 4/1/91 3739827acfSderaadt# 3839827acfSderaadt# Transitional front end to CCCP to make it behave like (Reiser) CCP: 3939827acfSderaadt# specifies -traditional 4039827acfSderaadt# doesn't search gcc-include 4139827acfSderaadt# 42*1a49fa34SajacoutotPATH=/usr/bin:/bin:/usr/sbin:/sbin 435aab292eSespieTRAD=-traditional 441d02ddb3SdrahnDGNUC="@GNUC@" 455aab292eSespieSTDINC="-I/usr/include" 4680cb8463Sguentherset -A OPTS 4780cb8463Sguentherset -A INCS -- "-nostdinc" 485aab292eSespieFOUNDFILES=false 4939827acfSderaadt 5039827acfSderaadtCPP=/usr/libexec/cpp 5139827acfSderaadtif [ ! -x $CPP ]; then 52a55444b1Sniklas CPP=`cc -print-search-dirs | sed -ne '/^install: /s/install: \(.*\)/\1cpp/p'`; 53a55444b1Sniklas if [ ! -x $CPP ]; then 54a55444b1Sniklas echo "$0: installation problem: $CPP not found/executable" >&2 55a55444b1Sniklas exit 1 56a55444b1Sniklas fi 5739827acfSderaadtfi 5839827acfSderaadt 5939827acfSderaadtwhile [ $# -gt 0 ] 6039827acfSderaadtdo 6139827acfSderaadt A="$1" 6239827acfSderaadt shift 6339827acfSderaadt 6439827acfSderaadt case $A in 6539827acfSderaadt -nostdinc) 665aab292eSespie STDINC= 6739827acfSderaadt ;; 6839827acfSderaadt -traditional) 695aab292eSespie TRAD=-traditional 705aab292eSespie ;; 715aab292eSespie -notraditional) 725aab292eSespie TRAD= 7339827acfSderaadt ;; 7480cb8463Sguenther # options that take an argument and that should be sorted before 7580cb8463Sguenther # the $STDINC option 7680cb8463Sguenther -I | -imacros | -include | -idirafter | -iprefix | -iwithprefix | \ 7780cb8463Sguenther -iwithprefixbefore | -isysroot | -imultilib | -isystem | -iquote) 7880cb8463Sguenther INCS[${#INCS[@]}]=$A 7980cb8463Sguenther INCS[${#INCS[@]}]=$1 8080cb8463Sguenther shift 8180cb8463Sguenther ;; 8239827acfSderaadt -I*) 8380cb8463Sguenther INCS[${#INCS[@]}]=$A 8480cb8463Sguenther ;; 8580cb8463Sguenther # other options that take an argument 8680cb8463Sguenther -MF | -MT | -MQ | -x | -D | -U | -o | -A) 8780cb8463Sguenther OPTS[${#OPTS[@]}]=$A 8880cb8463Sguenther OPTS[${#OPTS[@]}]=$1 8980cb8463Sguenther shift 9039827acfSderaadt ;; 91cc5a0021Sespie -U__GNUC__) 925aab292eSespie DGNUC= 9380cb8463Sguenther OPTS[${#OPTS[@]}]=$A 9439827acfSderaadt ;; 9539827acfSderaadt -*) 9680cb8463Sguenther OPTS[${#OPTS[@]}]=$A 9739827acfSderaadt ;; 9839827acfSderaadt *) 995aab292eSespie FOUNDFILES=true 10080cb8463Sguenther $CPP $TRAD $DGNUC "${INCS[@]}" $STDINC "${OPTS[@]}" "$A" || 10180cb8463Sguenther exit 10239827acfSderaadt ;; 10339827acfSderaadt esac 10439827acfSderaadtdone 10539827acfSderaadt 1065aab292eSespieif ! $FOUNDFILES 10739827acfSderaadtthen 10839827acfSderaadt # read standard input 10980cb8463Sguenther exec $CPP $TRAD $DGNUC "${INCS[@]}" $STDINC "${OPTS[@]}" 11039827acfSderaadtfi 11139827acfSderaadt 11239827acfSderaadtexit 0 113