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