From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  7-JUL-1989 12:27
To:	MRGATE::"ARISIA::EVERHART"
Subj:	DECWindows "Dummy" Shareable Images

Received: From KL.SRI.COM ([0.0.0.0]) by CRVAX.SRI.COM with TCP; Fri,  7 JUL 89 08:35:27 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 7 Jul 89 08:25:19 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA05129; Fri, 7 Jul 89 08:08:47 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 5 Jul 89 21:52:20 GMT
From: contact!ileaf!io!bcking@husc6.harvard.edu  (Christine King x4426)
Organization: Interleaf Inc, Cambridge, MA
Subject: DECWindows "Dummy" Shareable Images
Message-Id: <1140@io.UUCP>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

Somebody besides us must be having this problem, so here's our
solution.  You want to build an executable image that works in
either a VWS (UIS) or a DECWindows environment.  So you write a
bunch of code that detects what's present and takes the appropriate
path at runtime.  But the problem is that the image you have built
has references to DECWindows routines, so if you try to activate it
in on a machine that doesn't have DECWindows installed you get an
error because the runtime libraries are  missing.  (...Although it
wouldn't really be *used* because your code is so smart...)

What you need is a "dummy" DECWindows runtime library, so all the
references will be resolved.  And here's how to build such a library,
not just for DECWindows, but any runtime library.

(PS: This is the first time I've tried anything like this.  I expect
that if it's dumb or overly-complex or wrong I'll get a lot of mail.
Please don't make it hate-mail.)

>>> This comfile assumes you have 'awk'.  <<<

------ cut here ------
$! make_dummy_shr.com
$!
$ Verify_Status = f$verify('Debug'+0)
$!--
$!	Examine SYS$SHARE: sharable image
$!	and make a dummy sharable image that can take its place
$!	at runtime.  Use it to substitute for a sharable image
$!	whose entries really won't be called at runtime, like
$!	for DECW$XLIBSHR on a system without DECW.
$! P1 = sharable image
$! Usage:
$!      @ make_dummy_shr sys$share:decw$transport_common
$!--
$ awk		:= $ D_LIST:[BIN]NAWK
$!
$ Name	= f$parse(P1,,,"NAME")
$!
$ Unique_Num	= f$getjpi("","PID")
$ Unique_Name	:= 'Name'_'Unique_Num'
$ Analyze_Out	:= 'Unique_Name'.ANL
$ Awk_Pgm	:= 'Unique_Name'.AWK
$ Dummy_Pgm	:= 'Name'.MAR
$ Dummy_Obj	:= 'Name'.OBJ
$ Dummy_Opt	:= 'Unique_Name'.OPT
$!
$ analyze/image 'p1 /out='Analyze_Out'
$!
$ create 'Awk_Pgm'
    BEGIN {
        got_entry_point = 0;
	print ";                                                        "
	print "; "Dummy" sharable image            "
	print ";                                                        "
	print " .title	dummy                                           "
	print " .psect	dummy,exe,nowrt,pic,shr,gbl,quad		"
	print ";                                                        "
	print "; macro to generate a transfer vector entry              "
	print ";                                                        "
	print ".macro	make_entry_for_at_offset  routine_name,offset	"
	print ". = start+offset						"
	print " .transfer	routine_name                            "
	print " .mask		routine_name                            "
	print " .entry		routine_name,0				"
	print "  ret							"
	print " .endm							"
	print ";                                                        "
	print "start:							"
	}
    $2 == "Entry"	{ got_entry_point = 1 }
    $1 == "value:"	{ if (got_entry_point) value = $2 }
    $1 == "symbol:"	{ if (got_entry_point) {
				gsub("\"","",$2);
				printf "   make_entry_for_at_offset %s,<^X%04x>\n", $2, value;
				}
			  got_entry_point = 0 }
    END	{ 
	print ";							"
	print ";							"
	print "	.end							"
	}
$!
$!
$ def/user sys$output 'Dummy_Pgm'
$ awk -f 'Awk_Pgm'  'Analyze_Out'
$!
$ macro/list 'Dummy_Pgm'
$!
$ create 'Awk_Pgm'
    BEGIN	{ got_id = 0 }
    ( $1 " " $2 " " $3 ) == "Fixed Header Information" { got_id = 1 }
    ( $1 " " $2 " " $3 " " $4 ) == "global section major id:" { \
	if ( got_id ) {
	    gsub ("'","",$5);
	    gsub ("'","",$8);
	    printf "gsmatch = lequal,%s %s\n", $5, $8
	    }
	got_id = 0
	}
    END		{}
$!
$ def/user sys$output 'Dummy_Opt'
$ awk -f 'Awk_Pgm'  'Analyze_Out'
$!
$ link /map /full /share 'Dummy_Obj', 'Dummy_Opt'/opt
$!==
$ EXIT:
$ My_Status = $status
$ delete 'Unique_Name'.*;*
$ delete 'Name'.MAR;*,.OBJ;*,.LIS;*,.MAP;*
$ exit 'My_Status' + 0*f$verify('Verify_Status')
----- that's all ------



-- 
MONIKER:	Christine King
UUCP:		...{mit-eddie,ihnp4!harvard!bbn,sun!sunne}!ileaf!bcking
PHONE:		(617) 577-9800
USMAIL:		Interleaf Inc, Ten Canal Park, Cambridge MA 02141

