good night nightly(1); long live 'make build'
[unleashed.git] / tools / bldenv.sh
blob230f48e3577af1ec4ee15260a6db4258e3a1b899
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 # make sure we are not outside of the git checkout when sourcing env.sh; it has
91 # some git commands that rely on that
92 cwd=$(pwd)
93 cd $dir
94 if [[ -f "env.sh" ]]; then
95 . ./env.sh
96 else
97 printf \
98 'Cannot find env file env.sh\n'
99 exit 1
101 cd $cwd
103 # Check if we have sufficient data to continue...
104 [[ -n "${SRCTOP}" ]] || fatal_error "Error: Variable SRCTOP not set."
105 [[ -d "${SRCTOP}" ]] || fatal_error "Error: ${SRCTOP} is not a directory."
106 [[ -f "${SRCTOP}/usr/src/Makefile" ]] || fatal_error "Error: ${SRCTOP}/usr/src/Makefile not found."
108 POUND_SIGN="#"
109 # have we set RELEASE_DATE in our env file?
110 if [ -z "$RELEASE_DATE" ]; then
111 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
113 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
114 BASEWSDIR=$(basename -- "${SRCTOP}")
115 export RELEASE_DATE POUND_SIGN
117 # update build-type variables
118 PKGARCHIVE="${PKGARCHIVE}"
120 # Set PATH for a build
121 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"
123 if [[ -n "${MAKE}" ]]; then
124 if [[ -x "${MAKE}" ]]; then
125 export PATH="$(dirname -- "${MAKE}"):$PATH"
126 else
127 print "\$MAKE (${MAKE}) is not a valid executible"
128 exit 1
132 TOOLS="${SRC}/tools"
133 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
135 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
137 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
138 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
139 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
141 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
142 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
143 export PATH
145 export DMAKE_MODE=${DMAKE_MODE:-parallel}
147 DEF_STRIPFLAG="-s"
149 TMPDIR="/tmp"
151 export \
152 PATH TMPDIR \
153 POUND_SIGN \
154 DEF_STRIPFLAG \
155 RELEASE_DATE
156 unset \
157 CFLAGS \
158 LD_LIBRARY_PATH
160 # a la ws
161 ENVLDLIBS1=
162 ENVLDLIBS2=
163 ENVLDLIBS3=
164 ENVCPPFLAGS1=
165 ENVCPPFLAGS2=
166 ENVCPPFLAGS3=
167 ENVCPPFLAGS4=
169 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
170 ENVCPPFLAGS1="-I$ROOT/usr/include"
171 MAKEFLAGS=e
173 export \
174 ENVLDLIBS1 \
175 ENVLDLIBS2 \
176 ENVLDLIBS3 \
177 ENVCPPFLAGS1 \
178 ENVCPPFLAGS2 \
179 ENVCPPFLAGS3 \
180 ENVCPPFLAGS4 \
181 MAKEFLAGS
183 export RELEASE_BUILD=
184 unset EXTRA_OPTIONS
185 unset EXTRA_CFLAGS
187 if [ -n "$*" ]; then
188 exec "$@"
191 ENV=${dir}/ksh.env exec /bin/ksh