buildit revision 1296
181N/A#!/bin/ksh93
181N/A#
181N/A# buildit
181N/A# Script for building OpenSolaris X Consolidation
181N/A#
181N/A###########################################################################
181N/A#
181N/A# Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
181N/A#
181N/A# Permission is hereby granted, free of charge, to any person obtaining a
181N/A# copy of this software and associated documentation files (the "Software"),
181N/A# to deal in the Software without restriction, including without limitation
181N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
181N/A# and/or sell copies of the Software, and to permit persons to whom the
181N/A# Software is furnished to do so, subject to the following conditions:
181N/A#
181N/A# The above copyright notice and this permission notice (including the next
181N/A# paragraph) shall be included in all copies or substantial portions of the
181N/A# Software.
181N/A#
181N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3532N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
181N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
181N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
181N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
181N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
181N/A# DEALINGS IN THE SOFTWARE.
181N/A#
181N/A###########################################################################
181N/A#
181N/A#
181N/A
181N/A# Add /usr/bin to front of path in case user has /usr/gnu/bin default
181N/A# Add /usr/gnu/bin to path for gnu sed/awk/etc. that configure scripts prefer
181N/A# Add /usr/sbin to path for dtrace (to build probes in X servers)
181N/A
181N/APATH=/usr/bin:${PATH}:/usr/gnu/bin:/usr/sbin
181N/Aexport PATH
181N/A
1210N/Aprogname="$0"
1210N/Afunction fatal_error
1210N/A{
181N/A print -u2 "${progname}: ERROR: $*"
181N/A exit 1
181N/A}
181N/A
181N/AMAKE_PKGS=0
181N/AVERBOSE_FLAGS="" # verbosity flag passed to xmake/make_release_packages
181N/APUBLISHER_FLAGS=""
181N/A
181N/Awhile getopts pP:v i; do
181N/A case $i in
181N/A p) MAKE_PKGS=1 ;;
181N/A v) VERBOSE_FLAGS="-v" ;;
181N/A P) PUBLISHER_FLAGS="-p $OPTARG" ;;
181N/A ?) print -u2 "USAGE: $0 [-p [-P publisher]] [-v]"; exit 2 ;;
181N/A esac
181N/Adone
181N/A
181N/Ashift $(($OPTIND-1))
181N/A
181N/Aif [[ $? != 0 ]] ; then
181N/A print -u2 "USAGE: $0 [-p [-P publisher]] [-v]"
181N/A exit 2
181N/Afi
181N/A
1210N/A[ -d log ] || mkdir log
448N/A
448N/A# Send all further output & errors to the log file
181N/Aexec > log/buildit-XW 2>&1
448N/A
1210N/ASTART="$(perl -e 'print time')"
1210N/A
1210N/AXMAKE="$(pwd)/open-src/util/build-tools/xmake ${VERBOSE_FLAGS} -k"
1210N/A
181N/A${XMAKE} setup || fatal_error "make setup failed: cannot build"
448N/A
448N/A# Extract variables from makefiles via make and set them in the shell
448N/Aget_make_var() {
448N/A typeset -n var=$1
448N/A eval "$(${XMAKE} -s -C open-src/util/util-macros print_make_vars VARS=$1)"
181N/A}
448N/A
181N/A# Find hg id and export it so set-elf-comments.pl doesn't have to re-run
1210N/A# for every module built
1210N/Ahg_id() {
1210N/A hg id -it | read rev tag
181N/A case "${tag}" in
181N/A tip) print "${rev}" ;;
181N/A *) print "${tag}" ;;
181N/A esac
181N/A}
181N/Aexport XBUILD_HG_ID="$(hg_id)"
181N/A
181N/Aprint "------------------------------------------------------------------------------"
2238N/Aprint "Building gate at hg id: ${XBUILD_HG_ID}"
181N/Aprint -n "Start time: " ; date
181N/Aprint -n "Building on: " ; uname -a
1210N/Aprint "Using these tools: "
448N/A# Make sure Sun C compiler is at least version 5.10 (Studio 12 Update 1)
181N/Awhence cc
448N/Acc -V 2>&1 | perl -n -e 'if (($_ =~ m| C (\d+).(\d+)|)) { \
448N/A print $_ ; print "*** Compiler too old!\n" if ( ($1 != 5) || ($2 < 10) ) }'
448N/A# Log paths & versions of tools which use gnu standard --version flag
448N/Aget_make_var GCC
1210N/Afor tool in parfait ${GCC} gmake autoconf automake libtool ; do
1210N/A printf "%-22s\t" "$(whence ${tool}):"
1210N/A ${tool} --version | head -1
448N/Adone
448N/A
448N/A# Exported to stop Sun compilers from reporting home on each usage
448N/Aexport SUNW_NO_UPDATE_NOTIFY='true'
181N/Aexport UT_NO_USAGE_TRACKING='1'
448N/A
181N/Aprint "Using these environment variables: "
448N/Aenv
181N/Aprint "------------------------------------------------------------------------------"
181N/A
181N/AMACH="$(uname -p)"
1210N/A
181N/A# Clean new proto areas for this architecture
464N/A/bin/rm -rf "proto/root_${MACH}" "proto/metadata_${MACH}" \
464N/A "proto/pkg_${MACH}" "proto/tools_${MACH}"
181N/A
448N/Acd open-src
181N/A# Run as two steps to avoid race between cleaning & rebuilding when
181N/A# using parallel make
181N/A${XMAKE} clean
181N/A${XMAKE} install
181N/A${XMAKE} check_rtime > ../log/check-rtime 2>&1 &
181N/Acd ..
1210N/A
1210N/Aget_make_var USE_PARFAIT
1210N/Aif [[ "${USE_PARFAIT}" == "yes" ]] ; then
181N/A get_make_var DMAKE_MAX_JOBS
181N/A /bin/rm -rf log/parfait
181N/A parfait -e all -c open-src/common/X-parfait.conf -z "$(pwd)" \
181N/A -j "${DMAKE_MAX_JOBS:-100%}" -r "${XBUILD_HG_ID}" \
181N/A -o log/parfait.txt -g log/parfait open-src > log/parfait.out 2>&1 &
181N/Afi
181N/A
379N/A# Set DISTRO_NAME based on open-src/common/Makefile.options
464N/Aget_make_var DISTRO_NAME
464N/A
181N/Aprint "\nFinished building the X Window System Consolidation for" \
379N/A "${DISTRO_NAME:-OpenSolaris}.\n"
464N/A
464N/Aif [ "${MAKE_PKGS}" = 1 ] ; then
464N/A print -n "Build finish time: " ; date ; print ""
464N/A ./make_release_packages ${PUBLISHER_FLAGS} ${VERBOSE_FLAGS}
181N/Afi
181N/A
448N/Await
448N/A
181N/Aif [[ "${USE_PARFAIT}" == "yes" ]] ; then
181N/A print -n "\nParfait issues: "
448N/A wc -l < log/parfait/bugstatus.db
181N/A print "Parfait results:"
181N/A print " file:///net/$(hostname)$(pwd)/log/parfait/index.html"
448N/Afi
181N/A
181N/Aprint -n "\ncheck-rtime errors: "
181N/Agrep -c '^====' log/check-rtime
181N/A
181N/Aprint -n "\nFinish time: " ; date
448N/Aperl -e '$runtime = time - $ARGV[0];
181N/A printf("Runtime: %d:%02d\n", $runtime/3600, ($runtime%3600)/60); ' \
1210N/A "${START}"
1210N/A