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