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