.;	LINK.CMD  LINK COMMAND FILE  RSX11M
.;	***********************************
.;	Ing. Brunecky  V001	  June 1981
.;	
	.ENABLE SUBSTITUTION
	.SETF ODL
	.SETF MAP
	.SETT TSK
	.SETF RUN
	.SETF ASK
	.SETS P3 "#"
.;	Qualifier parser
	.SETS Q0 "/"
	.IF Q0 NE P1[1:1] .GOTO A10
	.PARSE P1 "/" Q0 QUA
	.SETS P1 P2
	.SETS P2 "#"
.Q10:	.PARSE QUA "/" Q0 QUA
	.PARSE Q0 ":" Q0 Q1
	.SETS Q0 Q0[1:3]
	.IF Q0 = "RUN" .SETT RUN
	.IF Q0 = "MAP" .SETT MAP
	.IF Q0 = "MAP" .SETS P2 Q1
	.IF Q0 = "TAS" .SETT TSK
	.IF Q0 = "TAS" .SETS P3 Q1
	.IF Q0 = "NOT" .SETF TSK
	.IF Q0 = "NOM" .SETF MAP
	.IF Q0 = "RUN" .OR .IF Q0 = "MAP" .OR .IF Q0 = "TAS" .GOTO Q20
	.IF Q0 = "NOM" .OR .IF Q0 = "NOT" .GOTO Q20
	;LINK -- invalid qualifier 'Q0'
	.EXIT
.Q20:	.IF QUA NE "" .GOTO Q10
.;
.;	Input files list [p1] decoding
.A10:	.IF P1 = "" .ASKS P1 Linked files
	.PARSE P1 "@" X1 X2
	.ENABLE QUIET
	.IF X2 NE "" .GOTO L10		.;buildfile prescribed
	.DISABLE QUIET
	.PARSE X1 ":" X0 X1
	.PARSE X0 "/" X3 X4
	.IF X4 NE "" .SETS X1 X0+":"+X1
	.IF X1 EQ "" .SETS X1 X0
	.PARSE X1 "]" X0 X2
	.IF X2 EQ "" .GOTO D00
	.PARSE X1 "[" X1 X0
	.SETS X1 X1+X2
.D00:	.PARSE X1 "," X1 X2
	.PARSE X1 "/" NAM X3
	.IF X3 EQ "" .GOTO D30		.;no switch defined
	.SETS X4 X3[1:2]
	.IF X4 EQ "MP" .GOTO D20	.;ODL defined
	.IF X4 EQ "LB" .GOTO D10	.;ROOT module name from library
	;LINK -- invalid switch /'X4'
	.EXIT
.D10:	.PARSE X3 "::" X1 NAM X4
	.IF NAM NE "" .GOTO D30
.D15:	;LINK -- empty root module name
	.EXIT
.D20:	.SETT ODL
.D30:	.IF NAM EQ "" .GOTO D15
.;
.;	Map file specification [p2] decoding
	.IFF MAP .GOTO T10
	.IF P2 = "#" .SETS P2 NAM+"/SH/WI"
	.IF P2 = "" .ASKS P2 MAP file/sw
	.IF P2 = "" .SETS P2 NAM+"/SH/WI"
	.SETS P2 ","+P2
.;
.;	Task file specification [p3] decoding
.T10:	.IFF TSK .GOTO B10
	.IF P3 = "#" .SETS P3 NAM+"/MM/CP/FP"
	.IF P3 = "" .ASKS P3 TSK file/sw
	.IF P3 = "" .SETS P3 NAM+"/MM/CP/FP"
.;
.;	Generate the buildfile
.B10:	.IFF MAP .SETS P2 ""
	.IFF TSK .SETS P3 ""
	.TESTFILE 'NAM'.BLD
	.DISABLE QUIET
	.IF <FILERR> = 1 ;LINK -- buildfile 'NAM'.BLD allready exists !
	.IF <FILERR> = 1 .EXIT
	.OPEN 'NAM'.BLD
	.DATA ;	'NAM'.BLD - RSX11M BUILD FILE FOR >>>'NAM'<<<
	.DATA ;	*****************************************************
	.DATA ;	LET '<UIC>'				'<DATE>'
	.DATA ;
	.DATA 'P3''P2'=
	.DATA 'P1'
	.IFF ODL .DATA /
	.DATA ACTFIL=4
	.DATA UNITS=6
	.DATA ASG=SY:1:2:3:4:6,TI:5
	.DATA LIBR=F4PRES:RO
	.DATA STACK=120
	.DATA UIC=[377,377]
	.DATA //
	.CLOSE
	;LINK -- buildfile 'NAM'.BLD ready
	.SETS P1 "@"+NAM
.;
.L10:	.PARSE P1 "." X1 X2
	.IF X2 EQ "" .SETS P1 P1+".BLD"
	TKB 'P1'
	.IF <EXSTAT> NE 1 .OR .IFF RUN .EXIT
	.PARSE P3 "/" P3 P2
	RUN 'P3'
	.EXIT
.;
.;	This command file provides DCL-like LINK command. It must be invoked
.;	by SCP driven catch-all monitor, which separates qualifier string
,;	from command by space, so that qualifiers form first parameter.
.;
.;	>LINK/qualif linked-files      OR   >LINK @buildfile
.;
.;	Qualifiers recognized:
.;	/MAP[:filespec]	- prescribes MAP generation
.;	/TSK[:filespec] - defines task image file
.;	/RUN		- requires immediate execution (default /NORUN)
.;	Negatition allowed for /NOMAP and /NOTSK
.;
.;	 LINK requires following inputs:
.;	 * linked file [s] - list of modules, or ODL description marked /MP
.;			      module may be specified in form: library/LB:name
.;			      the first module name is default for map and task
.;	 * map file/sw [s] - filename for map,  default = name/SH/WI
.;	 * tsk file/sw [s] - filename for task, deafult = name/MM/FP/CP
.;
