|
root / base / usr / src / cmd / mdb / tools / scripts / mkmodules.sh
mkmodules.sh Bash 121 lines 3.8 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 1998-2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"%Z%%M%	%I%	%E% SMI"

#
# Script to build the MDB modules present in a workspace against the set of
# include files saved in an MDB "root" (created with mkroot.sh), and install
# resulting modules into this tree so that it can be used as the argument
# to ``mdb -R'' or by mdb's auto-detect code, used by the mdb.sh wrapper.
# We use the ``make dmods'' target to do the build -- this is equivalent to
# make install, but does not build the debugger itself, and pass a special
# define (_MDB_BLDID) into the compilation environment so that the module
# source can detect the various changes in header files, etc.  This is only
# used for module source kept on mdb.eng that needs to compile against
# legacy builds of the operating system.
#

PNAME=`basename $0`
opt_R=false
umask 022

if [ $# -ne 0 -a "x$1" = x-R ]; then
	opt_R=true
	shift
fi

if [ $# -ne 1 -o -z "${INCROOT:=$1}" -o ! -d "$INCROOT" ]; then
	echo "Usage: $PNAME [-R] root-dir"
	exit 2
fi

if $opt_R; then
	ROOT="$INCROOT"
	export ROOT
fi

if [ -z "$SRC" -a -z "$CODEMGR_WS" ]; then
	echo "$PNAME: \$SRC or \$CODEMGR_WS must be set" >& 2
	exit 1
fi

if [ -z "$ROOT" ]; then
	echo "$PNAME: \$ROOT must be set" >& 2
	exit 1
fi

if [ -z "$SRC" ]; then
	SRC="$CODEMGR_WS/usr/src"
	export SRC
fi

#
# Derive a build-id based on the name of the $ROOT directory.  The build-id
# is passed into the compilation environment as _MDB_BLDID, and consists of
# a 4-digit hexadecimal number whose first two digits are the release number
# (e.g. 0x27XX for Solaris 2.7) and whose last two digits are the build number.
#
case "`basename $INCROOT`" in
s297_fcs) BLDID=0x2637 ;;
s998_fcs) BLDID=0x2721 ;;
 s28_fcs) BLDID=0x2838 ;;
  s399_*) BLDID=0x27FF ;;
  s599_*) BLDID=0x27FF ;;
  s899_*) BLDID=0x27FF ;;
 s1199_*) BLDID=0x27FF ;;
   s81_*) BLDID=0x81`basename $INCROOT | sed 's/s81_//' | tr -cd '[0-9]'` ;;
       *) echo "$PNAME: cannot derive _MDB_BLDID for $INCROOT" >& 2; exit 1 ;;
esac

#
# Set up the necessary environment variables to perform a build.  Basically
# we need to do the same stuff as bld_env or bfmenv.
#
[ `id | cut -d'(' -f1` != 'uid=0' ] && CH='#' || CH=; export CH
VERSION=${VERSION:-"`basename $INCROOT`:`date '+%m/%d/%y'`"}; export VERSION
MACH=`uname -p`; export MACH
TMPDIR=/tmp; export TMPDIR
NODENAME=`uname -n`; export NODENAME
PATH="$PUBLIC/bin:$PUBLIC/bin/$MACH:/opt/onbld/bin:/opt/onbld/bin/$MACH:/bin:/sbin:/usr/bin:/usr/sbin:."; export PATH
INS=/opt/onbld/bin/$MACH/install.bin; export INS
MAKEFLAGS=e; export MAKEFLAGS

#
# We need to export $BLDID into the compilation environment, and make sure
# to remap the default include path from /usr/include to $INCROOT/usr/include.
#
ENVCPPFLAGS1="-YI,$INCROOT/usr/include"; export ENVCPPFLAGS1
ENVCPPFLAGS2="-D_MDB_BLDID=$BLDID"; export ENVCPPFLAGS2
ENVCPPFLAGS3=; export ENVCPPFLAGS3
ENVCPPFLAGS4=; export ENVCPPFLAGS4

ENVLDLIBS1=; export ENVLDLIBS1
ENVLDLIBS2=; export ENVLDLIBS2
ENVLDLIBS3=; export ENVLDLIBS3

cd $SRC && make clobber && make dmods