1*7c478bd9Sstevel@tonic-gate#!/bin/sh
2*7c478bd9Sstevel@tonic-gate#
3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START
4*7c478bd9Sstevel@tonic-gate#
5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*7c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*7c478bd9Sstevel@tonic-gate# with the License.
9*7c478bd9Sstevel@tonic-gate#
10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
13*7c478bd9Sstevel@tonic-gate# and limitations under the License.
14*7c478bd9Sstevel@tonic-gate#
15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*7c478bd9Sstevel@tonic-gate#
21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END
22*7c478bd9Sstevel@tonic-gate#
23*7c478bd9Sstevel@tonic-gate#
24*7c478bd9Sstevel@tonic-gate# Copyright (c) 1998-2001 by Sun Microsystems, Inc.
25*7c478bd9Sstevel@tonic-gate# All rights reserved.
26*7c478bd9Sstevel@tonic-gate#
27*7c478bd9Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate#
30*7c478bd9Sstevel@tonic-gate# Script to build the MDB modules present in a workspace against the set of
31*7c478bd9Sstevel@tonic-gate# include files saved in an MDB "root" (created with mkroot.sh), and install
32*7c478bd9Sstevel@tonic-gate# resulting modules into this tree so that it can be used as the argument
33*7c478bd9Sstevel@tonic-gate# to ``mdb -R'' or by mdb's auto-detect code, used by the mdb.sh wrapper.
34*7c478bd9Sstevel@tonic-gate# We use the ``make dmods'' target to do the build -- this is equivalent to
35*7c478bd9Sstevel@tonic-gate# make install, but does not build the debugger itself, and pass a special
36*7c478bd9Sstevel@tonic-gate# define (_MDB_BLDID) into the compilation environment so that the module
37*7c478bd9Sstevel@tonic-gate# source can detect the various changes in header files, etc.  This is only
38*7c478bd9Sstevel@tonic-gate# used for module source kept on mdb.eng that needs to compile against
39*7c478bd9Sstevel@tonic-gate# legacy builds of the operating system.
40*7c478bd9Sstevel@tonic-gate#
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gatePNAME=`basename $0`
43*7c478bd9Sstevel@tonic-gateopt_R=false
44*7c478bd9Sstevel@tonic-gateumask 022
45*7c478bd9Sstevel@tonic-gate
46*7c478bd9Sstevel@tonic-gateif [ $# -ne 0 -a "x$1" = x-R ]; then
47*7c478bd9Sstevel@tonic-gate	opt_R=true
48*7c478bd9Sstevel@tonic-gate	shift
49*7c478bd9Sstevel@tonic-gatefi
50*7c478bd9Sstevel@tonic-gate
51*7c478bd9Sstevel@tonic-gateif [ $# -ne 1 -o -z "${INCROOT:=$1}" -o ! -d "$INCROOT" ]; then
52*7c478bd9Sstevel@tonic-gate	echo "Usage: $PNAME [-R] root-dir"
53*7c478bd9Sstevel@tonic-gate	exit 2
54*7c478bd9Sstevel@tonic-gatefi
55*7c478bd9Sstevel@tonic-gate
56*7c478bd9Sstevel@tonic-gateif $opt_R; then
57*7c478bd9Sstevel@tonic-gate	ROOT="$INCROOT"
58*7c478bd9Sstevel@tonic-gate	export ROOT
59*7c478bd9Sstevel@tonic-gatefi
60*7c478bd9Sstevel@tonic-gate
61*7c478bd9Sstevel@tonic-gateif [ -z "$SRC" -a -z "$CODEMGR_WS" ]; then
62*7c478bd9Sstevel@tonic-gate	echo "$PNAME: \$SRC or \$CODEMGR_WS must be set" >& 2
63*7c478bd9Sstevel@tonic-gate	exit 1
64*7c478bd9Sstevel@tonic-gatefi
65*7c478bd9Sstevel@tonic-gate
66*7c478bd9Sstevel@tonic-gateif [ -z "$ROOT" ]; then
67*7c478bd9Sstevel@tonic-gate	echo "$PNAME: \$ROOT must be set" >& 2
68*7c478bd9Sstevel@tonic-gate	exit 1
69*7c478bd9Sstevel@tonic-gatefi
70*7c478bd9Sstevel@tonic-gate
71*7c478bd9Sstevel@tonic-gateif [ -z "$SRC" ]; then
72*7c478bd9Sstevel@tonic-gate	SRC="$CODEMGR_WS/usr/src"
73*7c478bd9Sstevel@tonic-gate	export SRC
74*7c478bd9Sstevel@tonic-gatefi
75*7c478bd9Sstevel@tonic-gate
76*7c478bd9Sstevel@tonic-gate#
77*7c478bd9Sstevel@tonic-gate# Derive a build-id based on the name of the $ROOT directory.  The build-id
78*7c478bd9Sstevel@tonic-gate# is passed into the compilation environment as _MDB_BLDID, and consists of
79*7c478bd9Sstevel@tonic-gate# a 4-digit hexadecimal number whose first two digits are the release number
80*7c478bd9Sstevel@tonic-gate# (e.g. 0x27XX for Solaris 2.7) and whose last two digits are the build number.
81*7c478bd9Sstevel@tonic-gate#
82*7c478bd9Sstevel@tonic-gatecase "`basename $INCROOT`" in
83*7c478bd9Sstevel@tonic-gates297_fcs) BLDID=0x2637 ;;
84*7c478bd9Sstevel@tonic-gates998_fcs) BLDID=0x2721 ;;
85*7c478bd9Sstevel@tonic-gate s28_fcs) BLDID=0x2838 ;;
86*7c478bd9Sstevel@tonic-gate  s399_*) BLDID=0x27FF ;;
87*7c478bd9Sstevel@tonic-gate  s599_*) BLDID=0x27FF ;;
88*7c478bd9Sstevel@tonic-gate  s899_*) BLDID=0x27FF ;;
89*7c478bd9Sstevel@tonic-gate s1199_*) BLDID=0x27FF ;;
90*7c478bd9Sstevel@tonic-gate   s81_*) BLDID=0x81`basename $INCROOT | sed 's/s81_//' | tr -cd '[0-9]'` ;;
91*7c478bd9Sstevel@tonic-gate       *) echo "$PNAME: cannot derive _MDB_BLDID for $INCROOT" >& 2; exit 1 ;;
92*7c478bd9Sstevel@tonic-gateesac
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gate#
95*7c478bd9Sstevel@tonic-gate# Set up the necessary environment variables to perform a build.  Basically
96*7c478bd9Sstevel@tonic-gate# we need to do the same stuff as bld_env or bfmenv.
97*7c478bd9Sstevel@tonic-gate#
98*7c478bd9Sstevel@tonic-gate[ `id | cut -d'(' -f1` != 'uid=0' ] && CH='#' || CH=; export CH
99*7c478bd9Sstevel@tonic-gateVERSION=${VERSION:-"`basename $INCROOT`:`date '+%m/%d/%y'`"}; export VERSION
100*7c478bd9Sstevel@tonic-gateMACH=`uname -p`; export MACH
101*7c478bd9Sstevel@tonic-gateTMPDIR=/tmp; export TMPDIR
102*7c478bd9Sstevel@tonic-gateNODENAME=`uname -n`; export NODENAME
103*7c478bd9Sstevel@tonic-gatePATH="$PUBLIC/bin:$PUBLIC/bin/$MACH:/opt/onbld/bin:/opt/onbld/bin/$MACH:/opt/SUNWspro/bin:/opt/teamware/ParallelMake/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/openwin/bin:."; export PATH
104*7c478bd9Sstevel@tonic-gateINS=/opt/onbld/bin/$MACH/install.bin; export INS
105*7c478bd9Sstevel@tonic-gateMAKEFLAGS=e; export MAKEFLAGS
106*7c478bd9Sstevel@tonic-gate
107*7c478bd9Sstevel@tonic-gate#
108*7c478bd9Sstevel@tonic-gate# We need to export $BLDID into the compilation environment, and make sure
109*7c478bd9Sstevel@tonic-gate# to remap the default include path from /usr/include to $INCROOT/usr/include.
110*7c478bd9Sstevel@tonic-gate#
111*7c478bd9Sstevel@tonic-gateENVCPPFLAGS1="-YI,$INCROOT/usr/include"; export ENVCPPFLAGS1
112*7c478bd9Sstevel@tonic-gateENVCPPFLAGS2="-D_MDB_BLDID=$BLDID"; export ENVCPPFLAGS2
113*7c478bd9Sstevel@tonic-gateENVCPPFLAGS3=; export ENVCPPFLAGS3
114*7c478bd9Sstevel@tonic-gateENVCPPFLAGS4=; export ENVCPPFLAGS4
115*7c478bd9Sstevel@tonic-gate
116*7c478bd9Sstevel@tonic-gateENVLDLIBS1=; export ENVLDLIBS1
117*7c478bd9Sstevel@tonic-gateENVLDLIBS2=; export ENVLDLIBS2
118*7c478bd9Sstevel@tonic-gateENVLDLIBS3=; export ENVLDLIBS3
119*7c478bd9Sstevel@tonic-gate
120*7c478bd9Sstevel@tonic-gatecd $SRC && make clobber && make dmods
121