Merge branch 'master' of git://repo.or.cz/illumos-gate/unleashed
[unleashed.git] / tools / env.sh
blobc3b872f2e56c9ddbe849448195cd7da8953300c6
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
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.
27 # Configuration variables for the runtime environment of the nightly
28 # build script and other tools for construction and packaging of
29 # releases.
30 # This example is suitable for building an illumos workspace, which
31 # will contain the resulting archives. It is based off the onnv
32 # release. It sets NIGHTLY_OPTIONS to make nightly do:
33 # DEBUG build instead of non-DEBUG (-D)
34 # runs 'make check' (-C)
35 # checks for new interfaces in libraries (-A)
36 # sends mail on completion (-m and the MAILTO variable)
37 # creates packages for PIT/RE (-p)
38 # checks for changes in ELF runpaths (-r)
40 # - This file is sourced by "bldenv.sh" and "nightly.sh" and should not
41 # be executed directly.
42 # - This script is only interpreted by ksh93 and explicitly allows the
43 # use of ksh93 language extensions.
45 export NIGHTLY_OPTIONS='-DCAmpr'
47 # CODEMGR_WS - where is your workspace at
48 #export CODEMGR_WS="$HOME/ws/illumos-gate"
49 export CODEMGR_WS="`git rev-parse --show-toplevel`"
51 # Maximum number of dmake jobs. The recommended number is 2 + NCPUS,
52 # where NCPUS is the number of logical CPUs on your build system.
53 function maxjobs
55 nameref maxjobs=$1
56 integer ncpu
57 integer -r min_mem_per_job=512 # minimum amount of memory for a job
59 ncpu=$(builtin getconf ; getconf 'NPROCESSORS_ONLN')
60 (( maxjobs=ncpu + 2 ))
62 # Throttle number of parallel jobs launched by dmake to a value which
63 # gurantees that all jobs have enough memory. This was added to avoid
64 # excessive paging/swapping in cases of virtual machine installations
65 # which have lots of CPUs but not enough memory assigned to handle
66 # that many parallel jobs
67 if [[ $(/usr/sbin/prtconf 2>'/dev/null') == ~(E)Memory\ size:\ ([[:digit:]]+)\ Megabytes ]] ; then
68 integer max_jobs_per_memory # parallel jobs which fit into physical memory
69 integer physical_memory # physical memory installed
71 # The array ".sh.match" contains the contents of capturing
72 # brackets in the last regex, .sh.match[1] will contain
73 # the value matched by ([[:digit:]]+), i.e. the amount of
74 # memory installed
75 physical_memory="10#${.sh.match[1]}"
78 max_jobs_per_memory=round(physical_memory/min_mem_per_job) ,
79 maxjobs=fmax(2, fmin(maxjobs, max_jobs_per_memory))
83 return 0
86 maxjobs DMAKE_MAX_JOBS # "DMAKE_MAX_JOBS" passed as ksh(1) name reference
87 export DMAKE_MAX_JOBS
89 # Some scripts optionally send mail messages to MAILTO.
90 export MAILTO="$LOGNAME"
92 # If you wish the mail messages to be From: an arbitrary address, export
93 # MAILFROM.
94 #export MAILFROM="user@example.com"
96 # The project (see project(4)) under which to run this build. If not
97 # specified, the build is simply run in a new task in the current project.
98 export BUILD_PROJECT=''
100 # You should not need to change the next three lines
101 export ATLOG="$CODEMGR_WS/log"
102 export LOGFILE="$ATLOG/nightly.log"
103 export MACH="$(uname -p)"
105 export ROOT="$CODEMGR_WS/proto/root_${MACH}"
106 export SRC="$CODEMGR_WS/usr/src"
109 # build environment variables, including version info for mcs, motd,
110 # motd, uname and boot messages. Mostly you shouldn't change this except
111 # when the release slips (nah) or you move an environment file to a new
112 # release
114 export VERSION="`git describe --long --all HEAD | cut -d/ -f2-`"
116 # Package creation variables. You probably shouldn't change these,
117 # either.
119 # PKGARCHIVE determines where the repository will be created.
121 # PKGPUBLISHER controls the publisher setting for the repository.
123 export PKGARCHIVE="${CODEMGR_WS}/packages/${MACH}/nightly"
124 # export PKGPUBLISHER='publisher'
126 # Package manifest format version.
127 export PKGFMT_OUTPUT='v1'
129 # we want make to do as much as it can, just in case there's more than
130 # one problem.
131 export MAKEFLAGS='k'
133 # Set this flag to 'n' to disable the use of 'checkpaths'. The default,
134 # if the 'N' option is not specified, is to run this test.
135 #CHECK_PATHS='y'
137 # POST_NIGHTLY can be any command to be run at the end of nightly. See
138 # nightly(1) for interactions between environment variables and this command.
139 #POST_NIGHTLY=
141 # If your distro uses certain versions of Perl, make sure either Makefile.master
142 # contains your new defaults OR your .env file sets them.
143 # These are how you would override for building on OmniOS r151012, for example.
144 #export PERL_VERSION=5.16.1
145 #export PERL_ARCH=i86pc-solaris-thread-multi-64int
146 #export PERL_PKGVERS=-5161