xref: /illumos-gate/usr/src/tools/scripts/bldenv (revision 5ca82e6914c4162ba9b7028b19c9d77d3eadaf17)
1*5ca82e69SJohn Levon#!/usr/bin/ksh93
2*5ca82e69SJohn Levon#
3*5ca82e69SJohn Levon# CDDL HEADER START
4*5ca82e69SJohn Levon#
5*5ca82e69SJohn Levon# The contents of this file are subject to the terms of the
6*5ca82e69SJohn Levon# Common Development and Distribution License (the "License").
7*5ca82e69SJohn Levon# You may not use this file except in compliance with the License.
8*5ca82e69SJohn Levon#
9*5ca82e69SJohn Levon# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*5ca82e69SJohn Levon# or http://www.opensolaris.org/os/licensing.
11*5ca82e69SJohn Levon# See the License for the specific language governing permissions
12*5ca82e69SJohn Levon# and limitations under the License.
13*5ca82e69SJohn Levon#
14*5ca82e69SJohn Levon# When distributing Covered Code, include this CDDL HEADER in each
15*5ca82e69SJohn Levon# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*5ca82e69SJohn Levon# If applicable, add the following below this CDDL HEADER, with the
17*5ca82e69SJohn Levon# fields enclosed by brackets "[]" replaced with your own identifying
18*5ca82e69SJohn Levon# information: Portions Copyright [yyyy] [name of copyright owner]
19*5ca82e69SJohn Levon#
20*5ca82e69SJohn Levon# CDDL HEADER END
21*5ca82e69SJohn Levon#
22*5ca82e69SJohn Levon
23*5ca82e69SJohn Levon#
24*5ca82e69SJohn Levon# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25*5ca82e69SJohn Levon# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26*5ca82e69SJohn Levon# Copyright 2014 Garrett D'Amore <garrett@damore.org>
27*5ca82e69SJohn Levon# Copyright 2020 Joyent, Inc.
28*5ca82e69SJohn Levon#
29*5ca82e69SJohn Levon# Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
30*5ca82e69SJohn Levon# before spawning a shell for doing a release-style builds interactively
31*5ca82e69SJohn Levon# and incrementally.
32*5ca82e69SJohn Levon#
33*5ca82e69SJohn Levon
34*5ca82e69SJohn Levonfunction fatal_error
35*5ca82e69SJohn Levon{
36*5ca82e69SJohn Levon	print -u2 "${progname}: $*"
37*5ca82e69SJohn Levon	exit 1
38*5ca82e69SJohn Levon}
39*5ca82e69SJohn Levon
40*5ca82e69SJohn Levonfunction usage
41*5ca82e69SJohn Levon{
42*5ca82e69SJohn Levon    OPTIND=0
43*5ca82e69SJohn Levon    getopts -a "${progname}" "${USAGE}" OPT '-?'
44*5ca82e69SJohn Levon    exit 2
45*5ca82e69SJohn Levon}
46*5ca82e69SJohn Levon
47*5ca82e69SJohn Levontypeset -r USAGE=$'+
48*5ca82e69SJohn Levon[-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
49*5ca82e69SJohn Levon[-author?OS/Net community <tools-discuss@opensolaris.org>]
50*5ca82e69SJohn Levon[+NAME?bldenv - spawn shell for interactive incremental OS-Net
51*5ca82e69SJohn Levon    consolidation builds]
52*5ca82e69SJohn Levon[+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
53*5ca82e69SJohn Levon    doing interactive and incremental builds in a workspace
54*5ca82e69SJohn Levon    already built with nightly(1). bldenv spawns a shell set up
55*5ca82e69SJohn Levon    with the same environment variables taken from an env_file,
56*5ca82e69SJohn Levon    as prepared for use with nightly(1).]
57*5ca82e69SJohn Levon[+?In addition to running a shell for interactive use, bldenv
58*5ca82e69SJohn Levon    can optionally run a single command in the given environment,
59*5ca82e69SJohn Levon    in the vein of sh -c or su -c. This is useful for
60*5ca82e69SJohn Levon    scripting, when an interactive shell would not be. If the
61*5ca82e69SJohn Levon    command is composed of multiple shell words or contains
62*5ca82e69SJohn Levon    other shell metacharacters, it must be quoted appropriately.]
63*5ca82e69SJohn Levon[+?bldenv is particularly useful for testing Makefile targets
64*5ca82e69SJohn Levon    like clobber, install and _msg, which otherwise require digging
65*5ca82e69SJohn Levon    through large build logs to figure out what is being
66*5ca82e69SJohn Levon    done.]
67*5ca82e69SJohn Levon[+?By default, bldenv will invoke the shell specified in
68*5ca82e69SJohn Levon    $SHELL. If $SHELL is not set or is invalid, csh will be
69*5ca82e69SJohn Levon    used.]
70*5ca82e69SJohn Levon[c?force the use of csh, regardless of the  value  of $SHELL.]
71*5ca82e69SJohn Levon[f?invoke csh with the -f (fast-start) option. This option is valid
72*5ca82e69SJohn Levon    only if $SHELL is unset or if it points to csh.]
73*5ca82e69SJohn Levon[d?set up environment for doing DEBUG builds. The default is non-DEBUG,
74*5ca82e69SJohn Levon    unless the -F flag is specified in the nightly file.]
75*5ca82e69SJohn Levon[t?set up environment to use the tools in usr/src/tools (this is the
76*5ca82e69SJohn Levon    default, use +t to use the tools from /opt/onbld)]
77*5ca82e69SJohn Levon
78*5ca82e69SJohn Levon<env_file> [command]
79*5ca82e69SJohn Levon
80*5ca82e69SJohn Levon[+EXAMPLES]{
81*5ca82e69SJohn Levon    [+?Example 1: Interactive use]{
82*5ca82e69SJohn Levon        [+?Use bldenv to spawn a shell to perform  a  DEBUG  build  and
83*5ca82e69SJohn Levon            testing of the  Makefile  targets  clobber and install for
84*5ca82e69SJohn Levon            usr/src/cmd/true.]
85*5ca82e69SJohn Levon        [+\n% rlogin wopr-2 -l gk
86*5ca82e69SJohn Levon{root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
87*5ca82e69SJohn LevonBuild type   is  DEBUG
88*5ca82e69SJohn LevonRELEASE      is  5.10
89*5ca82e69SJohn LevonVERSION      is  wopr-2::on10-se::11/01/2001
90*5ca82e69SJohn LevonRELEASE_DATE is  May 2004
91*5ca82e69SJohn LevonThe top-level `setup\' target is available to build headers
92*5ca82e69SJohn Levonand tools.
93*5ca82e69SJohn LevonUsing /usr/bin/tcsh as shell.
94*5ca82e69SJohn Levon{root::wopr-2::49}
95*5ca82e69SJohn Levon{root::wopr-2::49} cd $SRC/cmd/true
96*5ca82e69SJohn Levon{root::wopr-2::50} make
97*5ca82e69SJohn Levon{root::wopr-2::51} make clobber
98*5ca82e69SJohn Levon/usr/bin/rm -f true true.po
99*5ca82e69SJohn Levon{root::wopr-2::52} make
100*5ca82e69SJohn Levon/usr/bin/rm -f true
101*5ca82e69SJohn Levoncat true.sh > true
102*5ca82e69SJohn Levonchmod +x true
103*5ca82e69SJohn Levon{root::wopr-2::53} make install
104*5ca82e69SJohn Levoninstall -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true
105*5ca82e69SJohn Levon`install\' is up to date.]
106*5ca82e69SJohn Levon    }
107*5ca82e69SJohn Levon    [+?Example 2: Non-interactive use]{
108*5ca82e69SJohn Levon        [+?Invoke bldenv to create SUNWonbld with a single command:]
109*5ca82e69SJohn Levon        [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\']
110*5ca82e69SJohn Levon        }
111*5ca82e69SJohn Levon}
112*5ca82e69SJohn Levon[+SEE ALSO?\bnightly\b(1)]
113*5ca82e69SJohn Levon'
114*5ca82e69SJohn Levon
115*5ca82e69SJohn Levon# main
116*5ca82e69SJohn Levonbuiltin basename
117*5ca82e69SJohn Levon
118*5ca82e69SJohn Levon# boolean flags (true/false)
119*5ca82e69SJohn Levontypeset flags=(
120*5ca82e69SJohn Levon	typeset c=false
121*5ca82e69SJohn Levon	typeset f=false
122*5ca82e69SJohn Levon	typeset d=false
123*5ca82e69SJohn Levon	typeset O=false
124*5ca82e69SJohn Levon	typeset o=false
125*5ca82e69SJohn Levon	typeset t=true
126*5ca82e69SJohn Levon	typeset s=(
127*5ca82e69SJohn Levon		typeset e=false
128*5ca82e69SJohn Levon		typeset h=false
129*5ca82e69SJohn Levon		typeset d=false
130*5ca82e69SJohn Levon		typeset o=false
131*5ca82e69SJohn Levon	)
132*5ca82e69SJohn Levon	typeset d_set=false
133*5ca82e69SJohn Levon	typeset DF_build=false
134*5ca82e69SJohn Levon)
135*5ca82e69SJohn Levon
136*5ca82e69SJohn Levontypeset progname="$(basename -- "${0}")"
137*5ca82e69SJohn Levon
138*5ca82e69SJohn LevonOPTIND=1
139*5ca82e69SJohn Levon
140*5ca82e69SJohn Levonwhile getopts -a "${progname}" "${USAGE}" OPT ; do
141*5ca82e69SJohn Levon    case ${OPT} in
142*5ca82e69SJohn Levon	  c)	flags.c=true  ;;
143*5ca82e69SJohn Levon	  +c)	flags.c=false ;;
144*5ca82e69SJohn Levon	  f)	flags.f=true  ;;
145*5ca82e69SJohn Levon	  +f)	flags.f=false ;;
146*5ca82e69SJohn Levon	  d)	flags.d=true ; flags.d_set=true ;;
147*5ca82e69SJohn Levon	  +d)	flags.d=false ; flags.d_set=true ;;
148*5ca82e69SJohn Levon	  t)	flags.t=true  ;;
149*5ca82e69SJohn Levon	  +t)	flags.t=false ;;
150*5ca82e69SJohn Levon	  \?)	usage ;;
151*5ca82e69SJohn Levon    esac
152*5ca82e69SJohn Levondone
153*5ca82e69SJohn Levonshift $((OPTIND-1))
154*5ca82e69SJohn Levon
155*5ca82e69SJohn Levon# test that the path to the environment-setting file was given
156*5ca82e69SJohn Levonif (( $# < 1 )) ; then
157*5ca82e69SJohn Levon	usage
158*5ca82e69SJohn Levonfi
159*5ca82e69SJohn Levon
160*5ca82e69SJohn Levon# force locale to C
161*5ca82e69SJohn Levonexport \
162*5ca82e69SJohn Levon	LANG=C \
163*5ca82e69SJohn Levon	LC_ALL=C \
164*5ca82e69SJohn Levon	LC_COLLATE=C \
165*5ca82e69SJohn Levon	LC_CTYPE=C \
166*5ca82e69SJohn Levon	LC_MESSAGES=C \
167*5ca82e69SJohn Levon	LC_MONETARY=C \
168*5ca82e69SJohn Levon	LC_NUMERIC=C \
169*5ca82e69SJohn Levon	LC_TIME=C
170*5ca82e69SJohn Levon
171*5ca82e69SJohn Levon# clear environment variables we know to be bad for the build
172*5ca82e69SJohn Levonunset \
173*5ca82e69SJohn Levon	LD_OPTIONS \
174*5ca82e69SJohn Levon	LD_LIBRARY_PATH \
175*5ca82e69SJohn Levon	LD_AUDIT \
176*5ca82e69SJohn Levon	LD_BIND_NOW \
177*5ca82e69SJohn Levon	LD_BREADTH \
178*5ca82e69SJohn Levon	LD_CONFIG \
179*5ca82e69SJohn Levon	LD_DEBUG \
180*5ca82e69SJohn Levon	LD_FLAGS \
181*5ca82e69SJohn Levon	LD_LIBRARY_PATH_64 \
182*5ca82e69SJohn Levon	LD_NOVERSION \
183*5ca82e69SJohn Levon	LD_ORIGIN \
184*5ca82e69SJohn Levon	LD_LOADFLTR \
185*5ca82e69SJohn Levon	LD_NOAUXFLTR \
186*5ca82e69SJohn Levon	LD_NOCONFIG \
187*5ca82e69SJohn Levon	LD_NODIRCONFIG \
188*5ca82e69SJohn Levon	LD_NOOBJALTER \
189*5ca82e69SJohn Levon	LD_PRELOAD \
190*5ca82e69SJohn Levon	LD_PROFILE \
191*5ca82e69SJohn Levon	CONFIG \
192*5ca82e69SJohn Levon	GROUP \
193*5ca82e69SJohn Levon	OWNER \
194*5ca82e69SJohn Levon	REMOTE \
195*5ca82e69SJohn Levon	ENV \
196*5ca82e69SJohn Levon	ARCH \
197*5ca82e69SJohn Levon	CLASSPATH
198*5ca82e69SJohn Levon
199*5ca82e69SJohn Levon#
200*5ca82e69SJohn Levon# Setup environment variables
201*5ca82e69SJohn Levon#
202*5ca82e69SJohn Levonif [[ -f /etc/nightly.conf ]]; then
203*5ca82e69SJohn Levon	source /etc/nightly.conf
204*5ca82e69SJohn Levonfi
205*5ca82e69SJohn Levon
206*5ca82e69SJohn Levonif [[ -f "$1" ]]; then
207*5ca82e69SJohn Levon	if [[ "$1" == */* ]]; then
208*5ca82e69SJohn Levon		source "$1"
209*5ca82e69SJohn Levon	else
210*5ca82e69SJohn Levon		source "./$1"
211*5ca82e69SJohn Levon	fi
212*5ca82e69SJohn Levonelse
213*5ca82e69SJohn Levon	if [[ -f "/opt/onbld/env/$1" ]]; then
214*5ca82e69SJohn Levon		source "/opt/onbld/env/$1"
215*5ca82e69SJohn Levon	else
216*5ca82e69SJohn Levon		printf \
217*5ca82e69SJohn Levon		    'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
218*5ca82e69SJohn Levon		    "$1" "$1"
219*5ca82e69SJohn Levon		exit 1
220*5ca82e69SJohn Levon	fi
221*5ca82e69SJohn Levonfi
222*5ca82e69SJohn Levonshift
223*5ca82e69SJohn Levon
224*5ca82e69SJohn Levon# Check if we have sufficient data to continue...
225*5ca82e69SJohn Levon[[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
226*5ca82e69SJohn Levon[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
227*5ca82e69SJohn Levon[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
228*5ca82e69SJohn Levon
229*5ca82e69SJohn Levon# must match the getopts in nightly
230*5ca82e69SJohn LevonOPTIND=1
231*5ca82e69SJohn LevonNIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
232*5ca82e69SJohn Levonwhile getopts '+0ABCDdFfGIilMmNnpRrtUuwW' FLAG $NIGHTLY_OPTIONS
233*5ca82e69SJohn Levondo
234*5ca82e69SJohn Levon	case "$FLAG" in
235*5ca82e69SJohn Levon	  t)	flags.t=true  ;;
236*5ca82e69SJohn Levon	  +t)	flags.t=false ;;
237*5ca82e69SJohn Levon	  F)	flags.DF_build=true ;;
238*5ca82e69SJohn Levon	  *)	;;
239*5ca82e69SJohn Levon	esac
240*5ca82e69SJohn Levondone
241*5ca82e69SJohn Levon
242*5ca82e69SJohn Levon# DEBUG is a little bit complicated.  First, bldenv -d/+d over-rides
243*5ca82e69SJohn Levon# the env file.  Otherwise, we'll default to DEBUG iff we are *not*
244*5ca82e69SJohn Levon# building non-DEBUG bits at all.
245*5ca82e69SJohn Levonif [ "${flags.d_set}" != "true" ] && "${flags.DF_build}"; then
246*5ca82e69SJohn Levon	flags.d=true
247*5ca82e69SJohn Levonfi
248*5ca82e69SJohn Levon
249*5ca82e69SJohn LevonPOUND_SIGN="#"
250*5ca82e69SJohn Levon# have we set RELEASE_DATE in our env file?
251*5ca82e69SJohn Levonif [ -z "$RELEASE_DATE" ]; then
252*5ca82e69SJohn Levon	RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
253*5ca82e69SJohn Levonfi
254*5ca82e69SJohn LevonBUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
255*5ca82e69SJohn LevonBASEWSDIR=$(basename -- "${CODEMGR_WS}")
256*5ca82e69SJohn LevonDEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
257*5ca82e69SJohn Levonexport DEV_CM RELEASE_DATE POUND_SIGN
258*5ca82e69SJohn Levon
259*5ca82e69SJohn Levonprint 'Build type   is  \c'
260*5ca82e69SJohn Levonif ${flags.d} ; then
261*5ca82e69SJohn Levon	print 'DEBUG'
262*5ca82e69SJohn Levon	SUFFIX=""
263*5ca82e69SJohn Levon	unset RELEASE_BUILD
264*5ca82e69SJohn Levon	unset EXTRA_OPTIONS
265*5ca82e69SJohn Levon	unset EXTRA_CFLAGS
266*5ca82e69SJohn Levon
267*5ca82e69SJohn Levon	if [ -n "$DEBUG_CONSOLE_COLOR" ]; then
268*5ca82e69SJohn Levon		export DEFAULT_CONSOLE_COLOR="$DEBUG_CONSOLE_COLOR"
269*5ca82e69SJohn Levon	fi
270*5ca82e69SJohn Levonelse
271*5ca82e69SJohn Levon	# default is a non-DEBUG build
272*5ca82e69SJohn Levon	print 'non-DEBUG'
273*5ca82e69SJohn Levon	SUFFIX="-nd"
274*5ca82e69SJohn Levon	export RELEASE_BUILD=
275*5ca82e69SJohn Levon	unset EXTRA_OPTIONS
276*5ca82e69SJohn Levon	unset EXTRA_CFLAGS
277*5ca82e69SJohn Levon
278*5ca82e69SJohn Levon	if [ -n "$RELEASE_CONSOLE_COLOR" ]; then
279*5ca82e69SJohn Levon		export DEFAULT_CONSOLE_COLOR="$RELEASE_CONSOLE_COLOR"
280*5ca82e69SJohn Levon	fi
281*5ca82e69SJohn Levonfi
282*5ca82e69SJohn Levon
283*5ca82e69SJohn Levon# update build-type variables
284*5ca82e69SJohn LevonPKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
285*5ca82e69SJohn Levon
286*5ca82e69SJohn Levon#	Set PATH for a build
287*5ca82e69SJohn 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:."
288*5ca82e69SJohn Levonif [[ "${SUNWSPRO}" != "" ]]; then
289*5ca82e69SJohn Levon	export PATH="${SUNWSPRO}/bin:$PATH"
290*5ca82e69SJohn Levonfi
291*5ca82e69SJohn Levon
292*5ca82e69SJohn Levonif [[ -n "${MAKE}" ]]; then
293*5ca82e69SJohn Levon	if [[ -x "${MAKE}" ]]; then
294*5ca82e69SJohn Levon		export PATH="$(dirname -- "${MAKE}"):$PATH"
295*5ca82e69SJohn Levon	else
296*5ca82e69SJohn Levon		print "\$MAKE (${MAKE}) is not a valid executible"
297*5ca82e69SJohn Levon		exit 1
298*5ca82e69SJohn Levon	fi
299*5ca82e69SJohn Levonfi
300*5ca82e69SJohn Levon
301*5ca82e69SJohn LevonTOOLS="${SRC}/tools"
302*5ca82e69SJohn LevonTOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
303*5ca82e69SJohn Levon
304*5ca82e69SJohn Levonif "${flags.t}" ; then
305*5ca82e69SJohn Levon	export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
306*5ca82e69SJohn Levon
307*5ca82e69SJohn Levon	export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
308*5ca82e69SJohn Levon	export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
309*5ca82e69SJohn Levon	export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
310*5ca82e69SJohn Levon
311*5ca82e69SJohn Levon	export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
312*5ca82e69SJohn Levon	export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
313*5ca82e69SJohn Levon	export NDRGEN="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ndrgen"
314*5ca82e69SJohn Levon
315*5ca82e69SJohn Levon	PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
316*5ca82e69SJohn Levon	PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
317*5ca82e69SJohn Levon	export PATH
318*5ca82e69SJohn Levonfi
319*5ca82e69SJohn Levon
320*5ca82e69SJohn Levonexport DMAKE_MODE=${DMAKE_MODE:-parallel}
321*5ca82e69SJohn Levon
322*5ca82e69SJohn Levon#
323*5ca82e69SJohn Levon# Work around folks who have historically used GCC_ROOT and convert it to
324*5ca82e69SJohn Levon# GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could
325*5ca82e69SJohn Levon# mess up the case where multiple different gcc versions are being used to
326*5ca82e69SJohn Levon# shadow).
327*5ca82e69SJohn Levon#
328*5ca82e69SJohn Levonif [[ -n "${GCC_ROOT}" ]]; then
329*5ca82e69SJohn Levon	export GNUC_ROOT=${GCC_ROOT}
330*5ca82e69SJohn Levonfi
331*5ca82e69SJohn Levon
332*5ca82e69SJohn LevonDEF_STRIPFLAG="-s"
333*5ca82e69SJohn Levon
334*5ca82e69SJohn LevonTMPDIR="/tmp"
335*5ca82e69SJohn Levon
336*5ca82e69SJohn Levonexport \
337*5ca82e69SJohn Levon	PATH TMPDIR \
338*5ca82e69SJohn Levon	POUND_SIGN \
339*5ca82e69SJohn Levon	DEF_STRIPFLAG \
340*5ca82e69SJohn Levon	RELEASE_DATE
341*5ca82e69SJohn Levonunset \
342*5ca82e69SJohn Levon	CFLAGS \
343*5ca82e69SJohn Levon	LD_LIBRARY_PATH
344*5ca82e69SJohn Levon
345*5ca82e69SJohn Levon# a la ws
346*5ca82e69SJohn LevonENVLDLIBS1=
347*5ca82e69SJohn LevonENVLDLIBS2=
348*5ca82e69SJohn LevonENVLDLIBS3=
349*5ca82e69SJohn LevonENVCPPFLAGS1=
350*5ca82e69SJohn LevonENVCPPFLAGS2=
351*5ca82e69SJohn LevonENVCPPFLAGS3=
352*5ca82e69SJohn LevonENVCPPFLAGS4=
353*5ca82e69SJohn LevonPARENT_ROOT=
354*5ca82e69SJohn LevonPARENT_TOOLS_ROOT=
355*5ca82e69SJohn Levon
356*5ca82e69SJohn Levonif [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
357*5ca82e69SJohn Levon	printf \
358*5ca82e69SJohn Levon	    'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
359*5ca82e69SJohn Levon	    "$MULTI_PROTO"
360*5ca82e69SJohn Levon	export MULTI_PROTO="no"
361*5ca82e69SJohn Levonfi
362*5ca82e69SJohn Levon
363*5ca82e69SJohn Levon[[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
364*5ca82e69SJohn Levon
365*5ca82e69SJohn LevonENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
366*5ca82e69SJohn LevonENVCPPFLAGS1="-I$ROOT/usr/include"
367*5ca82e69SJohn LevonMAKEFLAGS=e
368*5ca82e69SJohn Levon
369*5ca82e69SJohn Levonexport \
370*5ca82e69SJohn Levon        ENVLDLIBS1 \
371*5ca82e69SJohn Levon        ENVLDLIBS2 \
372*5ca82e69SJohn Levon        ENVLDLIBS3 \
373*5ca82e69SJohn Levon	ENVCPPFLAGS1 \
374*5ca82e69SJohn Levon        ENVCPPFLAGS2 \
375*5ca82e69SJohn Levon        ENVCPPFLAGS3 \
376*5ca82e69SJohn Levon	ENVCPPFLAGS4 \
377*5ca82e69SJohn Levon        MAKEFLAGS \
378*5ca82e69SJohn Levon        PARENT_ROOT \
379*5ca82e69SJohn Levon        PARENT_TOOLS_ROOT
380*5ca82e69SJohn Levon
381*5ca82e69SJohn Levonprintf 'RELEASE      is %s\n'   "$RELEASE"
382*5ca82e69SJohn Levonprintf 'VERSION      is %s\n'   "$VERSION"
383*5ca82e69SJohn Levonprintf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
384*5ca82e69SJohn Levon
385*5ca82e69SJohn Levonif [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then
386*5ca82e69SJohn Levon	print "The top-level 'setup' target is available \c"
387*5ca82e69SJohn Levon	print "to build headers and tools."
388*5ca82e69SJohn Levon	print ""
389*5ca82e69SJohn Levon
390*5ca82e69SJohn Levonelif "${flags.t}" ; then
391*5ca82e69SJohn Levon	printf \
392*5ca82e69SJohn Levon	    'The tools can be (re)built with the install target in %s.\n\n' \
393*5ca82e69SJohn Levon	    "${TOOLS}"
394*5ca82e69SJohn Levonfi
395*5ca82e69SJohn Levon
396*5ca82e69SJohn Levon#
397*5ca82e69SJohn Levon# place ourselves in a new task, respecting BUILD_PROJECT if set.
398*5ca82e69SJohn Levon#
399*5ca82e69SJohn Levon/usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT}
400*5ca82e69SJohn Levon
401*5ca82e69SJohn Levonif [[ "${flags.c}" == "false" && -x "$SHELL" && \
402*5ca82e69SJohn Levon    "$(basename -- "${SHELL}")" != "csh" ]]; then
403*5ca82e69SJohn Levon	# $SHELL is set, and it's not csh.
404*5ca82e69SJohn Levon
405*5ca82e69SJohn Levon	if "${flags.f}" ; then
406*5ca82e69SJohn Levon		print 'WARNING: -f is ignored when $SHELL is not csh'
407*5ca82e69SJohn Levon	fi
408*5ca82e69SJohn Levon
409*5ca82e69SJohn Levon	printf 'Using %s as shell.\n' "$SHELL"
410*5ca82e69SJohn Levon	exec "$SHELL" ${@:+-c "$@"}
411*5ca82e69SJohn Levon
412*5ca82e69SJohn Levonelif "${flags.f}" ; then
413*5ca82e69SJohn Levon	print 'Using csh -f as shell.'
414*5ca82e69SJohn Levon	exec csh -f ${@:+-c "$@"}
415*5ca82e69SJohn Levon
416*5ca82e69SJohn Levonelse
417*5ca82e69SJohn Levon	print 'Using csh as shell.'
418*5ca82e69SJohn Levon	exec csh ${@:+-c "$@"}
419*5ca82e69SJohn Levonfi
420*5ca82e69SJohn Levon
421*5ca82e69SJohn Levon# not reached
422