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