xref: /illumos-gate/usr/src/tools/env/illumos.sh (revision de41ff85)
1fb9f9b97Skupfer#
2fb9f9b97Skupfer# CDDL HEADER START
3fb9f9b97Skupfer#
4fb9f9b97Skupfer# The contents of this file are subject to the terms of the
529949e86Sstevel# Common Development and Distribution License (the "License").
629949e86Sstevel# You may not use this file except in compliance with the License.
7fb9f9b97Skupfer#
8fb9f9b97Skupfer# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fb9f9b97Skupfer# or http://www.opensolaris.org/os/licensing.
10fb9f9b97Skupfer# See the License for the specific language governing permissions
11fb9f9b97Skupfer# and limitations under the License.
12fb9f9b97Skupfer#
13fb9f9b97Skupfer# When distributing Covered Code, include this CDDL HEADER in each
14fb9f9b97Skupfer# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fb9f9b97Skupfer# If applicable, add the following below this CDDL HEADER, with the
16fb9f9b97Skupfer# fields enclosed by brackets "[]" replaced with your own identifying
17fb9f9b97Skupfer# information: Portions Copyright [yyyy] [name of copyright owner]
18fb9f9b97Skupfer#
19fb9f9b97Skupfer# CDDL HEADER END
20fb9f9b97Skupfer#
2178add226Sjmcp# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
223cb00cf1SJoshua M. Clulow# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
2336afce5dSRichard Lowe# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
241f2ca518SDan McDonald# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
250ae9a84fSAndrew Stormont# Copyright 2016 RackTop Systems.
268d139918SAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
275ca82e69SJohn Levon# Copyright 2020 Joyent, Inc.
28864a8d69SBill Sommerfeld# Copyright 2023 Bill Sommerfeld
29fb9f9b97Skupfer#
305ca82e69SJohn Levon# - This file is sourced by "bldenv" and "nightly" and should not
3136acdd11SJohn Levon#   be executed directly.
3236acdd11SJohn Levon# - This script is only interpreted by ksh93 and explicitly allows the
3336acdd11SJohn Levon#   use of ksh93 language extensions.
3436acdd11SJohn Levon
3536acdd11SJohn Levon
3636acdd11SJohn Levon# -----------------------------------------------------------------------------
3736acdd11SJohn Levon# Parameters you are likely to want to change
3836acdd11SJohn Levon# -----------------------------------------------------------------------------
399a70fc3bSMark J. Nelson
40d7693b08SRoland Mainz#       DEBUG build only (-D, -F)
41d7693b08SRoland Mainz#       do not bringover from the parent (-n)
42d7693b08SRoland Mainz#       runs 'make check' (-C)
432c2a4b29SRichard Lowe#       checks for new interfaces in libraries (-A)
44d7693b08SRoland Mainz#       sends mail on completion (-m and the MAILTO variable)
45d7693b08SRoland Mainz#       creates packages for PIT/RE (-p)
46d7693b08SRoland Mainz#       checks for changes in ELF runpaths (-r)
47d7693b08SRoland Mainz#       build and use this workspace's tools in $SRC/tools (-t)
48f9008f8dSToomas Soomeexport NIGHTLY_OPTIONS='-FnCDAmprt'
49d7693b08SRoland Mainz
5036acdd11SJohn Levon# Some scripts optionally send mail messages to MAILTO.
5136acdd11SJohn Levon#export MAILTO=
5236acdd11SJohn Levon
5338e64a37SJosef 'Jeff' Sipek# CODEMGR_WS - where is your workspace at
54*de41ff85SBill Sommerfeldexport CODEMGR_WS="${CODEMGR_WS:-`git rev-parse --show-toplevel`}"
55fb9f9b97Skupfer
5636acdd11SJohn Levon# Compilers may be specified using the following variables:
5736acdd11SJohn Levon# PRIMARY_CC	- primary C compiler
5836acdd11SJohn Levon# PRIMARY_CCC	- primary C++ compiler
5936acdd11SJohn Levon#
6036acdd11SJohn Levon# SHADOW_CCS    - list of shadow C compilers
6136acdd11SJohn Levon# SHADOW_CCCS	- list of shadow C++ compilers
6236acdd11SJohn Levon#
6336acdd11SJohn Levon# Each entry has the form <name>,<path to binary>,<style> where name is a
6436acdd11SJohn Levon# free-form name (possibly used in the makefiles to guard options), path is
6536acdd11SJohn Levon# the path to the executable.  style is the 'style' of command line taken by
6636acdd11SJohn Levon# the compiler, currently either gnu (or gcc) or sun (or cc), which is also
6736acdd11SJohn Levon# used by Makefiles to guard options.
6836acdd11SJohn Levon#
6936acdd11SJohn Levon# for example:
7036acdd11SJohn Levon# export PRIMARY_CC=gcc4,/opt/gcc/4.4.4/bin/gcc,gnu
7136acdd11SJohn Levon# export PRIMARY_CCC=gcc4,/opt/gcc/4.4.4/bin/g++,gnu
7236acdd11SJohn Levon# export SHADOW_CCS=studio12,/opt/SUNWspro/bin/cc,sun
7336acdd11SJohn Levon# export SHADOW_CCCS=studio12,/opt/SUNWspro/bin/CC,sun
7436acdd11SJohn Levon#
7536acdd11SJohn Levon# There can be several space-separated entries in SHADOW_* to run multiple
7636acdd11SJohn Levon# shadow compilers.
7736acdd11SJohn Levon#
7836acdd11SJohn Levon# To disable shadow compilation, unset SHADOW_* or set them to the empty string.
7936acdd11SJohn Levon#
8069cb22eaSAndy Fiddamanexport GNUC_ROOT=/usr/gcc/10
8169cb22eaSAndy Fiddamanexport PRIMARY_CC=gcc10,$GNUC_ROOT/bin/gcc,gnu
8269cb22eaSAndy Fiddamanexport PRIMARY_CCC=gcc10,$GNUC_ROOT/bin/g++,gnu
8369cb22eaSAndy Fiddamanexport SHADOW_CCS=gcc7,/usr/gcc/7/bin/gcc,gnu
8469cb22eaSAndy Fiddamanexport SHADOW_CCCS=gcc7,/usr/gcc/7/bin/g++,gnu
8536acdd11SJohn Levon
867ae7577cSJohn Levon# comment to disable smatch
877ae7577cSJohn Levonexport ENABLE_SMATCH=1
881f5207b7SJohn Levon
8936acdd11SJohn Levon# Comment this out to disable support for SMB printing, i.e. if you
9036acdd11SJohn Levon# don't want to bother providing the CUPS headers this needs.
9136acdd11SJohn Levonexport ENABLE_SMB_PRINTING=
9236acdd11SJohn Levon
9336acdd11SJohn Levon# If your distro uses certain versions of Perl, make sure either Makefile.master
9436acdd11SJohn Levon# contains your new defaults OR your .env file sets them.
9536acdd11SJohn Levon# These are how you would override for building on OmniOS r151028, for example.
9636acdd11SJohn Levon#export PERL_VERSION=5.28
970ae9a84fSAndrew Stormont#export PERL_VARIANT=-thread-multi
9836acdd11SJohn Levon#export PERL_PKGVERS=
9936acdd11SJohn Levon
1000ae9a84fSAndrew Stormont# To disable building of the 32-bit or 64-bit perl modules (or both),
1010ae9a84fSAndrew Stormont# uncomment these lines:
1020ae9a84fSAndrew Stormont#export BUILDPERL32='#'
1030ae9a84fSAndrew Stormont#export BUILDPERL64='#'
1040ae9a84fSAndrew Stormont
10536acdd11SJohn Levon# If your distro uses certain versions of Python, make sure either
10636acdd11SJohn Levon# Makefile.master contains your new defaults OR your .env file sets them.
10736afce5dSRichard Lowe#export PYTHON3_VERSION=3.9
10836afce5dSRichard Lowe#export PYTHON3_PKGVERS=-39
10936afce5dSRichard Lowe#export PYTHON3_SUFFIX=
11036acdd11SJohn Levon
1113c562093SToomas Soome# Set console color scheme either by build type:
1123c562093SToomas Soome#
1133c562093SToomas Soome#export RELEASE_CONSOLE_COLOR="-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_BLACK \
1143c562093SToomas Soome#	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_WHITE"
1153c562093SToomas Soome#
1163c562093SToomas Soome#export DEBUG_CONSOLE_COLOR="-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_RED \
1173c562093SToomas Soome#	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_WHITE"
1183c562093SToomas Soome#
1193c562093SToomas Soome# or just one for any build type:
1203c562093SToomas Soome#
1213c562093SToomas Soome#export DEFAULT_CONSOLE_COLOR="-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_BLACK \
1223c562093SToomas Soome#	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_WHITE"
1233c562093SToomas Soome
12436acdd11SJohn Levon# Set if your distribution has different package versioning
12536acdd11SJohn Levon#export PKGVERS_BRANCH=2018.0.0.17900
12636acdd11SJohn Levon
12751396a8eSPeter Tribble# Skip Java 11 builds on distributions that don't support it
12851396a8eSPeter Tribble#export BLD_JAVA_11=
12936acdd11SJohn Levon
13036acdd11SJohn Levon# POST_NIGHTLY can be any command to be run at the end of nightly.  See
13136acdd11SJohn Levon# nightly(1) for interactions between environment variables and this command.
13236acdd11SJohn Levon#POST_NIGHTLY=
13336acdd11SJohn Levon
1348eb8717cSJohn Levon# Populates /etc/versions/build on each nightly run
1358eb8717cSJohn Levonexport BUILDVERSION_EXEC="git describe --all --long --dirty"
1368eb8717cSJohn Levon
13736acdd11SJohn Levon# -----------------------------------------------------------------------------
13836acdd11SJohn Levon# You are less likely to need to modify parameters below.
13936acdd11SJohn Levon# -----------------------------------------------------------------------------
14036acdd11SJohn Levon
141d43a4e79SJeppe Toustrup# Maximum number of dmake jobs.  The recommended number is 2 + NCPUS,
142d43a4e79SJeppe Toustrup# where NCPUS is the number of logical CPUs on your build system.
143d7693b08SRoland Mainzfunction maxjobs
144d7693b08SRoland Mainz{
145d7693b08SRoland Mainz	nameref maxjobs=$1
146d7693b08SRoland Mainz	integer ncpu
147d7693b08SRoland Mainz	integer -r min_mem_per_job=512 # minimum amount of memory for a job
148d7693b08SRoland Mainz
149d7693b08SRoland Mainz	ncpu=$(builtin getconf ; getconf 'NPROCESSORS_ONLN')
150d7693b08SRoland Mainz	(( maxjobs=ncpu + 2 ))
151aa9ef484SJohn Levon
152d7693b08SRoland Mainz	# Throttle number of parallel jobs launched by dmake to a value which
153d7693b08SRoland Mainz	# gurantees that all jobs have enough memory. This was added to avoid
154d7693b08SRoland Mainz	# excessive paging/swapping in cases of virtual machine installations
155d7693b08SRoland Mainz	# which have lots of CPUs but not enough memory assigned to handle
156d7693b08SRoland Mainz	# that many parallel jobs
157d7693b08SRoland Mainz	if [[ $(/usr/sbin/prtconf 2>'/dev/null') == ~(E)Memory\ size:\ ([[:digit:]]+)\ Megabytes ]] ; then
158d7693b08SRoland Mainz		integer max_jobs_per_memory # parallel jobs which fit into physical memory
159d7693b08SRoland Mainz		integer physical_memory # physical memory installed
160d7693b08SRoland Mainz
161d7693b08SRoland Mainz		# The array ".sh.match" contains the contents of capturing
162d7693b08SRoland Mainz		# brackets in the last regex, .sh.match[1] will contain
163d7693b08SRoland Mainz		# the value matched by ([[:digit:]]+), i.e. the amount of
164d7693b08SRoland Mainz		# memory installed
165d7693b08SRoland Mainz		physical_memory="10#${.sh.match[1]}"
166aa9ef484SJohn Levon
167d7693b08SRoland Mainz		((
168d7693b08SRoland Mainz			max_jobs_per_memory=round(physical_memory/min_mem_per_job) ,
169d7693b08SRoland Mainz			maxjobs=fmax(2, fmin(maxjobs, max_jobs_per_memory))
170d7693b08SRoland Mainz		))
171d7693b08SRoland Mainz	fi
172d7693b08SRoland Mainz
173d7693b08SRoland Mainz	return 0
174fb9f9b97Skupfer}
175d7693b08SRoland Mainz
176d7693b08SRoland Mainzmaxjobs DMAKE_MAX_JOBS # "DMAKE_MAX_JOBS" passed as ksh(1) name reference
177d7693b08SRoland Mainzexport DMAKE_MAX_JOBS
178fb9f9b97Skupfer
179fb9f9b97Skupfer# path to onbld tool binaries
180d7693b08SRoland MainzONBLD_BIN='/opt/onbld/bin'
181fb9f9b97Skupfer
182fb9f9b97Skupfer# PARENT_WS is used to determine the parent of this workspace. This is
183fb9f9b97Skupfer# for the options that deal with the parent workspace (such as where the
184fb9f9b97Skupfer# proto area will go).
185*de41ff85SBill Sommerfeldexport PARENT_WS="${PARENT_WS:-}"
186fb9f9b97Skupfer
1879a70fc3bSMark J. Nelson# CLONE_WS is the workspace nightly should do a bringover from.
18836acdd11SJohn Levon# The bringover, if any, is done as STAFFER.
189*de41ff85SBill Sommerfeldexport CLONE_WS="${CLONE_WS:-}"
190fb9f9b97Skupfer
191fb9f9b97Skupfer# Set STAFFER to your own login as gatekeeper or developer
192fb9f9b97Skupfer# The point is to use group "staff" and avoid referencing the parent
193fb9f9b97Skupfer# workspace as root.
194d7693b08SRoland Mainzexport STAFFER="$LOGNAME"
19536acdd11SJohn Levonexport MAILTO="${MAILTO:-$STAFFER}"
196fb9f9b97Skupfer
1973cb00cf1SJoshua M. Clulow# If you wish the mail messages to be From: an arbitrary address, export
1983cb00cf1SJoshua M. Clulow# MAILFROM.
1993cb00cf1SJoshua M. Clulow#export MAILFROM="user@example.com"
2003cb00cf1SJoshua M. Clulow
201bbf21555SRichard Lowe# The project (see project(5)) under which to run this build.  If not
202fb9f9b97Skupfer# specified, the build is simply run in a new task in the current project.
203d7693b08SRoland Mainzexport BUILD_PROJECT=''
204fb9f9b97Skupfer
20560a61f7aSJosef 'Jeff' Sipek# You should not need to change the next three lines
206d7693b08SRoland Mainzexport ATLOG="$CODEMGR_WS/log"
207d7693b08SRoland Mainzexport LOGFILE="$ATLOG/nightly.log"
208d7693b08SRoland Mainzexport MACH="$(uname -p)"
209fb9f9b97Skupfer
210081d8c97SJeppe Toustrup#
2111a49874bSJosef 'Jeff' Sipek#  The following macro points to the closed binaries.  Once illumos has
2121a49874bSJosef 'Jeff' Sipek#  totally freed itself, we can remove this reference.
213081d8c97SJeppe Toustrup#
214081d8c97SJeppe Toustrup# Location of encumbered binaries.
215a190135aSRobert Mustacchiexport ON_CLOSED_BINS="/opt/onbld/closed"
216081d8c97SJeppe Toustrup
217fb9f9b97Skupfer# REF_PROTO_LIST - for comparing the list of stuff in your proto area
218fb9f9b97Skupfer# with. Generally this should be left alone, since you want to see differences
219fb9f9b97Skupfer# from your parent (the gate).
220fb9f9b97Skupfer#
221d7693b08SRoland Mainzexport REF_PROTO_LIST="$PARENT_WS/usr/src/proto_list_${MACH}"
222fb9f9b97Skupfer
22386dc0e00SRichard Lowe
22486dc0e00SRichard Loweexport ROOT="$CODEMGR_WS/proto/root_${MACH}"
22586dc0e00SRichard Loweexport SRC="$CODEMGR_WS/usr/src"
22686dc0e00SRichard Loweexport MULTI_PROTO="no"
22786dc0e00SRichard Lowe
228fb9f9b97Skupfer#
229fb9f9b97Skupfer#	build environment variables, including version info for mcs, motd,
230fb9f9b97Skupfer# motd, uname and boot messages. Mostly you shouldn't change this except
231fb9f9b97Skupfer# when the release slips (nah) or you move an environment file to a new
232fb9f9b97Skupfer# release
233fb9f9b97Skupfer#
234*de41ff85SBill Sommerfeldexport VERSION="${VERSION:-`git describe --long --all HEAD | cut -d/ -f2-`}"
235fb9f9b97Skupfer
236fb9f9b97Skupfer#
237fb9f9b97Skupfer# the RELEASE and RELEASE_DATE variables are set in Makefile.master;
238fb9f9b97Skupfer# there might be special reasons to override them here, but that
239fb9f9b97Skupfer# should not be the case in general
240fb9f9b97Skupfer#
241d7693b08SRoland Mainz# export RELEASE='5.11'
242d7693b08SRoland Mainz# export RELEASE_DATE='October 2007'
243fb9f9b97Skupfer
244fb9f9b97Skupfer# proto area in parent for optionally depositing a copy of headers and
245fb9f9b97Skupfer# libraries corresponding to the protolibs target
246fb9f9b97Skupfer# not applicable given the NIGHTLY_OPTIONS
247fb9f9b97Skupfer#
248d7693b08SRoland Mainzexport PARENT_ROOT="$PARENT_WS/proto/root_$MACH"
249d7693b08SRoland Mainzexport PARENT_TOOLS_ROOT="$PARENT_WS/usr/src/tools/proto/root_$MACH-nd"
250fb9f9b97Skupfer
251ead1f93eSLiane Praza# Package creation variables.  You probably shouldn't change these,
252ead1f93eSLiane Praza# either.
253ead1f93eSLiane Praza#
254ead1f93eSLiane Praza# PKGARCHIVE determines where the repository will be created.
255fb9f9b97Skupfer#
256ead1f93eSLiane Praza# PKGPUBLISHER_REDIST controls the publisher setting for the repository.
257fb9f9b97Skupfer#
258d7693b08SRoland Mainzexport PKGARCHIVE="${CODEMGR_WS}/packages/${MACH}/nightly"
259d7693b08SRoland Mainz# export PKGPUBLISHER_REDIST='on-redist'
260fb9f9b97Skupfer
261efcb7078SYuri Pankov# Package manifest format version.
26286d41711SAndy Fiddamanexport PKGFMT_OUTPUT='v2'
263efcb7078SYuri Pankov
264864a8d69SBill Sommerfeld# We want make to do as much as it can, just in case there's more than
265fb9f9b97Skupfer# one problem.
266864a8d69SBill Sommerfeld# We also must set e in MAKEFLAGS as the makefiles depend on importing
267864a8d69SBill Sommerfeld# the environment variables set here.
268864a8d69SBill Sommerfeldexport MAKEFLAGS='ke'
269fb9f9b97Skupfer
270fb9f9b97Skupfer# Build tools - don't change these unless you know what you're doing.  These
271bd93c05dSAlexander Eremin# variables allows you to get the compilers and onbld files locally.
272bd93c05dSAlexander Eremin# Set BUILD_TOOLS to pull everything from one location.
273fb9f9b97Skupfer# Alternately, you can set ONBLD_TOOLS to where you keep the contents of
2748c426718SRichard Lowe# SUNWonbld.
275d7693b08SRoland Mainzexport BUILD_TOOLS='/opt'
276d7693b08SRoland Mainz#export ONBLD_TOOLS='/opt/onbld'
277fb9f9b97Skupfer
278fb9f9b97Skupfer# Set this flag to 'n' to disable the use of 'checkpaths'.  The default,
279fb9f9b97Skupfer# if the 'N' option is not specified, is to run this test.
280d7693b08SRoland Mainz#CHECK_PATHS='y'
2811f5207b7SJohn Levon
28286d41711SAndy Fiddamanif [[ "$ENABLE_SMATCH" == "1" ]]; then
2831f5207b7SJohn Levon	SMATCHBIN=$CODEMGR_WS/usr/src/tools/proto/root_$MACH-nd/opt/onbld/bin/$MACH/smatch
2841f5207b7SJohn Levon	export SHADOW_CCS="$SHADOW_CCS smatch,$SMATCHBIN,smatch"
2851f5207b7SJohn Levonfi
286