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