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