xref: /illumos-gate/usr/src/tools/env/illumos.sh (revision 8c426718)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
22# Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
23# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
24# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
25# Copyright 2016 RackTop Systems.
26# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
27# Copyright 2020 Joyent, Inc.
28#
29# - This file is sourced by "bldenv" and "nightly" and should not
30#   be executed directly.
31# - This script is only interpreted by ksh93 and explicitly allows the
32#   use of ksh93 language extensions.
33
34
35# -----------------------------------------------------------------------------
36# Parameters you are likely to want to change
37# -----------------------------------------------------------------------------
38
39#       DEBUG build only (-D, -F)
40#       do not bringover from the parent (-n)
41#       runs 'make check' (-C)
42#       checks for new interfaces in libraries (-A)
43#       sends mail on completion (-m and the MAILTO variable)
44#       creates packages for PIT/RE (-p)
45#       checks for changes in ELF runpaths (-r)
46#       build and use this workspace's tools in $SRC/tools (-t)
47export NIGHTLY_OPTIONS='-FnCDAmprt'
48
49# Some scripts optionally send mail messages to MAILTO.
50#export MAILTO=
51
52# CODEMGR_WS - where is your workspace at
53export CODEMGR_WS="`git rev-parse --show-toplevel`"
54
55# Compilers may be specified using the following variables:
56# PRIMARY_CC	- primary C compiler
57# PRIMARY_CCC	- primary C++ compiler
58#
59# SHADOW_CCS    - list of shadow C compilers
60# SHADOW_CCCS	- list of shadow C++ compilers
61#
62# Each entry has the form <name>,<path to binary>,<style> where name is a
63# free-form name (possibly used in the makefiles to guard options), path is
64# the path to the executable.  style is the 'style' of command line taken by
65# the compiler, currently either gnu (or gcc) or sun (or cc), which is also
66# used by Makefiles to guard options.
67#
68# for example:
69# export PRIMARY_CC=gcc4,/opt/gcc/4.4.4/bin/gcc,gnu
70# export PRIMARY_CCC=gcc4,/opt/gcc/4.4.4/bin/g++,gnu
71# export SHADOW_CCS=studio12,/opt/SUNWspro/bin/cc,sun
72# export SHADOW_CCCS=studio12,/opt/SUNWspro/bin/CC,sun
73#
74# There can be several space-separated entries in SHADOW_* to run multiple
75# shadow compilers.
76#
77# To disable shadow compilation, unset SHADOW_* or set them to the empty string.
78#
79export GNUC_ROOT=/usr/gcc/10
80export PRIMARY_CC=gcc10,$GNUC_ROOT/bin/gcc,gnu
81export PRIMARY_CCC=gcc10,$GNUC_ROOT/bin/g++,gnu
82export SHADOW_CCS=gcc7,/usr/gcc/7/bin/gcc,gnu
83export SHADOW_CCCS=gcc7,/usr/gcc/7/bin/g++,gnu
84
85# comment to disable smatch
86export ENABLE_SMATCH=1
87
88# Comment this out to disable support for SMB printing, i.e. if you
89# don't want to bother providing the CUPS headers this needs.
90export ENABLE_SMB_PRINTING=
91
92# If your distro uses certain versions of Perl, make sure either Makefile.master
93# contains your new defaults OR your .env file sets them.
94# These are how you would override for building on OmniOS r151028, for example.
95#export PERL_VERSION=5.28
96#export PERL_VARIANT=-thread-multi
97#export PERL_PKGVERS=
98
99# To disable building of the 32-bit or 64-bit perl modules (or both),
100# uncomment these lines:
101#export BUILDPERL32='#'
102#export BUILDPERL64='#'
103
104# If your distro uses certain versions of Python, make sure either
105# Makefile.master contains your new defaults OR your .env file sets them.
106#export PYTHON3_VERSION=3.9
107#export PYTHON3_PKGVERS=-39
108#export PYTHON3_SUFFIX=
109
110# Set console color scheme either by build type:
111#
112#export RELEASE_CONSOLE_COLOR="-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_BLACK \
113#	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_WHITE"
114#
115#export DEBUG_CONSOLE_COLOR="-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_RED \
116#	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_WHITE"
117#
118# or just one for any build type:
119#
120#export DEFAULT_CONSOLE_COLOR="-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_BLACK \
121#	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_WHITE"
122
123# Set if your distribution has different package versioning
124#export PKGVERS_BRANCH=2018.0.0.17900
125
126# Skip Java 11 builds on distributions that don't support it
127#export BLD_JAVA_11=
128
129# POST_NIGHTLY can be any command to be run at the end of nightly.  See
130# nightly(1) for interactions between environment variables and this command.
131#POST_NIGHTLY=
132
133# Populates /etc/versions/build on each nightly run
134export BUILDVERSION_EXEC="git describe --all --long --dirty"
135
136# -----------------------------------------------------------------------------
137# You are less likely to need to modify parameters below.
138# -----------------------------------------------------------------------------
139
140# Maximum number of dmake jobs.  The recommended number is 2 + NCPUS,
141# where NCPUS is the number of logical CPUs on your build system.
142function maxjobs
143{
144	nameref maxjobs=$1
145	integer ncpu
146	integer -r min_mem_per_job=512 # minimum amount of memory for a job
147
148	ncpu=$(builtin getconf ; getconf 'NPROCESSORS_ONLN')
149	(( maxjobs=ncpu + 2 ))
150
151	# Throttle number of parallel jobs launched by dmake to a value which
152	# gurantees that all jobs have enough memory. This was added to avoid
153	# excessive paging/swapping in cases of virtual machine installations
154	# which have lots of CPUs but not enough memory assigned to handle
155	# that many parallel jobs
156	if [[ $(/usr/sbin/prtconf 2>'/dev/null') == ~(E)Memory\ size:\ ([[:digit:]]+)\ Megabytes ]] ; then
157		integer max_jobs_per_memory # parallel jobs which fit into physical memory
158		integer physical_memory # physical memory installed
159
160		# The array ".sh.match" contains the contents of capturing
161		# brackets in the last regex, .sh.match[1] will contain
162		# the value matched by ([[:digit:]]+), i.e. the amount of
163		# memory installed
164		physical_memory="10#${.sh.match[1]}"
165
166		((
167			max_jobs_per_memory=round(physical_memory/min_mem_per_job) ,
168			maxjobs=fmax(2, fmin(maxjobs, max_jobs_per_memory))
169		))
170	fi
171
172	return 0
173}
174
175maxjobs DMAKE_MAX_JOBS # "DMAKE_MAX_JOBS" passed as ksh(1) name reference
176export DMAKE_MAX_JOBS
177
178# path to onbld tool binaries
179ONBLD_BIN='/opt/onbld/bin'
180
181# PARENT_WS is used to determine the parent of this workspace. This is
182# for the options that deal with the parent workspace (such as where the
183# proto area will go).
184export PARENT_WS=''
185
186# CLONE_WS is the workspace nightly should do a bringover from.
187# The bringover, if any, is done as STAFFER.
188export CLONE_WS='ssh://anonhg@hg.illumos.org/illumos-gate'
189
190# Set STAFFER to your own login as gatekeeper or developer
191# The point is to use group "staff" and avoid referencing the parent
192# workspace as root.
193export STAFFER="$LOGNAME"
194export MAILTO="${MAILTO:-$STAFFER}"
195
196# If you wish the mail messages to be From: an arbitrary address, export
197# MAILFROM.
198#export MAILFROM="user@example.com"
199
200# The project (see project(5)) under which to run this build.  If not
201# specified, the build is simply run in a new task in the current project.
202export BUILD_PROJECT=''
203
204# You should not need to change the next three lines
205export ATLOG="$CODEMGR_WS/log"
206export LOGFILE="$ATLOG/nightly.log"
207export MACH="$(uname -p)"
208
209#
210#  The following macro points to the closed binaries.  Once illumos has
211#  totally freed itself, we can remove this reference.
212#
213# Location of encumbered binaries.
214export ON_CLOSED_BINS="/opt/onbld/closed"
215
216# REF_PROTO_LIST - for comparing the list of stuff in your proto area
217# with. Generally this should be left alone, since you want to see differences
218# from your parent (the gate).
219#
220export REF_PROTO_LIST="$PARENT_WS/usr/src/proto_list_${MACH}"
221
222
223export ROOT="$CODEMGR_WS/proto/root_${MACH}"
224export SRC="$CODEMGR_WS/usr/src"
225export MULTI_PROTO="no"
226
227#
228#	build environment variables, including version info for mcs, motd,
229# motd, uname and boot messages. Mostly you shouldn't change this except
230# when the release slips (nah) or you move an environment file to a new
231# release
232#
233export VERSION="`git describe --long --all HEAD | cut -d/ -f2-`"
234
235#
236# the RELEASE and RELEASE_DATE variables are set in Makefile.master;
237# there might be special reasons to override them here, but that
238# should not be the case in general
239#
240# export RELEASE='5.11'
241# export RELEASE_DATE='October 2007'
242
243# proto area in parent for optionally depositing a copy of headers and
244# libraries corresponding to the protolibs target
245# not applicable given the NIGHTLY_OPTIONS
246#
247export PARENT_ROOT="$PARENT_WS/proto/root_$MACH"
248export PARENT_TOOLS_ROOT="$PARENT_WS/usr/src/tools/proto/root_$MACH-nd"
249
250# Package creation variables.  You probably shouldn't change these,
251# either.
252#
253# PKGARCHIVE determines where the repository will be created.
254#
255# PKGPUBLISHER_REDIST controls the publisher setting for the repository.
256#
257export PKGARCHIVE="${CODEMGR_WS}/packages/${MACH}/nightly"
258# export PKGPUBLISHER_REDIST='on-redist'
259
260# Package manifest format version.
261export PKGFMT_OUTPUT='v2'
262
263# we want make to do as much as it can, just in case there's more than
264# one problem.
265export MAKEFLAGS='k'
266
267# Build tools - don't change these unless you know what you're doing.  These
268# variables allows you to get the compilers and onbld files locally.
269# Set BUILD_TOOLS to pull everything from one location.
270# Alternately, you can set ONBLD_TOOLS to where you keep the contents of
271# SUNWonbld.
272export BUILD_TOOLS='/opt'
273#export ONBLD_TOOLS='/opt/onbld'
274
275# Set this flag to 'n' to disable the use of 'checkpaths'.  The default,
276# if the 'N' option is not specified, is to run this test.
277#CHECK_PATHS='y'
278
279if [[ "$ENABLE_SMATCH" == "1" ]]; then
280	SMATCHBIN=$CODEMGR_WS/usr/src/tools/proto/root_$MACH-nd/opt/onbld/bin/$MACH/smatch
281	export SHADOW_CCS="$SHADOW_CCS smatch,$SMATCHBIN,smatch"
282fi
283