Print this page
4029 remove tonic build bits
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/bldenv.sh
+++ new/usr/src/tools/scripts/bldenv.sh
1 1 #!/usr/bin/ksh93
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 26 #
27 27 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
28 28 # before spawning a shell for doing a release-style builds interactively
29 29 # and incrementally.
30 30 #
31 31
32 32 function fatal_error
33 33 {
34 34 print -u2 "${progname}: $*"
35 35 exit 1
36 36 }
37 37
38 38 function usage
39 39 {
40 40 OPTIND=0
41 41 getopts -a "${progname}" "${USAGE}" OPT '-?'
42 42 exit 2
43 43 }
44 44
45 45 function is_source_build
46 46 {
47 47 "${flags.s.e}" || "${flags.s.d}" || "${flags.s.h}" || "${flags.s.o}"
48 48 return $?
49 49 }
50 50
51 51 #
52 52 # single function for setting -S flag and doing error checking.
53 53 # usage: set_S_flag <type>
54 54 # where <type> is the source build type ("E", "D", ...).
55 55 #
56 56 function set_S_flag
57 57 {
58 58 if is_source_build; then
59 59 print 'Can only build one source variant at a time.'
60 60 exit 1
61 61 fi
62 62
63 63 case "$1" in
64 64 "E") flags.s.e=true ;;
65 65 "D") flags.s.d=true ;;
66 66 "H") flags.s.h=true ;;
67 67 "O") flags.s.o=true ;;
68 68 *) usage ;;
69 69 esac
70 70 }
71 71
72 72 typeset -r USAGE=$'+
73 73 [-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
74 74 [-author?OS/Net community <tools-discuss@opensolaris.org>]
75 75 [+NAME?bldenv - spawn shell for interactive incremental OS-Net
76 76 consolidation builds]
77 77 [+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
78 78 doing interactive and incremental builds in a workspace
79 79 already built with nightly(1). bldenv spawns a shell set up
80 80 with the same environment variables taken from an env_file,
81 81 as prepared for use with nightly(1).]
82 82 [+?In addition to running a shell for interactive use, bldenv
83 83 can optionally run a single command in the given environment,
84 84 in the vein of sh -c or su -c. This is useful for
85 85 scripting, when an interactive shell would not be. If the
86 86 command is composed of multiple shell words or contains
87 87 other shell metacharacters, it must be quoted appropriately.]
88 88 [+?bldenv is particularly useful for testing Makefile targets
89 89 like clobber, install and _msg, which otherwise require digging
90 90 through large build logs to figure out what is being
91 91 done.]
92 92 [+?bldenv is also useful if you run into build issues with the
93 93 source product or when generating OpenSolaris deliverables.
94 94 If a source product build is flagged, the environment is set
95 95 up for building the indicated source product tree, which is
96 96 assumed to have already been created. If the OpenSolaris
97 97 deliverables flag (-O) is set in NIGHTLY_OPTIONS, the
98 98 environment is set up for building just the open source.
99 99 This includes using an alternate proto area, as well as
100 100 using the closed binaries in $CODEMGR_WS/closed.skel (which
101 101 is assumed to already exist).]
102 102 [+?By default, bldenv will invoke the shell specified in
103 103 $SHELL. If $SHELL is not set or is invalid, csh will be
104 104 used.]
105 105 [c?force the use of csh, regardless of the value of $SHELL.]
106 106 [f?invoke csh with the -f (fast-start) option. This option is valid
107 107 only if $SHELL is unset or if it points to csh.]
108 108 [d?set up environment for doing DEBUG builds (default is non-DEBUG)]
109 109 [t?set up environment to use the tools in usr/src/tools (this is the
110 110 default, use +t to use the tools from /opt/onbld)]
111 111 [S]:[option?Build a variant of the source product.
112 112 The value of \aoption\a must be one of the following:]{
113 113 [+E?build the exportable source variant of the source product.]
114 114 [+D?build the domestic source (exportable + crypt) variant of
115 115 the source product.]
116 116 [+H?build hybrid source (binaries + deleted source).]
117 117 [+O?simulate an OpenSolaris (open source only) build.]
118 118 }
119 119
120 120 <env_file> [command]
121 121
122 122 [+EXAMPLES]{
123 123 [+?Example 1: Interactive use]{
124 124 [+?Use bldenv to spawn a shell to perform a DEBUG build and
125 125 testing of the Makefile targets clobber and install for
126 126 usr/src/cmd/true.]
127 127 [+\n% rlogin wopr-2 -l gk
128 128 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
129 129 Build type is DEBUG
130 130 RELEASE is 5.10
131 131 VERSION is wopr-2::on10-se::11/01/2001
132 132 RELEASE_DATE is May 2004
133 133 The top-level `setup\' target is available to build headers
134 134 and tools.
135 135 Using /usr/bin/tcsh as shell.
136 136 {root::wopr-2::49}
137 137 {root::wopr-2::49} cd $SRC/cmd/true
138 138 {root::wopr-2::50} make
139 139 {root::wopr-2::51} make clobber
140 140 /usr/bin/rm -f true true.po
141 141 {root::wopr-2::52} make
142 142 /usr/bin/rm -f true
143 143 cat true.sh > true
144 144 chmod +x true
145 145 {root::wopr-2::53} make install
146 146 install -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true
147 147 `install\' is up to date.]
148 148 }
149 149 [+?Example 2: Non-interactive use]{
150 150 [+?Invoke bldenv to create SUNWonbld with a single command:]
151 151 [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\']
152 152 }
153 153 }
154 154 [+SEE ALSO?\bnightly\b(1)]
155 155 '
156 156
157 157 # main
158 158 builtin basename
159 159
160 160 # boolean flags (true/false)
161 161 typeset flags=(
162 162 typeset c=false
163 163 typeset f=false
164 164 typeset d=false
165 165 typeset O=false
166 166 typeset o=false
167 167 typeset t=true
168 168 typeset s=(
169 169 typeset e=false
170 170 typeset h=false
171 171 typeset d=false
172 172 typeset o=false
173 173 )
174 174 )
175 175
176 176 typeset progname="$(basename -- "${0}")"
177 177
178 178 OPTIND=1
179 179 SUFFIX="-nd"
180 180
181 181 while getopts -a "${progname}" "${USAGE}" OPT ; do
182 182 case ${OPT} in
183 183 c) flags.c=true ;;
184 184 +c) flags.c=false ;;
185 185 f) flags.f=true ;;
186 186 +f) flags.f=false ;;
187 187 d) flags.d=true SUFFIX="" ;;
188 188 +d) flags.d=false SUFFIX="-nd" ;;
189 189 t) flags.t=true ;;
190 190 +t) flags.t=false ;;
191 191 S) set_S_flag "$OPTARG" ;;
192 192 \?) usage ;;
193 193 esac
194 194 done
195 195 shift $((OPTIND-1))
196 196
197 197 # test that the path to the environment-setting file was given
198 198 if (( $# < 1 )) ; then
199 199 usage
200 200 fi
201 201
202 202 # force locale to C
203 203 export \
204 204 LC_COLLATE=C \
205 205 LC_CTYPE=C \
206 206 LC_MESSAGES=C \
207 207 LC_MONETARY=C \
208 208 LC_NUMERIC=C \
209 209 LC_TIME=C
210 210
211 211 # clear environment variables we know to be bad for the build
212 212 unset \
213 213 LD_OPTIONS \
214 214 LD_LIBRARY_PATH \
215 215 LD_AUDIT \
216 216 LD_BIND_NOW \
217 217 LD_BREADTH \
218 218 LD_CONFIG \
219 219 LD_DEBUG \
220 220 LD_FLAGS \
221 221 LD_LIBRARY_PATH_64 \
222 222 LD_NOVERSION \
223 223 LD_ORIGIN \
224 224 LD_LOADFLTR \
225 225 LD_NOAUXFLTR \
226 226 LD_NOCONFIG \
227 227 LD_NODIRCONFIG \
228 228 LD_NOOBJALTER \
229 229 LD_PRELOAD \
230 230 LD_PROFILE \
231 231 CONFIG \
232 232 GROUP \
233 233 OWNER \
234 234 REMOTE \
235 235 ENV \
236 236 ARCH \
237 237 CLASSPATH
238 238
239 239 #
240 240 # Setup environment variables
241 241 #
242 242 if [[ -f /etc/nightly.conf ]]; then
243 243 source /etc/nightly.conf
244 244 fi
245 245
246 246 if [[ -f "$1" ]]; then
247 247 if [[ "$1" == */* ]]; then
248 248 source "$1"
249 249 else
250 250 source "./$1"
251 251 fi
252 252 else
253 253 if [[ -f "/opt/onbld/env/$1" ]]; then
254 254 source "/opt/onbld/env/$1"
255 255 else
256 256 printf \
257 257 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
258 258 "$1" "$1"
259 259 exit 1
260 260 fi
261 261 fi
262 262 shift
263 263
264 264 # contents of stdenv.sh inserted after next line:
265 265 # STDENV_START
266 266 # STDENV_END
267 267
268 268 # Check if we have sufficient data to continue...
269 269 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
270 270 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
271 271 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
272 272
273 273 # must match the getopts in nightly.sh
274 274 OPTIND=1
275 275 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
276 276 while getopts '+0AaBCDdFfGIilMmNnOopRrS:tUuWwXxz' FLAG "$NIGHTLY_OPTIONS"
277 277 do
278 278 case "$FLAG" in
279 279 O) flags.O=true ;;
280 280 +O) flags.O=false ;;
281 281 o) flags.o=true ;;
282 282 +o) flags.o=false ;;
283 283 t) flags.t=true ;;
284 284 +t) flags.t=false ;;
285 285 S) set_S_flag "$OPTARG" ;;
286 286 *) ;;
287 287 esac
288 288 done
289 289
290 290 POUND_SIGN="#"
291 291 # have we set RELEASE_DATE in our env file?
292 292 if [ -z "$RELEASE_DATE" ]; then
293 293 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
294 294 fi
295 295 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
296 296 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
297 297 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
298 298 export DEV_CM RELEASE_DATE POUND_SIGN
299 299
300 300 export INTERNAL_RELEASE_BUILD=
301 301
302 302 print 'Build type is \c'
303 303 if ${flags.d} ; then
304 304 print 'DEBUG'
305 305 unset RELEASE_BUILD
306 306 unset EXTRA_OPTIONS
307 307 unset EXTRA_CFLAGS
308 308 else
309 309 # default is a non-DEBUG build
310 310 print 'non-DEBUG'
311 311 export RELEASE_BUILD=
312 312 unset EXTRA_OPTIONS
313 313 unset EXTRA_CFLAGS
314 314 fi
315 315
316 316 [[ "${flags.O}" == "true" ]] && export MULTI_PROTO="yes"
317 317
318 318 # update build-type variables
319 319 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
320 320
321 321 # Append source version
322 322 if "${flags.s.e}" ; then
323 323 VERSION+=":EXPORT"
324 324 SRC="${EXPORT_SRC}/usr/src"
325 325 fi
326 326
327 327 if "${flags.s.d}" ; then
328 328 VERSION+=":DOMESTIC"
329 329 SRC="${EXPORT_SRC}/usr/src"
330 330 fi
331 331
332 332 if "${flags.s.h}" ; then
333 333 VERSION+=":HYBRID"
334 334 SRC="${EXPORT_SRC}/usr/src"
335 335 fi
336 336
337 337 if "${flags.s.o}" ; then
338 338 VERSION+=":OPEN_ONLY"
339 339 SRC="${OPEN_SRCDIR}/usr/src"
340 340 fi
341 341
342 342 # Set PATH for a build
343 343 PATH="/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:."
344 344 if [[ "${SUNWSPRO}" != "" ]]; then
345 345 export PATH="${SUNWSPRO}/bin:$PATH"
346 346 fi
347 347
348 348 TOOLS="${SRC}/tools"
349 349 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
350 350
351 351 if "${flags.t}" ; then
352 352 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
353 353
354 354 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
355 355 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
356 356 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
357 357
358 358 export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
359 359 export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
360 360
361 361 export CTFCVTPTBL="${TOOLS_PROTO}/opt/onbld/bin/ctfcvtptbl"
362 362 export CTFFINDMOD="${TOOLS_PROTO}/opt/onbld/bin/ctffindmod"
363 363
364 364 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
365 365 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
366 366 export PATH
367 367 fi
368 368
369 369 export DMAKE_MODE=${DMAKE_MODE:-parallel}
370 370
371 371 if "${flags.o}" ; then
372 372 export CH=
373 373 else
374 374 unset CH
375 375 fi
376 376 DEF_STRIPFLAG="-s"
377 377
378 378 TMPDIR="/tmp"
379 379
380 380 # "o_FLAG" is used by "nightly.sh" (it may be useful to rename this
381 381 # variable using a more descriptive name later)
382 382 export o_FLAG="$(${flags.o} && print 'y' || print 'n')"
383 383
384 384 export \
385 385 PATH TMPDIR \
386 386 POUND_SIGN \
387 387 DEF_STRIPFLAG \
388 388 RELEASE_DATE
389 389 unset \
390 390 CFLAGS \
391 391 LD_LIBRARY_PATH
392 392
393 393 # a la ws
394 394 ENVLDLIBS1=
395 395 ENVLDLIBS2=
396 396 ENVLDLIBS3=
397 397 ENVCPPFLAGS1=
398 398 ENVCPPFLAGS2=
399 399 ENVCPPFLAGS3=
400 400 ENVCPPFLAGS4=
401 401 PARENT_ROOT=
402 402 PARENT_TOOLS_ROOT=
↓ open down ↓ |
402 lines elided |
↑ open up ↑ |
403 403
404 404 if [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
405 405 printf \
406 406 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
407 407 "$MULTI_PROTO"
408 408 export MULTI_PROTO="no"
409 409 fi
410 410
411 411 [[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
412 412
413 -export TONICBUILD="#"
414 -
415 413 if "${flags.O}" ; then
416 414 print "OpenSolaris closed binary generation requires "
417 415 print "closed tree"
418 416 exit 1
419 417 fi
420 418
421 419 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
422 420 ENVCPPFLAGS1="-I$ROOT/usr/include"
423 421 MAKEFLAGS=e
424 422
425 423 export \
426 424 ENVLDLIBS1 \
427 425 ENVLDLIBS2 \
428 426 ENVLDLIBS3 \
429 427 ENVCPPFLAGS1 \
430 428 ENVCPPFLAGS2 \
431 429 ENVCPPFLAGS3 \
432 430 ENVCPPFLAGS4 \
433 431 MAKEFLAGS \
434 432 PARENT_ROOT \
435 433 PARENT_TOOLS_ROOT
436 434
437 435 printf 'RELEASE is %s\n' "$RELEASE"
438 436 printf 'VERSION is %s\n' "$VERSION"
439 437 printf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
440 438
441 439 if [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then
442 440 print "The top-level 'setup' target is available \c"
443 441 print "to build headers and tools."
444 442 print ""
445 443
446 444 elif "${flags.t}" ; then
447 445 printf \
448 446 'The tools can be (re)built with the install target in %s.\n\n' \
449 447 "${TOOLS}"
450 448 fi
451 449
452 450 #
453 451 # place ourselves in a new task, respecting BUILD_PROJECT if set.
454 452 #
455 453 /usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT}
456 454
457 455 if [[ "${flags.c}" == "false" && -x "$SHELL" && \
458 456 "$(basename -- "${SHELL}")" != "csh" ]]; then
459 457 # $SHELL is set, and it's not csh.
460 458
461 459 if "${flags.f}" ; then
462 460 print 'WARNING: -f is ignored when $SHELL is not csh'
463 461 fi
464 462
465 463 printf 'Using %s as shell.\n' "$SHELL"
466 464 exec "$SHELL" ${@:+-c "$@"}
467 465
468 466 elif "${flags.f}" ; then
469 467 print 'Using csh -f as shell.'
470 468 exec csh -f ${@:+-c "$@"}
471 469
472 470 else
473 471 print 'Using csh as shell.'
474 472 exec csh ${@:+-c "$@"}
475 473 fi
476 474
477 475 # not reached
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX