bldenv: remove newtask & option flags, add PS1 indicator to interactive
[unleashed.git] / tools / bldenv.sh
blob6e98ddab9bbe972ff2155faa5c5b7541474019b0
1 #!/bin/ksh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
28 # Uses "env.sh" file to set shell variables before spawning a shell for doing a
29 # release-style builds interactively and incrementally.
32 function fatal_error
34 print -u2 "${progname}: $*"
35 exit 1
38 function usage
40 print -u2 "usage: ${progname} [command [args]]"
41 exit 2
44 progname="$(basename -- "${0}")"
45 dir="$(dirname $0)"
47 # force locale to C
48 export \
49 LANG=C \
50 LC_ALL=C \
51 LC_COLLATE=C \
52 LC_CTYPE=C \
53 LC_MESSAGES=C \
54 LC_MONETARY=C \
55 LC_NUMERIC=C \
56 LC_TIME=C
58 # clear environment variables we know to be bad for the build
59 unset \
60 LD_OPTIONS \
61 LD_LIBRARY_PATH \
62 LD_AUDIT \
63 LD_BIND_NOW \
64 LD_BREADTH \
65 LD_CONFIG \
66 LD_DEBUG \
67 LD_FLAGS \
68 LD_LIBRARY_PATH_64 \
69 LD_NOVERSION \
70 LD_ORIGIN \
71 LD_LOADFLTR \
72 LD_NOAUXFLTR \
73 LD_NOCONFIG \
74 LD_NODIRCONFIG \
75 LD_NOOBJALTER \
76 LD_PRELOAD \
77 LD_PROFILE \
78 CONFIG \
79 GROUP \
80 OWNER \
81 REMOTE \
82 ENV \
83 ARCH \
84 CLASSPATH
87 # Setup environment variables
90 env=${dir}/env.sh
91 if [[ -f "$env" ]]; then
92 . "$env"
93 else
94 printf \
95 'Cannot find env file "%s"\n' "$env"
96 exit 1
99 # Check if we have sufficient data to continue...
100 [[ -n "${SRCTOP}" ]] || fatal_error "Error: Variable SRCTOP not set."
101 [[ -d "${SRCTOP}" ]] || fatal_error "Error: ${SRCTOP} is not a directory."
102 [[ -f "${SRCTOP}/usr/src/Makefile" ]] || fatal_error "Error: ${SRCTOP}/usr/src/Makefile not found."
104 POUND_SIGN="#"
105 # have we set RELEASE_DATE in our env file?
106 if [ -z "$RELEASE_DATE" ]; then
107 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
109 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
110 BASEWSDIR=$(basename -- "${SRCTOP}")
111 export RELEASE_DATE POUND_SIGN
113 # update build-type variables
114 PKGARCHIVE="${PKGARCHIVE}"
116 # Set PATH for a build
117 PATH="/opt/onbld/bin:/opt/onbld/bin/${MACH}:/usr/bin:/usr/sbin:/usr/ucb:/usr/etc:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:.:/opt/SUNWspro/bin"
119 if [[ -n "${MAKE}" ]]; then
120 if [[ -x "${MAKE}" ]]; then
121 export PATH="$(dirname -- "${MAKE}"):$PATH"
122 else
123 print "\$MAKE (${MAKE}) is not a valid executible"
124 exit 1
128 TOOLS="${SRC}/tools"
129 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
131 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
133 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
134 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
135 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
137 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
138 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
139 export PATH
141 export DMAKE_MODE=${DMAKE_MODE:-parallel}
143 DEF_STRIPFLAG="-s"
145 TMPDIR="/tmp"
147 export \
148 PATH TMPDIR \
149 POUND_SIGN \
150 DEF_STRIPFLAG \
151 RELEASE_DATE
152 unset \
153 CFLAGS \
154 LD_LIBRARY_PATH
156 # a la ws
157 ENVLDLIBS1=
158 ENVLDLIBS2=
159 ENVLDLIBS3=
160 ENVCPPFLAGS1=
161 ENVCPPFLAGS2=
162 ENVCPPFLAGS3=
163 ENVCPPFLAGS4=
165 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
166 ENVCPPFLAGS1="-I$ROOT/usr/include"
167 MAKEFLAGS=e
169 export \
170 ENVLDLIBS1 \
171 ENVLDLIBS2 \
172 ENVLDLIBS3 \
173 ENVCPPFLAGS1 \
174 ENVCPPFLAGS2 \
175 ENVCPPFLAGS3 \
176 ENVCPPFLAGS4 \
177 MAKEFLAGS
179 export RELEASE_BUILD=
180 unset EXTRA_OPTIONS
181 unset EXTRA_CFLAGS
183 if [ -n "$*" ]; then
184 exec "$@"
187 ENV=${dir}/ksh.env exec /bin/ksh