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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
|
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
#
#ident "%Z%%M% %I% %E% SMI"
.KEEP_STATE:
.SUFFIXES: .pl
include ../../../Makefile.cmd
PKGSCRIPTS = mdb mkmodules
BLDSCRIPTS = tigen map2linktest hdr2map
ROOTOPTPKGBIN = $(ROOT)/opt/SUNWonmdb/bin
ROOTPKGSCRIPTS = $(PKGSCRIPTS:%=$(ROOTOPTPKGBIN)/%)
all install: $(BLDSCRIPTS) $(PKGSCRIPTS)
clean.lint dmods install_h lint:
clobber: clean
clean:
$(RM) $(BLDSCRIPTS) $(PKGSCRIPTS)
pkg: $(ROOTPKGSCRIPTS)
$(ROOTOPTPKGBIN):
$(INS.dir)
$(ROOTPKGSCRIPTS): $(ROOTOPTPKGBIN)
$(ROOTOPTPKGBIN)/%: %.sh
$(INS.rename)
#!/bin/ksh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
#
# Given a header file, extract function prototypes and global variable
# declarations in a form that can be used in a mapfile. The list of extracted
# functions and variables will be combined with a user-specified template to
# create a complete mapfile.
#
# Template
# --------
#
# The template contains two sections - the prologue, and the epilogue. These
# sections are used, verbatim, as the beginning and the end of the mapfile.
# Sections begin and end with single-line comments whose sole contents are
# "/* BEGIN $section */" and "/* END $section */".
#
# Template example:
#
# /* BEGIN PROLOGUE */
# [ ... prologue goes here ... ]
# /* END PROLOGUE */
# /* BEGIN EPILOGUE */
# [ ... epilogue goes here ... ]
# /* END EPILOGUE */
#
# Selective Exportation
# ---------------------
#
# Some header files will have a public/private interface mix that is strongly
# biased towards private interfaces. That is, of the interfaces declared by
# a given header file, the majority of them are private. Only a small subset
# of interfaces are to be exported publicly. Using Selective Exportation, a
# special comment is included in the header file, declaring to this script that
# only a subset of interfaces - those with a marking declared in the comment -
# should be included in the mapfile. The marking is itself a special comment,
# whose format is declared using a directive like this:
#
# MAPFILE: export "Driver OK"
#
# Using the above directive, only those function prototypes and variable
# declarations with "/* Driver OK */" comments included in the mapfile. Note
# that the comment must be at the end of the first line. If the declaration
# spans multiple lines, the exportation comment must appear on the first line.
#
# Examples of functions selected for exportation:
#
# MAPFILE: export "Driver OK"
#
# extern int foo(int); /* Driver OK */
# extern void bar(int, int, /* Driver OK */
# int, void *);
#
# Selective Exportation may not be used in the same file as Selective Exclusion.
#
# Selective Exclusion
# -------------------
#
# Selective Exclusion is to be used in cases where the public/private interface
# mix is reversed - where public interfaces greatly outnumber the private ones.
# In this case, we want to be able to mark the private ones, thus telling this
# script that the marked interfaces are to be excluded from the mapfile.
# Marking is accomplished via a process similar to that used for Selective
# Exportation. A directive is included in a comment, and is formatted like
# this:
#
# MAPFILE: exclude "Internal"
#
# Using the above directive, function prototypes and variable declarations with
# "/* Internal */" comments would be excluded. Note that the comment must be at
# the end of the first line. If the declaration spans multiple lines, the
# exclusion comment must appear on the first line.
#
# Examples of functions excluded from exportation:
#
# MAPFILE: exclude "Internal"
#
# extern int foo(int); /* Internal */
# extern void bar(int, int, /* Internal */
# int, void *);
#
# Selective Exclusion may not be used in the same file as Selective Exportation.
#
function extract_prototypes
{
typeset header="$1"
typeset prefix="$2"
nawk -v prefix="$prefix" <$header '
/^.*MAPFILE: export \"[^\"]*\"$/ {
if (protoexclude) {
print "ERROR: export after exclude\n";
exit(1);
}
sub(/^[^\"]*\"/, "");
sub(/\"$/, "");
exportmark=sprintf("/* %s */", $0);
next;
}
/^.*MAPFILE: exclude \"[^\"]*\"$/ {
if (protomatch) {
print "ERROR: exclude after export";
exit(1);
}
sub(/^[^\"]*\"/, "");
sub(/\"$/, "");
excludemark=sprintf("/* %s */", $0);
next;
}
exportmark {
# Selective Exportation has been selected (exportmark is
# set), so exclude this line if it does not have the
# magic export mark.
if (length($0) < length(exportmark) ||
substr($0, length($0) - length(exportmark) + 1) != \
exportmark)
next;
}
excludemark {
# Selective Exclusion has been selected (excludemark is
# set), so exclude this line only if it has the magic
# exclude mark.
if (length($0) > length(excludemark) &&
substr($0, \
length($0) - length(excludemark) + 1) == \
excludemark)
next;
}
# Functions
/^extern.*\(/ {
for (i = 1; i <= NF; i++) {
if (sub(/\(.*$/, "", $i)) {
sub(/^\*/, "", $i);
if (!seenfn[$i]) {
printf("%s%s;\n", prefix, $i);
seenfn[$i] = 1;
}
break;
}
}
next;
}
# Global variables
/^extern[^\(\)]*;/ {
for (i = 1; i <= NF; i++) {
if (match($i, /;$/)) {
printf("%s%s; /* variable */\n", prefix,
substr($i, 1, length($i) - 1));
break;
}
}
next;
}
' || die "Extraction failed"
}
function extract_section
{
typeset skel="$1"
typeset secname="$2"
nawk <$skel -v name=$secname -v skel=$skel '
/\/\* [^ ]* [^ ]* \*\// && $3 == name {
if ($2 == "BEGIN") {
printing = 1;
} else {
printing = 0;
}
next;
}
printing != 0 { print; }
'
}
function die
{
echo "$PROGNAME: $@" >&2
exit 1
}
function usage
{
echo "Usage: $PROGNAME -t tmplfile header [header ...]" >&2
exit 2
}
PROGNAME=$(basename "$0")
while getopts t: c ; do
case $c in
t)
mapfile_skel=$OPTARG
;;
?)
usage
esac
done
[[ -z "$mapfile_skel" ]] && usage
[[ ! -f $mapfile_skel ]] && die "Couldn't open template $tmplfile"
shift $(($OPTIND - 1))
[[ $# -lt 1 ]] && usage
for file in $@ ; do
[[ ! -f $file ]] && die "Can't open input file $file"
done
extract_section $mapfile_skel PROLOGUE
for file in $@ ; do
echo "\t\t/*"
echo "\t\t * Exported functions and variables from:"
echo "\t\t * $file"
echo "\t\t */"
extract_prototypes $file "\t\t"
echo
done
extract_section $mapfile_skel EPILOGUE
#!/bin/ksh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
#
# Create dummy functions for each of the functions in the module API. We can
# then link a module against an object file created from the output of this
# script to determine whether or not that module restricts itself to the API.
# If the module uses functions outside of the module API, then it cannot be
# used as a kmdb module.
#
nawk '
/^[ ]*global:[ ]*$/ {
printing = 1;
next;
}
/^[ ]*local:[ ]*$/ {
printing = 0;
next;
}
# Skip blank lines and comments
/^$/ { next; }
/^[ ]*#/ { next;}
# Print globals only
printing == 0 { next; }
# Symbols beginning with "kmdb_" are not in the module API - they are
# private to kmdb.
$1 ~ /^kmdb_/ { next; }
# Symbols which have the token "variable" are seen as an int
$3 ~ /variable/ {
if (seen[$1]) {
next;
}
seen[$1] = 1;
printf("int %s = 0;\n", substr($1, 1, length($1) - 1));
next;
}
$1 !~ /;$/ { next; }
# Print everything else that we have not already seen as a function
# definition so we can create our filter.
{
if (seen[$1]) {
next;
}
seen[$1] = 1;
printf("void %s(void) {}\n", substr($1, 1, length($1) - 1));
}
'
#
# kmdb modules cannot have their own _init, _fini, or _info routines. By
# creating dummies for them here, a link against an object file created from
# the output of this script will fail if the module defines one of them.
#
echo "void _init(void) {}"
echo "void _info(void) {}"
echo "void _fini(void) {}"
#
# The SunStudio compiler may generate calls to _memcpy and so we
# need to make sure that the correct symbol exists for these calls.
#
echo "void _memcpy(void) {}"
#!/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"
mdb_lib=/net/mdb.eng/mdb/archives # Archive library path
mdb_ws=/net/mdb.eng/mdb/snapshot/latest # Snapshot of latest workspace
mdb_args= # Debugger argument string
os_name='s81' # Default OS name prefix
os_rel='5.9' # Default OS release number
mach=`/bin/uname -p` # Machine type
unset mdb_exec build root # Local variables
#
# Attempt to locate a suitable mdb binary to execute, first on the local
# machine, then in the user's workspace, and finally on the MDB server.
# If we select the user's workspace, we also set $root to their proto area
# to force MDB to use shared libraries installed there as well.
#
if [ -n "$CODEMGR_WS" -a -x $CODEMGR_WS/proto/root_$mach/usr/bin/mdb ]; then
mdb_exec=$CODEMGR_WS/proto/root_$mach/usr/bin/mdb
root=$CODEMGR_WS/proto/root_$mach
elif [ -x /usr/bin/mdb -a ! -d /mdb ]; then
mdb_exec=/usr/bin/mdb
root=$mdb_lib/$mach/%R/%V
elif [ -x /usr/bin/mdb -a -d /mdb ]; then
for isa in `isalist`; do
if [ -x /usr/bin/$isa/mdb ]; then
mdb_exec=/usr/bin/$isa/mdb
break
fi
done
if [ -z "$mdb_exec" ]; then
echo "$0: cannot find mdb binary in ISA subdirectories" >& 2
exit 1
fi
root=$mdb_lib/$mach/%R/%V
elif [ -x $mdb_ws/proto/root_$mach/usr/bin/mdb ]; then
mdb_exec=$mdb_ws/proto/root_$mach/usr/bin/mdb
root=$mdb_lib/$mach/%R/%V
fi
#
# Abort if we were not able to locate a copy of mdb to execute.
#
if [ -z "$mdb_exec" ]; then
echo "$0: failed to locate mdb executable" >& 2
exit 1
fi
#
# The wrapper script handles several special command-line arguments that are
# used to select a desired set of MDB macros, modules, and a libkvm binary.
#
if [ $# -gt 0 ]; then
case "$1" in
-s[0-9]*)
build=`echo "$1" | tr -d -`
shift
;;
-[0-9]|-[0-9][0-9])
build=`echo "$1" | tr -d -`
if [ $build -lt 10 ]; then
build=${os_name}_0$build
else
build=${os_name}_$build
fi
shift
;;
-[0-9][0-9]-|-[0-9][0-9][A-Za-z])
build=${os_name}_`echo "$1" | cut -c2- | tr '[A-Z]' '[a-z]'`
shift
;;
-B) build=$os_rel/Beta; shift ;;
-U) build=$os_rel/Beta_Update; shift ;;
-G) build=$os_rel/Generic; shift ;;
-\?)
echo "Usage: $0" \
"[ -s<rel> | -s<bld> | -[0-9]+ | -B | -G | -U ] args ..."
echo "\t-s<rel> Use proto area for specified release"
echo "\t e.g. -${os_name}"
echo "\t-s<bld> Use proto area for specified build"
echo "\t e.g. -${os_name}_01"
echo "\t-[0-9]+ Use proto area for specified build of $os_name"
echo "\t-B Use proto area for $os_rel Beta build"
echo "\t-G Use proto area for $os_rel Generic build\n"
echo "\t-U Use proto area for $os_rel Beta_Update build"
;;
esac
fi
#
# If a build was specified, using the corresponding proto area from $mdb_lib.
# Note that this will override the $root setting determined above.
#
[ -n "$build" ] && root=$mdb_lib/$mach/$build
#
# If a proto area was set either by specifying a build number, or by using
# mdb from $CODEMGR_WS, set LD_LIBRARY_PATH accordingly. This allows mdb to
# pick up the appropriate libkvm.so to examine dumps from that build.
# We also add the -R flag to the mdb command line so that mdb will modify
# its default macro include and module library paths to use the build root.
#
if [ -n "$build" -o "$root" = "$CODEMGR_WS/proto/root_$mach" ]; then
if [ -n "$build" -a ! -d $root ]; then
echo "mdb: $root is missing or not a directory" >& 2
exit 1
fi
[ -n "$LD_LIBRARY_PATH" ] && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
LD_LIBRARY_PATH="$LD_LIBRARY_PATH$root/usr/lib"
[ -n "$LD_LIBRARY_PATH_64" ] && LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64:
LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64$root/usr/lib/sparcv9"
export LD_LIBRARY_PATH LD_LIBRARY_PATH_64
elif [ $mdb_exec = $mdb_ws/proto/root_$mach/usr/bin/mdb ]; then
#
# We also need to set LD_LIBRARY_PATH if we're using mdb.eng's mdb
# binary -- it requires the new libproc.so to work properly.
#
usrlib=$mdb_ws/proto/root_$mach/usr/lib
[ -n "$LD_LIBRARY_PATH" ] && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
LD_LIBRARY_PATH="$LD_LIBRARY_PATH$usrlib"
[ -n "$LD_LIBRARY_PATH_64" ] && LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64:
LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64$usrlib/sparcv9"
export LD_LIBRARY_PATH LD_LIBRARY_PATH_64
fi
exec $mdb_exec -R $root $mdb_args "$@"
#!/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
#!/bin/ksh
#
# 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 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
#
# Terminal Info Generator
#
# This script generates a static terminfo database for use by mdb. For each
# of the terminal properties used by mdb_termio.c, this script uses tput(1)
# to determine the value of the given attribute for each specified terminal
# type. The script produces an ANSI-C source file which contains a static
# array for each terminal type storing the properties. An additional array
# is then declared containing a list of the terminal types and pointers to
# the previous arrays. Finally, source code for several terminfo routines
# are included that simply access the arrays and return the saved properties.
#
# Hammerhead: /bin is a separate directory (not symlinked to /usr/bin)
PATH=/bin:/usr/bin; export PATH
PROGNAME=$(basename "$0")
usage()
{
echo "Usage: $PROGNAME -s skel -t termio [-v] term ..." >&2
exit 2
}
extract_section()
{
typeset skel="$1"
typeset secname="$2"
nawk <$skel -v name=$secname -v skel=$skel '
/\/\* [^ ]* [^ ]* \*\// && $3 == name {
if ($2 == "BEGIN") {
printing = 1;
printf("# %d \"%s\"\n", NR + 1, skel);
} else {
printing = 0;
}
next;
}
printing != 0 { print; }
'
}
verbose=false
termio_c=
terminfo_skel=
while getopts s:t:v name ; do
case $name in
v)
verbose=true
;;
s)
terminfo_skel=$OPTARG
;;
t)
termio_c=$OPTARG
;;
?)
usage
;;
esac
done
shift $(($OPTIND - 1))
[[ -z "$terminfo_skel" || -z "$termio_c" || $# -eq 0 ]] && usage
termlist=$*
for term in $termlist; do
tput -T $term init >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "`basename $0`: invalid terminal -- $term" >& 2
exit 1
fi
done
# Extract the prologue from the skeleton
extract_section $terminfo_skel PROLOGUE
#
# For each terminal in the terminal list, produce a property definition array
# listing each property we need in mdb_termio.c and its current value.
#
for term in $termlist; do
#
# We don't want the compiler to blame the skeleton if it doesn't like
# the array we generate here, so point the finger elsewhere
#
echo "# 1 \"dynamic $term data from tigen\""
cterm=$(echo "$term" |tr '-' '_')
$verbose && echo "loading terminfo for $term ... \c" >& 2
echo "static const termio_attr_t ${cterm}_attrs[] = {"
sed -n '/termio_attrs\[\] = /,/^}/p' $termio_c | \
sed -n \ 's/{ "\([a-z0-9]*\)", \([A-Z_]*\),.*/\1 \2/p' | \
while read attr type; do
case "$type" in
TIO_ATTR_REQSTR|TIO_ATTR_STR)
data="\"`tput -T $term $attr | od -bv |
sed 's/^[0-9]*//;s/ /\\\\\\\\/g;/^\$/d'`\""
[ "$data" = '""' ] && data=NULL
;;
TIO_ATTR_BOOL)
tput -T $term $attr
data=`expr 1 - $?`
;;
TIO_ATTR_INT)
data=`tput -T $term $attr`
;;
*)
echo "`basename $0`: unknown type for $attr: $type" >& 2
exit 1
esac
echo "\t{ \"$attr\", $type, (void *)$data },"
done
echo "\t{ NULL, 0, NULL }"
printf '};\n\n'
$verbose && echo "done" >& 2
done
#
# For each terminal in the terminal list, produce an entry in the terminal
# database array linking this terminal to its terminfo property array.
#
echo "# 1 \"dynamic array from tigen\""
echo "static const termio_desc_t termio_db[] = {"
for term in $termlist; do
cterm=$(echo "$term" |tr '-' '_')
echo "\t{ \"$term\", ${cterm}_attrs },"
done
printf '\t{ NULL, NULL }\n};\n'
extract_section $terminfo_skel EPILOGUE
exit 0
|