8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mdb / tools / scripts / mkmodules.sh
blob43e11f6311bca3f277b5c10e8fc3166446fe6741
1 #!/bin/sh
3 # CDDL HEADER START
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.
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.
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]
21 # CDDL HEADER END
24 # Copyright (c) 1998-2001 by Sun Microsystems, Inc.
25 # All rights reserved.
27 #ident "%Z%%M% %I% %E% SMI"
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.
42 PNAME=`basename $0`
43 opt_R=false
44 umask 022
46 if [ $# -ne 0 -a "x$1" = x-R ]; then
47 opt_R=true
48 shift
51 if [ $# -ne 1 -o -z "${INCROOT:=$1}" -o ! -d "$INCROOT" ]; then
52 echo "Usage: $PNAME [-R] root-dir"
53 exit 2
56 if $opt_R; then
57 ROOT="$INCROOT"
58 export ROOT
61 if [ -z "$SRC" -a -z "$CODEMGR_WS" ]; then
62 echo "$PNAME: \$SRC or \$CODEMGR_WS must be set" >& 2
63 exit 1
66 if [ -z "$ROOT" ]; then
67 echo "$PNAME: \$ROOT must be set" >& 2
68 exit 1
71 if [ -z "$SRC" ]; then
72 SRC="$CODEMGR_WS/usr/src"
73 export SRC
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.
82 case "`basename $INCROOT`" in
83 s297_fcs) BLDID=0x2637 ;;
84 s998_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 ;;
92 esac
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.
98 [ `id | cut -d'(' -f1` != 'uid=0' ] && CH='#' || CH=; export CH
99 VERSION=${VERSION:-"`basename $INCROOT`:`date '+%m/%d/%y'`"}; export VERSION
100 MACH=`uname -p`; export MACH
101 TMPDIR=/tmp; export TMPDIR
102 NODENAME=`uname -n`; export NODENAME
103 PATH="$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 INS=/opt/onbld/bin/$MACH/install.bin; export INS
105 MAKEFLAGS=e; export MAKEFLAGS
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.
111 ENVCPPFLAGS1="-YI,$INCROOT/usr/include"; export ENVCPPFLAGS1
112 ENVCPPFLAGS2="-D_MDB_BLDID=$BLDID"; export ENVCPPFLAGS2
113 ENVCPPFLAGS3=; export ENVCPPFLAGS3
114 ENVCPPFLAGS4=; export ENVCPPFLAGS4
116 ENVLDLIBS1=; export ENVLDLIBS1
117 ENVLDLIBS2=; export ENVLDLIBS2
118 ENVLDLIBS3=; export ENVLDLIBS3
120 cd $SRC && make clobber && make dmods