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 29*4125432bSBill Sommerfeld# Copyright 2024 Bill Sommerfeld <sommerfeld@hamachi.org> 305ca82e69SJohn Levon# 315ca82e69SJohn Levon# Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables 325ca82e69SJohn Levon# before spawning a shell for doing a release-style builds interactively 335ca82e69SJohn Levon# and incrementally. 345ca82e69SJohn Levon# 355ca82e69SJohn Levon 365ca82e69SJohn Levonfunction fatal_error 375ca82e69SJohn Levon{ 385ca82e69SJohn Levon print -u2 "${progname}: $*" 395ca82e69SJohn Levon exit 1 405ca82e69SJohn Levon} 415ca82e69SJohn Levon 425ca82e69SJohn Levonfunction usage 435ca82e69SJohn Levon{ 445ca82e69SJohn Levon OPTIND=0 455ca82e69SJohn Levon getopts -a "${progname}" "${USAGE}" OPT '-?' 465ca82e69SJohn Levon exit 2 475ca82e69SJohn Levon} 485ca82e69SJohn Levon 495ca82e69SJohn Levontypeset -r USAGE=$'+ 505ca82e69SJohn Levon[-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n] 515ca82e69SJohn Levon[-author?OS/Net community <tools-discuss@opensolaris.org>] 525ca82e69SJohn Levon[+NAME?bldenv - spawn shell for interactive incremental OS-Net 535ca82e69SJohn Levon consolidation builds] 545ca82e69SJohn Levon[+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for 555ca82e69SJohn Levon doing interactive and incremental builds in a workspace 565ca82e69SJohn Levon already built with nightly(1). bldenv spawns a shell set up 575ca82e69SJohn Levon with the same environment variables taken from an env_file, 585ca82e69SJohn Levon as prepared for use with nightly(1).] 595ca82e69SJohn Levon[+?In addition to running a shell for interactive use, bldenv 605ca82e69SJohn Levon can optionally run a single command in the given environment, 615ca82e69SJohn Levon in the vein of sh -c or su -c. This is useful for 625ca82e69SJohn Levon scripting, when an interactive shell would not be. If the 635ca82e69SJohn Levon command is composed of multiple shell words or contains 645ca82e69SJohn Levon other shell metacharacters, it must be quoted appropriately.] 655ca82e69SJohn Levon[+?bldenv is particularly useful for testing Makefile targets 665ca82e69SJohn Levon like clobber, install and _msg, which otherwise require digging 675ca82e69SJohn Levon through large build logs to figure out what is being 685ca82e69SJohn Levon done.] 695ca82e69SJohn Levon[+?By default, bldenv will invoke the shell specified in 705ca82e69SJohn Levon $SHELL. If $SHELL is not set or is invalid, csh will be 715ca82e69SJohn Levon used.] 725ca82e69SJohn Levon[c?force the use of csh, regardless of the value of $SHELL.] 735ca82e69SJohn Levon[f?invoke csh with the -f (fast-start) option. This option is valid 745ca82e69SJohn Levon only if $SHELL is unset or if it points to csh.] 755ca82e69SJohn Levon[d?set up environment for doing DEBUG builds. The default is non-DEBUG, 765ca82e69SJohn Levon unless the -F flag is specified in the nightly file.] 775ca82e69SJohn Levon[t?set up environment to use the tools in usr/src/tools (this is the 785ca82e69SJohn Levon default, use +t to use the tools from /opt/onbld)] 795ca82e69SJohn Levon 805ca82e69SJohn Levon<env_file> [command] 815ca82e69SJohn Levon 825ca82e69SJohn Levon[+EXAMPLES]{ 835ca82e69SJohn Levon [+?Example 1: Interactive use]{ 845ca82e69SJohn Levon [+?Use bldenv to spawn a shell to perform a DEBUG build and 855ca82e69SJohn Levon testing of the Makefile targets clobber and install for 865ca82e69SJohn Levon usr/src/cmd/true.] 875ca82e69SJohn Levon [+\n% rlogin wopr-2 -l gk 885ca82e69SJohn Levon{root::wopr-2::49} bldenv -d /export0/jg/on10-se.env 895ca82e69SJohn LevonBuild type is DEBUG 905ca82e69SJohn LevonRELEASE is 5.10 915ca82e69SJohn LevonVERSION is wopr-2::on10-se::11/01/2001 925ca82e69SJohn LevonRELEASE_DATE is May 2004 935ca82e69SJohn LevonThe top-level `setup\' target is available to build headers 945ca82e69SJohn Levonand tools. 955ca82e69SJohn LevonUsing /usr/bin/tcsh as shell. 965ca82e69SJohn Levon{root::wopr-2::49} 975ca82e69SJohn Levon{root::wopr-2::49} cd $SRC/cmd/true 985ca82e69SJohn Levon{root::wopr-2::50} make 995ca82e69SJohn Levon{root::wopr-2::51} make clobber 1005ca82e69SJohn Levon/usr/bin/rm -f true true.po 1015ca82e69SJohn Levon{root::wopr-2::52} make 1025ca82e69SJohn Levon/usr/bin/rm -f true 1035ca82e69SJohn Levoncat true.sh > true 1045ca82e69SJohn Levonchmod +x true 1055ca82e69SJohn Levon{root::wopr-2::53} make install 1065ca82e69SJohn Levoninstall -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true 1075ca82e69SJohn Levon`install\' is up to date.] 1085ca82e69SJohn Levon } 1095ca82e69SJohn Levon [+?Example 2: Non-interactive use]{ 1105ca82e69SJohn Levon [+?Invoke bldenv to create SUNWonbld with a single command:] 1115ca82e69SJohn Levon [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\'] 1125ca82e69SJohn Levon } 1135ca82e69SJohn Levon} 1145ca82e69SJohn Levon[+SEE ALSO?\bnightly\b(1)] 1155ca82e69SJohn Levon' 1165ca82e69SJohn Levon 1175ca82e69SJohn Levon# main 1185ca82e69SJohn Levonbuiltin basename 1195ca82e69SJohn Levon 1205ca82e69SJohn Levon# boolean flags (true/false) 1215ca82e69SJohn Levontypeset flags=( 1225ca82e69SJohn Levon typeset c=false 1235ca82e69SJohn Levon typeset f=false 1245ca82e69SJohn Levon typeset d=false 1255ca82e69SJohn Levon typeset O=false 1265ca82e69SJohn Levon typeset o=false 1275ca82e69SJohn Levon typeset t=true 1285ca82e69SJohn Levon typeset s=( 1295ca82e69SJohn Levon typeset e=false 1305ca82e69SJohn Levon typeset h=false 1315ca82e69SJohn Levon typeset d=false 1325ca82e69SJohn Levon typeset o=false 1335ca82e69SJohn Levon ) 1345ca82e69SJohn Levon typeset d_set=false 1355ca82e69SJohn Levon typeset DF_build=false 1365ca82e69SJohn Levon) 1375ca82e69SJohn Levon 1385ca82e69SJohn Levontypeset progname="$(basename -- "${0}")" 1395ca82e69SJohn Levon 1405ca82e69SJohn LevonOPTIND=1 1415ca82e69SJohn Levon 1425ca82e69SJohn Levonwhile getopts -a "${progname}" "${USAGE}" OPT ; do 1435ca82e69SJohn Levon case ${OPT} in 1445ca82e69SJohn Levon c) flags.c=true ;; 1455ca82e69SJohn Levon +c) flags.c=false ;; 1465ca82e69SJohn Levon f) flags.f=true ;; 1475ca82e69SJohn Levon +f) flags.f=false ;; 1485ca82e69SJohn Levon d) flags.d=true ; flags.d_set=true ;; 1495ca82e69SJohn Levon +d) flags.d=false ; flags.d_set=true ;; 1505ca82e69SJohn Levon t) flags.t=true ;; 1515ca82e69SJohn Levon +t) flags.t=false ;; 1525ca82e69SJohn Levon \?) usage ;; 1535ca82e69SJohn Levon esac 1545ca82e69SJohn Levondone 1555ca82e69SJohn Levonshift $((OPTIND-1)) 1565ca82e69SJohn Levon 1575ca82e69SJohn Levon# test that the path to the environment-setting file was given 1585ca82e69SJohn Levonif (( $# < 1 )) ; then 1595ca82e69SJohn Levon usage 1605ca82e69SJohn Levonfi 1615ca82e69SJohn Levon 1625ca82e69SJohn Levon# force locale to C 1635ca82e69SJohn Levonexport \ 1645ca82e69SJohn Levon LANG=C \ 1655ca82e69SJohn Levon LC_ALL=C \ 1665ca82e69SJohn Levon LC_COLLATE=C \ 1675ca82e69SJohn Levon LC_CTYPE=C \ 1685ca82e69SJohn Levon LC_MESSAGES=C \ 1695ca82e69SJohn Levon LC_MONETARY=C \ 1705ca82e69SJohn Levon LC_NUMERIC=C \ 1715ca82e69SJohn Levon LC_TIME=C 1725ca82e69SJohn Levon 1735ca82e69SJohn Levon# clear environment variables we know to be bad for the build 1745ca82e69SJohn Levonunset \ 1755ca82e69SJohn Levon LD_OPTIONS \ 1765ca82e69SJohn Levon LD_LIBRARY_PATH \ 1775ca82e69SJohn Levon LD_AUDIT \ 1785ca82e69SJohn Levon LD_BIND_NOW \ 1795ca82e69SJohn Levon LD_BREADTH \ 1805ca82e69SJohn Levon LD_CONFIG \ 1815ca82e69SJohn Levon LD_DEBUG \ 1825ca82e69SJohn Levon LD_FLAGS \ 1835ca82e69SJohn Levon LD_LIBRARY_PATH_64 \ 1845ca82e69SJohn Levon LD_NOVERSION \ 1855ca82e69SJohn Levon LD_ORIGIN \ 1865ca82e69SJohn Levon LD_LOADFLTR \ 1875ca82e69SJohn Levon LD_NOAUXFLTR \ 1885ca82e69SJohn Levon LD_NOCONFIG \ 1895ca82e69SJohn Levon LD_NODIRCONFIG \ 1905ca82e69SJohn Levon LD_NOOBJALTER \ 1915ca82e69SJohn Levon LD_PRELOAD \ 1925ca82e69SJohn Levon LD_PROFILE \ 1935ca82e69SJohn Levon CONFIG \ 1945ca82e69SJohn Levon GROUP \ 1955ca82e69SJohn Levon OWNER \ 1965ca82e69SJohn Levon REMOTE \ 1975ca82e69SJohn Levon ENV \ 1985ca82e69SJohn Levon ARCH \ 1995ca82e69SJohn Levon CLASSPATH 2005ca82e69SJohn Levon 201eefeb0ceSBill Sommerfeld# set variables we want environment file to be able to override 202eefeb0ceSBill SommerfeldMAKEFLAGS=e 203eefeb0ceSBill Sommerfeld 2045ca82e69SJohn Levon# 2055ca82e69SJohn Levon# Setup environment variables 2065ca82e69SJohn Levon# 2075ca82e69SJohn Levonif [[ -f /etc/nightly.conf ]]; then 2085ca82e69SJohn Levon source /etc/nightly.conf 2095ca82e69SJohn Levonfi 2105ca82e69SJohn Levon 2115ca82e69SJohn Levonif [[ -f "$1" ]]; then 2125ca82e69SJohn Levon if [[ "$1" == */* ]]; then 2135ca82e69SJohn Levon source "$1" 2145ca82e69SJohn Levon else 2155ca82e69SJohn Levon source "./$1" 2165ca82e69SJohn Levon fi 2175ca82e69SJohn Levonelse 2185ca82e69SJohn Levon if [[ -f "/opt/onbld/env/$1" ]]; then 2195ca82e69SJohn Levon source "/opt/onbld/env/$1" 2205ca82e69SJohn Levon else 2215ca82e69SJohn Levon printf \ 2225ca82e69SJohn Levon 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \ 2235ca82e69SJohn Levon "$1" "$1" 2245ca82e69SJohn Levon exit 1 2255ca82e69SJohn Levon fi 2265ca82e69SJohn Levonfi 2275ca82e69SJohn Levonshift 2285ca82e69SJohn Levon 2295ca82e69SJohn Levon# Check if we have sufficient data to continue... 2305ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set." 2315ca82e69SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." 2325ca82e69SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." 2335ca82e69SJohn Levon 2345ca82e69SJohn Levon# must match the getopts in nightly 2355ca82e69SJohn LevonOPTIND=1 2365ca82e69SJohn LevonNIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}" 2375ca82e69SJohn Levonwhile getopts '+0ABCDdFfGIilMmNnpRrtUuwW' FLAG $NIGHTLY_OPTIONS 2385ca82e69SJohn Levondo 2395ca82e69SJohn Levon case "$FLAG" in 2405ca82e69SJohn Levon t) flags.t=true ;; 2415ca82e69SJohn Levon +t) flags.t=false ;; 2425ca82e69SJohn Levon F) flags.DF_build=true ;; 2435ca82e69SJohn Levon *) ;; 2445ca82e69SJohn Levon esac 2455ca82e69SJohn Levondone 2465ca82e69SJohn Levon 2475ca82e69SJohn Levon# DEBUG is a little bit complicated. First, bldenv -d/+d over-rides 2485ca82e69SJohn Levon# the env file. Otherwise, we'll default to DEBUG iff we are *not* 2495ca82e69SJohn Levon# building non-DEBUG bits at all. 2505ca82e69SJohn Levonif [ "${flags.d_set}" != "true" ] && "${flags.DF_build}"; then 2515ca82e69SJohn Levon flags.d=true 2525ca82e69SJohn Levonfi 2535ca82e69SJohn Levon 2545ca82e69SJohn LevonPOUND_SIGN="#" 2556112cec5SJoshua M. Clulowbasews=$(basename -- "$CODEMGR_WS") 2565ca82e69SJohn Levon# have we set RELEASE_DATE in our env file? 2575ca82e69SJohn Levonif [ -z "$RELEASE_DATE" ]; then 2585ca82e69SJohn Levon RELEASE_DATE=$(LC_ALL=C date +"%B %Y") 2595ca82e69SJohn Levonfi 2606112cec5SJoshua M. Clulownow=$(LC_ALL=C date +%Y-%b-%d) 2616112cec5SJoshua M. ClulowDEV_CM_TAIL="development build: $LOGNAME $now [$basews]" 2626112cec5SJoshua M. Clulow 2636112cec5SJoshua M. Clulow# 2646112cec5SJoshua M. Clulow# We export POUND_SIGN, RELEASE_DATE and DEV_CM_TAIL to speed up the build 2656112cec5SJoshua M. Clulow# process by avoiding repeated shell invocations to evaluate Makefile.master 2666112cec5SJoshua M. Clulow# definitions. 2676112cec5SJoshua M. Clulow# 2686112cec5SJoshua M. Clulowexport POUND_SIGN RELEASE_DATE DEV_CM_TAIL 2695ca82e69SJohn Levon 2705ca82e69SJohn Levonprint 'Build type is \c' 2715ca82e69SJohn Levonif ${flags.d} ; then 2725ca82e69SJohn Levon print 'DEBUG' 2735ca82e69SJohn Levon SUFFIX="" 2745ca82e69SJohn Levon unset RELEASE_BUILD 2755ca82e69SJohn Levon unset EXTRA_OPTIONS 2765ca82e69SJohn Levon unset EXTRA_CFLAGS 2775ca82e69SJohn Levon 2785ca82e69SJohn Levon if [ -n "$DEBUG_CONSOLE_COLOR" ]; then 2795ca82e69SJohn Levon export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR" 2805ca82e69SJohn Levon fi 2815ca82e69SJohn Levonelse 2825ca82e69SJohn Levon # default is a non-DEBUG build 2835ca82e69SJohn Levon print 'non-DEBUG' 2845ca82e69SJohn Levon SUFFIX="-nd" 2855ca82e69SJohn Levon export RELEASE_BUILD= 2865ca82e69SJohn Levon unset EXTRA_OPTIONS 2875ca82e69SJohn Levon unset EXTRA_CFLAGS 2885ca82e69SJohn Levon 2895ca82e69SJohn Levon if [ -n "$RELEASE_CONSOLE_COLOR" ]; then 2905ca82e69SJohn Levon export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR" 2915ca82e69SJohn Levon fi 2925ca82e69SJohn Levonfi 2935ca82e69SJohn Levon 2945ca82e69SJohn Levon# update build-type variables 2955ca82e69SJohn LevonPKGARCHIVE="${PKGARCHIVE}${SUFFIX}" 2965ca82e69SJohn Levon 2975ca82e69SJohn Levon# Set PATH for a build 2985ca82e69SJohn 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:." 2995ca82e69SJohn Levonif [[ "${SUNWSPRO}" != "" ]]; then 3005ca82e69SJohn Levon export PATH="${SUNWSPRO}/bin:$PATH" 3015ca82e69SJohn Levonfi 3025ca82e69SJohn Levon 3035ca82e69SJohn Levonif [[ -n "${MAKE}" ]]; then 3045ca82e69SJohn Levon if [[ -x "${MAKE}" ]]; then 3055ca82e69SJohn Levon export PATH="$(dirname -- "${MAKE}"):$PATH" 3065ca82e69SJohn Levon else 3075ca82e69SJohn Levon print "\$MAKE (${MAKE}) is not a valid executible" 3085ca82e69SJohn Levon exit 1 3095ca82e69SJohn Levon fi 3105ca82e69SJohn Levonfi 3115ca82e69SJohn Levon 3125ca82e69SJohn LevonTOOLS="${SRC}/tools" 3135ca82e69SJohn LevonTOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO 3145ca82e69SJohn Levon 3155ca82e69SJohn Levonif "${flags.t}" ; then 3165ca82e69SJohn Levon export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}" 3175ca82e69SJohn Levon 3185ca82e69SJohn Levon export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs" 3195ca82e69SJohn Levon export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs" 3205ca82e69SJohn Levon export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets" 3215ca82e69SJohn Levon 3225ca82e69SJohn Levon export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert" 3235ca82e69SJohn Levon export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge" 3245ca82e69SJohn Levon export NDRGEN="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ndrgen" 3255ca82e69SJohn Levon 3265ca82e69SJohn Levon PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}" 3275ca82e69SJohn Levon PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}" 3285ca82e69SJohn Levon export PATH 3295ca82e69SJohn Levonfi 3305ca82e69SJohn Levon 3315ca82e69SJohn Levonexport DMAKE_MODE=${DMAKE_MODE:-parallel} 3325ca82e69SJohn Levon 3335ca82e69SJohn Levon# 3345ca82e69SJohn Levon# Work around folks who have historically used GCC_ROOT and convert it to 3355ca82e69SJohn Levon# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could 3365ca82e69SJohn Levon# mess up the case where multiple different gcc versions are being used to 3375ca82e69SJohn Levon# shadow). 3385ca82e69SJohn Levon# 3395ca82e69SJohn Levonif [[ -n "${GCC_ROOT}" ]]; then 3405ca82e69SJohn Levon export GNUC_ROOT=${GCC_ROOT} 3415ca82e69SJohn Levonfi 3425ca82e69SJohn Levon 3435ca82e69SJohn LevonDEF_STRIPFLAG="-s" 3445ca82e69SJohn Levon 3455ca82e69SJohn LevonTMPDIR="/tmp" 3465ca82e69SJohn Levon 3475ca82e69SJohn Levonexport \ 3485ca82e69SJohn Levon PATH TMPDIR \ 3495ca82e69SJohn Levon POUND_SIGN \ 3505ca82e69SJohn Levon DEF_STRIPFLAG \ 3515ca82e69SJohn Levon RELEASE_DATE 3525ca82e69SJohn Levonunset \ 3535ca82e69SJohn Levon CFLAGS \ 3545ca82e69SJohn Levon LD_LIBRARY_PATH 3555ca82e69SJohn Levon 3565ca82e69SJohn Levon# a la ws 3575ca82e69SJohn LevonENVLDLIBS1= 3585ca82e69SJohn LevonENVLDLIBS2= 3595ca82e69SJohn LevonENVLDLIBS3= 3605ca82e69SJohn LevonENVCPPFLAGS1= 3615ca82e69SJohn LevonENVCPPFLAGS2= 3625ca82e69SJohn LevonENVCPPFLAGS3= 3635ca82e69SJohn LevonENVCPPFLAGS4= 3645ca82e69SJohn LevonPARENT_ROOT= 3655ca82e69SJohn LevonPARENT_TOOLS_ROOT= 3665ca82e69SJohn Levon 3675ca82e69SJohn Levonif [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then 3685ca82e69SJohn Levon printf \ 3695ca82e69SJohn Levon 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \ 3705ca82e69SJohn Levon "$MULTI_PROTO" 3715ca82e69SJohn Levon export MULTI_PROTO="no" 3725ca82e69SJohn Levonfi 3735ca82e69SJohn Levon 3745ca82e69SJohn Levon[[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}" 3755ca82e69SJohn Levon 3765ca82e69SJohn LevonENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib" 3775ca82e69SJohn LevonENVCPPFLAGS1="-I$ROOT/usr/include" 3785ca82e69SJohn Levon 379864a8d69SBill Sommerfeld# Per usr/src/cmd/make/bin/main.cc, MAKEFLAGS could be in one of two styles. 380864a8d69SBill Sommerfeld# If '-' or '=' is present, it is a new-style MAKEFLAGS which could be 381864a8d69SBill Sommerfeld# pasted into the command line as-is. 382864a8d69SBill Sommerfeld# Otherwise it is old-style (just a list of flag letters with no -) 383864a8d69SBill Sommerfeld# make always converts MAKEFLAGS to new-style in the environment of 384864a8d69SBill Sommerfeld# the processes it spawns 385864a8d69SBill Sommerfeld 386864a8d69SBill Sommerfeldcase $MAKEFLAGS in 387864a8d69SBill Sommerfeld *-* | *=*) 388864a8d69SBill Sommerfeld print "New-style MAKEFLAGS detected; no change made" 389864a8d69SBill Sommerfeld print "" 390864a8d69SBill Sommerfeld ;; 391864a8d69SBill Sommerfeld *e*) 392864a8d69SBill Sommerfeld ;; 393864a8d69SBill Sommerfeld *) 394864a8d69SBill Sommerfeld MAKEFLAGS="${MAKEFLAGS}e" 395864a8d69SBill Sommerfeld print "MAKEFLAGS is now '${MAKEFLAGS}'" 396864a8d69SBill Sommerfeld print "" 397864a8d69SBill Sommerfeld ;; 398864a8d69SBill Sommerfeldesac 399864a8d69SBill Sommerfeld 4005ca82e69SJohn Levonexport \ 4015ca82e69SJohn Levon ENVLDLIBS1 \ 4025ca82e69SJohn Levon ENVLDLIBS2 \ 4035ca82e69SJohn Levon ENVLDLIBS3 \ 4045ca82e69SJohn Levon ENVCPPFLAGS1 \ 4055ca82e69SJohn Levon ENVCPPFLAGS2 \ 4065ca82e69SJohn Levon ENVCPPFLAGS3 \ 4075ca82e69SJohn Levon ENVCPPFLAGS4 \ 4085ca82e69SJohn Levon MAKEFLAGS \ 4095ca82e69SJohn Levon PARENT_ROOT \ 4105ca82e69SJohn Levon PARENT_TOOLS_ROOT 4115ca82e69SJohn Levon 412*4125432bSBill Sommerfeldif [[ -z "$VERSION" ]]; then 413*4125432bSBill Sommerfeld export VERSION=$(git -C "${CODEMGR_WS}" describe --long --all --dirty | 414*4125432bSBill Sommerfeld cut -d/ -f2-) 415*4125432bSBill Sommerfeldfi 416*4125432bSBill Sommerfeld 4175ca82e69SJohn Levonprintf 'RELEASE is %s\n' "$RELEASE" 4185ca82e69SJohn Levonprintf 'VERSION is %s\n' "$VERSION" 4195ca82e69SJohn Levonprintf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE" 4205ca82e69SJohn Levon 4215ca82e69SJohn Levonif [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then 4225ca82e69SJohn Levon print "The top-level 'setup' target is available \c" 4235ca82e69SJohn Levon print "to build headers and tools." 4245ca82e69SJohn Levon print "" 4255ca82e69SJohn Levon 4265ca82e69SJohn Levonelif "${flags.t}" ; then 4275ca82e69SJohn Levon printf \ 4285ca82e69SJohn Levon 'The tools can be (re)built with the install target in %s.\n\n' \ 4295ca82e69SJohn Levon "${TOOLS}" 4305ca82e69SJohn Levonfi 4315ca82e69SJohn Levon 4325ca82e69SJohn Levon# 4335ca82e69SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set. 4345ca82e69SJohn Levon# 4355ca82e69SJohn Levon/usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT} 4365ca82e69SJohn Levon 4375ca82e69SJohn Levonif [[ "${flags.c}" == "false" && -x "$SHELL" && \ 4385ca82e69SJohn Levon "$(basename -- "${SHELL}")" != "csh" ]]; then 4395ca82e69SJohn Levon # $SHELL is set, and it's not csh. 4405ca82e69SJohn Levon 4415ca82e69SJohn Levon if "${flags.f}" ; then 4425ca82e69SJohn Levon print 'WARNING: -f is ignored when $SHELL is not csh' 4435ca82e69SJohn Levon fi 4445ca82e69SJohn Levon 4455ca82e69SJohn Levon printf 'Using %s as shell.\n' "$SHELL" 4465ca82e69SJohn Levon exec "$SHELL" ${@:+-c "$@"} 4475ca82e69SJohn Levon 4485ca82e69SJohn Levonelif "${flags.f}" ; then 4495ca82e69SJohn Levon print 'Using csh -f as shell.' 4505ca82e69SJohn Levon exec csh -f ${@:+-c "$@"} 4515ca82e69SJohn Levon 4525ca82e69SJohn Levonelse 4535ca82e69SJohn Levon print 'Using csh as shell.' 4545ca82e69SJohn Levon exec csh ${@:+-c "$@"} 4555ca82e69SJohn Levonfi 4565ca82e69SJohn Levon 4575ca82e69SJohn Levon# not reached 458