xref: /illumos-gate/usr/src/tools/scripts/bldenv (revision eefeb0cefd4c16a71271c521bd4eb89bd8f0627c)
15ca82e69SJohn Levon#!/usr/bin/ksh93
25ca82e69SJohn Levon#
35ca82e69SJohn Levon# CDDL HEADER START
45ca82e69SJohn Levon#
55ca82e69SJohn Levon# The contents of this file are subject to the terms of the
65ca82e69SJohn Levon# Common Development and Distribution License (the "License").
75ca82e69SJohn Levon# You may not use this file except in compliance with the License.
85ca82e69SJohn Levon#
95ca82e69SJohn Levon# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
105ca82e69SJohn Levon# or http://www.opensolaris.org/os/licensing.
115ca82e69SJohn Levon# See the License for the specific language governing permissions
125ca82e69SJohn Levon# and limitations under the License.
135ca82e69SJohn Levon#
145ca82e69SJohn Levon# When distributing Covered Code, include this CDDL HEADER in each
155ca82e69SJohn Levon# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
165ca82e69SJohn Levon# If applicable, add the following below this CDDL HEADER, with the
175ca82e69SJohn Levon# fields enclosed by brackets "[]" replaced with your own identifying
185ca82e69SJohn Levon# information: Portions Copyright [yyyy] [name of copyright owner]
195ca82e69SJohn Levon#
205ca82e69SJohn Levon# CDDL HEADER END
215ca82e69SJohn Levon#
225ca82e69SJohn Levon
235ca82e69SJohn Levon#
245ca82e69SJohn Levon# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
255ca82e69SJohn Levon# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
265ca82e69SJohn Levon# Copyright 2014 Garrett D'Amore <garrett@damore.org>
275ca82e69SJohn Levon# Copyright 2020 Joyent, Inc.
286112cec5SJoshua M. Clulow# Copyright 2020 Oxide Computer Company
295ca82e69SJohn Levon#
305ca82e69SJohn Levon# Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
315ca82e69SJohn Levon# before spawning a shell for doing a release-style builds interactively
325ca82e69SJohn Levon# and incrementally.
335ca82e69SJohn Levon#
345ca82e69SJohn Levon
355ca82e69SJohn Levonfunction fatal_error
365ca82e69SJohn Levon{
375ca82e69SJohn Levon	print -u2 "${progname}: $*"
385ca82e69SJohn Levon	exit 1
395ca82e69SJohn Levon}
405ca82e69SJohn Levon
415ca82e69SJohn Levonfunction usage
425ca82e69SJohn Levon{
435ca82e69SJohn Levon    OPTIND=0
445ca82e69SJohn Levon    getopts -a "${progname}" "${USAGE}" OPT '-?'
455ca82e69SJohn Levon    exit 2
465ca82e69SJohn Levon}
475ca82e69SJohn Levon
485ca82e69SJohn Levontypeset -r USAGE=$'+
495ca82e69SJohn Levon[-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
505ca82e69SJohn Levon[-author?OS/Net community <tools-discuss@opensolaris.org>]
515ca82e69SJohn Levon[+NAME?bldenv - spawn shell for interactive incremental OS-Net
525ca82e69SJohn Levon    consolidation builds]
535ca82e69SJohn Levon[+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
545ca82e69SJohn Levon    doing interactive and incremental builds in a workspace
555ca82e69SJohn Levon    already built with nightly(1). bldenv spawns a shell set up
565ca82e69SJohn Levon    with the same environment variables taken from an env_file,
575ca82e69SJohn Levon    as prepared for use with nightly(1).]
585ca82e69SJohn Levon[+?In addition to running a shell for interactive use, bldenv
595ca82e69SJohn Levon    can optionally run a single command in the given environment,
605ca82e69SJohn Levon    in the vein of sh -c or su -c. This is useful for
615ca82e69SJohn Levon    scripting, when an interactive shell would not be. If the
625ca82e69SJohn Levon    command is composed of multiple shell words or contains
635ca82e69SJohn Levon    other shell metacharacters, it must be quoted appropriately.]
645ca82e69SJohn Levon[+?bldenv is particularly useful for testing Makefile targets
655ca82e69SJohn Levon    like clobber, install and _msg, which otherwise require digging
665ca82e69SJohn Levon    through large build logs to figure out what is being
675ca82e69SJohn Levon    done.]
685ca82e69SJohn Levon[+?By default, bldenv will invoke the shell specified in
695ca82e69SJohn Levon    $SHELL. If $SHELL is not set or is invalid, csh will be
705ca82e69SJohn Levon    used.]
715ca82e69SJohn Levon[c?force the use of csh, regardless of the  value  of $SHELL.]
725ca82e69SJohn Levon[f?invoke csh with the -f (fast-start) option. This option is valid
735ca82e69SJohn Levon    only if $SHELL is unset or if it points to csh.]
745ca82e69SJohn Levon[d?set up environment for doing DEBUG builds. The default is non-DEBUG,
755ca82e69SJohn Levon    unless the -F flag is specified in the nightly file.]
765ca82e69SJohn Levon[t?set up environment to use the tools in usr/src/tools (this is the
775ca82e69SJohn Levon    default, use +t to use the tools from /opt/onbld)]
785ca82e69SJohn Levon
795ca82e69SJohn Levon<env_file> [command]
805ca82e69SJohn Levon
815ca82e69SJohn Levon[+EXAMPLES]{
825ca82e69SJohn Levon    [+?Example 1: Interactive use]{
835ca82e69SJohn Levon        [+?Use bldenv to spawn a shell to perform  a  DEBUG  build  and
845ca82e69SJohn Levon            testing of the  Makefile  targets  clobber and install for
855ca82e69SJohn Levon            usr/src/cmd/true.]
865ca82e69SJohn Levon        [+\n% rlogin wopr-2 -l gk
875ca82e69SJohn Levon{root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
885ca82e69SJohn LevonBuild type   is  DEBUG
895ca82e69SJohn LevonRELEASE      is  5.10
905ca82e69SJohn LevonVERSION      is  wopr-2::on10-se::11/01/2001
915ca82e69SJohn LevonRELEASE_DATE is  May 2004
925ca82e69SJohn LevonThe top-level `setup\' target is available to build headers
935ca82e69SJohn Levonand tools.
945ca82e69SJohn LevonUsing /usr/bin/tcsh as shell.
955ca82e69SJohn Levon{root::wopr-2::49}
965ca82e69SJohn Levon{root::wopr-2::49} cd $SRC/cmd/true
975ca82e69SJohn Levon{root::wopr-2::50} make
985ca82e69SJohn Levon{root::wopr-2::51} make clobber
995ca82e69SJohn Levon/usr/bin/rm -f true true.po
1005ca82e69SJohn Levon{root::wopr-2::52} make
1015ca82e69SJohn Levon/usr/bin/rm -f true
1025ca82e69SJohn Levoncat true.sh > true
1035ca82e69SJohn Levonchmod +x true
1045ca82e69SJohn Levon{root::wopr-2::53} make install
1055ca82e69SJohn Levoninstall -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true
1065ca82e69SJohn Levon`install\' is up to date.]
1075ca82e69SJohn Levon    }
1085ca82e69SJohn Levon    [+?Example 2: Non-interactive use]{
1095ca82e69SJohn Levon        [+?Invoke bldenv to create SUNWonbld with a single command:]
1105ca82e69SJohn Levon        [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\']
1115ca82e69SJohn Levon        }
1125ca82e69SJohn Levon}
1135ca82e69SJohn Levon[+SEE ALSO?\bnightly\b(1)]
1145ca82e69SJohn Levon'
1155ca82e69SJohn Levon
1165ca82e69SJohn Levon# main
1175ca82e69SJohn Levonbuiltin basename
1185ca82e69SJohn Levon
1195ca82e69SJohn Levon# boolean flags (true/false)
1205ca82e69SJohn Levontypeset flags=(
1215ca82e69SJohn Levon	typeset c=false
1225ca82e69SJohn Levon	typeset f=false
1235ca82e69SJohn Levon	typeset d=false
1245ca82e69SJohn Levon	typeset O=false
1255ca82e69SJohn Levon	typeset o=false
1265ca82e69SJohn Levon	typeset t=true
1275ca82e69SJohn Levon	typeset s=(
1285ca82e69SJohn Levon		typeset e=false
1295ca82e69SJohn Levon		typeset h=false
1305ca82e69SJohn Levon		typeset d=false
1315ca82e69SJohn Levon		typeset o=false
1325ca82e69SJohn Levon	)
1335ca82e69SJohn Levon	typeset d_set=false
1345ca82e69SJohn Levon	typeset DF_build=false
1355ca82e69SJohn Levon)
1365ca82e69SJohn Levon
1375ca82e69SJohn Levontypeset progname="$(basename -- "${0}")"
1385ca82e69SJohn Levon
1395ca82e69SJohn LevonOPTIND=1
1405ca82e69SJohn Levon
1415ca82e69SJohn Levonwhile getopts -a "${progname}" "${USAGE}" OPT ; do
1425ca82e69SJohn Levon    case ${OPT} in
1435ca82e69SJohn Levon	  c)	flags.c=true  ;;
1445ca82e69SJohn Levon	  +c)	flags.c=false ;;
1455ca82e69SJohn Levon	  f)	flags.f=true  ;;
1465ca82e69SJohn Levon	  +f)	flags.f=false ;;
1475ca82e69SJohn Levon	  d)	flags.d=true ; flags.d_set=true ;;
1485ca82e69SJohn Levon	  +d)	flags.d=false ; flags.d_set=true ;;
1495ca82e69SJohn Levon	  t)	flags.t=true  ;;
1505ca82e69SJohn Levon	  +t)	flags.t=false ;;
1515ca82e69SJohn Levon	  \?)	usage ;;
1525ca82e69SJohn Levon    esac
1535ca82e69SJohn Levondone
1545ca82e69SJohn Levonshift $((OPTIND-1))
1555ca82e69SJohn Levon
1565ca82e69SJohn Levon# test that the path to the environment-setting file was given
1575ca82e69SJohn Levonif (( $# < 1 )) ; then
1585ca82e69SJohn Levon	usage
1595ca82e69SJohn Levonfi
1605ca82e69SJohn Levon
1615ca82e69SJohn Levon# force locale to C
1625ca82e69SJohn Levonexport \
1635ca82e69SJohn Levon	LANG=C \
1645ca82e69SJohn Levon	LC_ALL=C \
1655ca82e69SJohn Levon	LC_COLLATE=C \
1665ca82e69SJohn Levon	LC_CTYPE=C \
1675ca82e69SJohn Levon	LC_MESSAGES=C \
1685ca82e69SJohn Levon	LC_MONETARY=C \
1695ca82e69SJohn Levon	LC_NUMERIC=C \
1705ca82e69SJohn Levon	LC_TIME=C
1715ca82e69SJohn Levon
1725ca82e69SJohn Levon# clear environment variables we know to be bad for the build
1735ca82e69SJohn Levonunset \
1745ca82e69SJohn Levon	LD_OPTIONS \
1755ca82e69SJohn Levon	LD_LIBRARY_PATH \
1765ca82e69SJohn Levon	LD_AUDIT \
1775ca82e69SJohn Levon	LD_BIND_NOW \
1785ca82e69SJohn Levon	LD_BREADTH \
1795ca82e69SJohn Levon	LD_CONFIG \
1805ca82e69SJohn Levon	LD_DEBUG \
1815ca82e69SJohn Levon	LD_FLAGS \
1825ca82e69SJohn Levon	LD_LIBRARY_PATH_64 \
1835ca82e69SJohn Levon	LD_NOVERSION \
1845ca82e69SJohn Levon	LD_ORIGIN \
1855ca82e69SJohn Levon	LD_LOADFLTR \
1865ca82e69SJohn Levon	LD_NOAUXFLTR \
1875ca82e69SJohn Levon	LD_NOCONFIG \
1885ca82e69SJohn Levon	LD_NODIRCONFIG \
1895ca82e69SJohn Levon	LD_NOOBJALTER \
1905ca82e69SJohn Levon	LD_PRELOAD \
1915ca82e69SJohn Levon	LD_PROFILE \
1925ca82e69SJohn Levon	CONFIG \
1935ca82e69SJohn Levon	GROUP \
1945ca82e69SJohn Levon	OWNER \
1955ca82e69SJohn Levon	REMOTE \
1965ca82e69SJohn Levon	ENV \
1975ca82e69SJohn Levon	ARCH \
1985ca82e69SJohn Levon	CLASSPATH
1995ca82e69SJohn Levon
200*eefeb0ceSBill Sommerfeld# set variables we want environment file to be able to override
201*eefeb0ceSBill SommerfeldMAKEFLAGS=e
202*eefeb0ceSBill Sommerfeld
2035ca82e69SJohn Levon#
2045ca82e69SJohn Levon# Setup environment variables
2055ca82e69SJohn Levon#
2065ca82e69SJohn Levonif [[ -f /etc/nightly.conf ]]; then
2075ca82e69SJohn Levon	source /etc/nightly.conf
2085ca82e69SJohn Levonfi
2095ca82e69SJohn Levon
2105ca82e69SJohn Levonif [[ -f "$1" ]]; then
2115ca82e69SJohn Levon	if [[ "$1" == */* ]]; then
2125ca82e69SJohn Levon		source "$1"
2135ca82e69SJohn Levon	else
2145ca82e69SJohn Levon		source "./$1"
2155ca82e69SJohn Levon	fi
2165ca82e69SJohn Levonelse
2175ca82e69SJohn Levon	if [[ -f "/opt/onbld/env/$1" ]]; then
2185ca82e69SJohn Levon		source "/opt/onbld/env/$1"
2195ca82e69SJohn Levon	else
2205ca82e69SJohn Levon		printf \
2215ca82e69SJohn Levon		    'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
2225ca82e69SJohn Levon		    "$1" "$1"
2235ca82e69SJohn Levon		exit 1
2245ca82e69SJohn Levon	fi
2255ca82e69SJohn Levonfi
2265ca82e69SJohn Levonshift
2275ca82e69SJohn Levon
2285ca82e69SJohn Levon# Check if we have sufficient data to continue...
2295ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
2305ca82e69SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
2315ca82e69SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
2325ca82e69SJohn Levon
2335ca82e69SJohn Levon# must match the getopts in nightly
2345ca82e69SJohn LevonOPTIND=1
2355ca82e69SJohn LevonNIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
2365ca82e69SJohn Levonwhile getopts '+0ABCDdFfGIilMmNnpRrtUuwW' FLAG $NIGHTLY_OPTIONS
2375ca82e69SJohn Levondo
2385ca82e69SJohn Levon	case "$FLAG" in
2395ca82e69SJohn Levon	  t)	flags.t=true  ;;
2405ca82e69SJohn Levon	  +t)	flags.t=false ;;
2415ca82e69SJohn Levon	  F)	flags.DF_build=true ;;
2425ca82e69SJohn Levon	  *)	;;
2435ca82e69SJohn Levon	esac
2445ca82e69SJohn Levondone
2455ca82e69SJohn Levon
2465ca82e69SJohn Levon# DEBUG is a little bit complicated.  First, bldenv -d/+d over-rides
2475ca82e69SJohn Levon# the env file.  Otherwise, we'll default to DEBUG iff we are *not*
2485ca82e69SJohn Levon# building non-DEBUG bits at all.
2495ca82e69SJohn Levonif [ "${flags.d_set}" != "true" ] && "${flags.DF_build}"; then
2505ca82e69SJohn Levon	flags.d=true
2515ca82e69SJohn Levonfi
2525ca82e69SJohn Levon
2535ca82e69SJohn LevonPOUND_SIGN="#"
2546112cec5SJoshua M. Clulowbasews=$(basename -- "$CODEMGR_WS")
2555ca82e69SJohn Levon# have we set RELEASE_DATE in our env file?
2565ca82e69SJohn Levonif [ -z "$RELEASE_DATE" ]; then
2575ca82e69SJohn Levon	RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
2585ca82e69SJohn Levonfi
2596112cec5SJoshua M. Clulownow=$(LC_ALL=C date +%Y-%b-%d)
2606112cec5SJoshua M. ClulowDEV_CM_TAIL="development build: $LOGNAME $now [$basews]"
2616112cec5SJoshua M. Clulow
2626112cec5SJoshua M. Clulow#
2636112cec5SJoshua M. Clulow# We export POUND_SIGN, RELEASE_DATE and DEV_CM_TAIL to speed up the build
2646112cec5SJoshua M. Clulow# process by avoiding repeated shell invocations to evaluate Makefile.master
2656112cec5SJoshua M. Clulow# definitions.
2666112cec5SJoshua M. Clulow#
2676112cec5SJoshua M. Clulowexport POUND_SIGN RELEASE_DATE DEV_CM_TAIL
2685ca82e69SJohn Levon
2695ca82e69SJohn Levonprint 'Build type   is  \c'
2705ca82e69SJohn Levonif ${flags.d} ; then
2715ca82e69SJohn Levon	print 'DEBUG'
2725ca82e69SJohn Levon	SUFFIX=""
2735ca82e69SJohn Levon	unset RELEASE_BUILD
2745ca82e69SJohn Levon	unset EXTRA_OPTIONS
2755ca82e69SJohn Levon	unset EXTRA_CFLAGS
2765ca82e69SJohn Levon
2775ca82e69SJohn Levon	if [ -n "$DEBUG_CONSOLE_COLOR" ]; then
2785ca82e69SJohn Levon		export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR"
2795ca82e69SJohn Levon	fi
2805ca82e69SJohn Levonelse
2815ca82e69SJohn Levon	# default is a non-DEBUG build
2825ca82e69SJohn Levon	print 'non-DEBUG'
2835ca82e69SJohn Levon	SUFFIX="-nd"
2845ca82e69SJohn Levon	export RELEASE_BUILD=
2855ca82e69SJohn Levon	unset EXTRA_OPTIONS
2865ca82e69SJohn Levon	unset EXTRA_CFLAGS
2875ca82e69SJohn Levon
2885ca82e69SJohn Levon	if [ -n "$RELEASE_CONSOLE_COLOR" ]; then
2895ca82e69SJohn Levon		export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR"
2905ca82e69SJohn Levon	fi
2915ca82e69SJohn Levonfi
2925ca82e69SJohn Levon
2935ca82e69SJohn Levon# update build-type variables
2945ca82e69SJohn LevonPKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
2955ca82e69SJohn Levon
2965ca82e69SJohn Levon#	Set PATH for a build
2975ca82e69SJohn LevonPATH="/opt/onbld/bin:/opt/onbld/bin/${MACH}:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/etc:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
2985ca82e69SJohn Levonif [[ "${SUNWSPRO}" != "" ]]; then
2995ca82e69SJohn Levon	export PATH="${SUNWSPRO}/bin:$PATH"
3005ca82e69SJohn Levonfi
3015ca82e69SJohn Levon
3025ca82e69SJohn Levonif [[ -n "${MAKE}" ]]; then
3035ca82e69SJohn Levon	if [[ -x "${MAKE}" ]]; then
3045ca82e69SJohn Levon		export PATH="$(dirname -- "${MAKE}"):$PATH"
3055ca82e69SJohn Levon	else
3065ca82e69SJohn Levon		print "\$MAKE (${MAKE}) is not a valid executible"
3075ca82e69SJohn Levon		exit 1
3085ca82e69SJohn Levon	fi
3095ca82e69SJohn Levonfi
3105ca82e69SJohn Levon
3115ca82e69SJohn LevonTOOLS="${SRC}/tools"
3125ca82e69SJohn LevonTOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
3135ca82e69SJohn Levon
3145ca82e69SJohn Levonif "${flags.t}" ; then
3155ca82e69SJohn Levon	export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
3165ca82e69SJohn Levon
3175ca82e69SJohn Levon	export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
3185ca82e69SJohn Levon	export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
3195ca82e69SJohn Levon	export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
3205ca82e69SJohn Levon
3215ca82e69SJohn Levon	export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
3225ca82e69SJohn Levon	export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
3235ca82e69SJohn Levon	export NDRGEN="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ndrgen"
3245ca82e69SJohn Levon
3255ca82e69SJohn Levon	PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
3265ca82e69SJohn Levon	PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
3275ca82e69SJohn Levon	export PATH
3285ca82e69SJohn Levonfi
3295ca82e69SJohn Levon
3305ca82e69SJohn Levonexport DMAKE_MODE=${DMAKE_MODE:-parallel}
3315ca82e69SJohn Levon
3325ca82e69SJohn Levon#
3335ca82e69SJohn Levon# Work around folks who have historically used GCC_ROOT and convert it to
3345ca82e69SJohn Levon# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could
3355ca82e69SJohn Levon# mess up the case where multiple different gcc versions are being used to
3365ca82e69SJohn Levon# shadow).
3375ca82e69SJohn Levon#
3385ca82e69SJohn Levonif [[ -n "${GCC_ROOT}" ]]; then
3395ca82e69SJohn Levon	export GNUC_ROOT=${GCC_ROOT}
3405ca82e69SJohn Levonfi
3415ca82e69SJohn Levon
3425ca82e69SJohn LevonDEF_STRIPFLAG="-s"
3435ca82e69SJohn Levon
3445ca82e69SJohn LevonTMPDIR="/tmp"
3455ca82e69SJohn Levon
3465ca82e69SJohn Levonexport \
3475ca82e69SJohn Levon	PATH TMPDIR \
3485ca82e69SJohn Levon	POUND_SIGN \
3495ca82e69SJohn Levon	DEF_STRIPFLAG \
3505ca82e69SJohn Levon	RELEASE_DATE
3515ca82e69SJohn Levonunset \
3525ca82e69SJohn Levon	CFLAGS \
3535ca82e69SJohn Levon	LD_LIBRARY_PATH
3545ca82e69SJohn Levon
3555ca82e69SJohn Levon# a la ws
3565ca82e69SJohn LevonENVLDLIBS1=
3575ca82e69SJohn LevonENVLDLIBS2=
3585ca82e69SJohn LevonENVLDLIBS3=
3595ca82e69SJohn LevonENVCPPFLAGS1=
3605ca82e69SJohn LevonENVCPPFLAGS2=
3615ca82e69SJohn LevonENVCPPFLAGS3=
3625ca82e69SJohn LevonENVCPPFLAGS4=
3635ca82e69SJohn LevonPARENT_ROOT=
3645ca82e69SJohn LevonPARENT_TOOLS_ROOT=
3655ca82e69SJohn Levon
3665ca82e69SJohn Levonif [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
3675ca82e69SJohn Levon	printf \
3685ca82e69SJohn Levon	    'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
3695ca82e69SJohn Levon	    "$MULTI_PROTO"
3705ca82e69SJohn Levon	export MULTI_PROTO="no"
3715ca82e69SJohn Levonfi
3725ca82e69SJohn Levon
3735ca82e69SJohn Levon[[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
3745ca82e69SJohn Levon
3755ca82e69SJohn LevonENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
3765ca82e69SJohn LevonENVCPPFLAGS1="-I$ROOT/usr/include"
3775ca82e69SJohn Levon
3785ca82e69SJohn Levonexport \
3795ca82e69SJohn Levon        ENVLDLIBS1 \
3805ca82e69SJohn Levon        ENVLDLIBS2 \
3815ca82e69SJohn Levon        ENVLDLIBS3 \
3825ca82e69SJohn Levon	ENVCPPFLAGS1 \
3835ca82e69SJohn Levon        ENVCPPFLAGS2 \
3845ca82e69SJohn Levon        ENVCPPFLAGS3 \
3855ca82e69SJohn Levon	ENVCPPFLAGS4 \
3865ca82e69SJohn Levon        MAKEFLAGS \
3875ca82e69SJohn Levon        PARENT_ROOT \
3885ca82e69SJohn Levon        PARENT_TOOLS_ROOT
3895ca82e69SJohn Levon
3905ca82e69SJohn Levonprintf 'RELEASE      is %s\n'   "$RELEASE"
3915ca82e69SJohn Levonprintf 'VERSION      is %s\n'   "$VERSION"
3925ca82e69SJohn Levonprintf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
3935ca82e69SJohn Levon
3945ca82e69SJohn Levonif [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then
3955ca82e69SJohn Levon	print "The top-level 'setup' target is available \c"
3965ca82e69SJohn Levon	print "to build headers and tools."
3975ca82e69SJohn Levon	print ""
3985ca82e69SJohn Levon
3995ca82e69SJohn Levonelif "${flags.t}" ; then
4005ca82e69SJohn Levon	printf \
4015ca82e69SJohn Levon	    'The tools can be (re)built with the install target in %s.\n\n' \
4025ca82e69SJohn Levon	    "${TOOLS}"
4035ca82e69SJohn Levonfi
4045ca82e69SJohn Levon
4055ca82e69SJohn Levon#
4065ca82e69SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set.
4075ca82e69SJohn Levon#
4085ca82e69SJohn Levon/usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT}
4095ca82e69SJohn Levon
4105ca82e69SJohn Levonif [[ "${flags.c}" == "false" && -x "$SHELL" && \
4115ca82e69SJohn Levon    "$(basename -- "${SHELL}")" != "csh" ]]; then
4125ca82e69SJohn Levon	# $SHELL is set, and it's not csh.
4135ca82e69SJohn Levon
4145ca82e69SJohn Levon	if "${flags.f}" ; then
4155ca82e69SJohn Levon		print 'WARNING: -f is ignored when $SHELL is not csh'
4165ca82e69SJohn Levon	fi
4175ca82e69SJohn Levon
4185ca82e69SJohn Levon	printf 'Using %s as shell.\n' "$SHELL"
4195ca82e69SJohn Levon	exec "$SHELL" ${@:+-c "$@"}
4205ca82e69SJohn Levon
4215ca82e69SJohn Levonelif "${flags.f}" ; then
4225ca82e69SJohn Levon	print 'Using csh -f as shell.'
4235ca82e69SJohn Levon	exec csh -f ${@:+-c "$@"}
4245ca82e69SJohn Levon
4255ca82e69SJohn Levonelse
4265ca82e69SJohn Levon	print 'Using csh as shell.'
4275ca82e69SJohn Levon	exec csh ${@:+-c "$@"}
4285ca82e69SJohn Levonfi
4295ca82e69SJohn Levon
4305ca82e69SJohn Levon# not reached
431