.ENABLE SUBSTITUTION
.ENABLE ESCAPE
.ENABLE GLOBAL
.DISABLE LOWERCASE
	.SETF REMFLX
	.SETF REMPIP
	.SETF REMFOR
	.SETF REMLBR
	.SETF REMMAC
	.SETF REMTKB
	.SETS BEGINT "'<DATE>' '<TIME>'"
	.IFNINS PIP .SETT REMPIP
	.IFNINS LBR .SETT REMLBR
	.IFNINS MAC .SETT REMMAC
	.IFNINS TKB .SETT REMTKB
	.IFT REMPIP INS $PIP
	.IFT REMLBR INS $LBR
	.IFT REMMAC INS $MAC
	.IFT REMTKB INS $TKB
;
;	SOFTWARE TOOLS FOR RSX-11M[+] -- FALL '83 DECUS DISTRIBUTION
;
;	TOOLGEN STARTED ON '<DATE>' AT '<TIME>'
;
;	YOU MAY REQUEST EXPANDED COMMENTS ON ANY QUESTION BY RESPONDING
;	WITH AN ESCAPE.
;
	.ASK XPD DO YOU WISH TO SEE ALL EXPANDED COMMENTS
	.IFF XPD .GOTO Q0
.H0:
;
;	The Mail system needs to know the time zone in which your
;	machine resides.  Just type in the appropriate three
;	character mnemonic
;
;	eg.	PST
;
.Q0:
	.ASKS TZONE 0. WHAT IS YOUR TIME ZONE [ XXX - DEFAULT: PST ]
	.IFT <ESCAPE> .GOTO H0
	.IF <STRLEN> = 0 .SETS TZONE "PST"
	.IFF XPD .GOTO Q05
.H05:
;
;	By default, the tools write over the contents of an existing file
;	when told to access a file at WRITE access.  Answering YES to this
;	question causes a new version of the file to be created.
;
.Q05:
	.ASK NEWVER 0.5 CREATE NEW VERSION WHEN ACCESSING FILE AT WRITE ACCESS
	.IFT <ESCAPE> .GOTO H05
	.IFF XPD .GOTO Q1
.H1:
;
;	THE TOOLS MAY PASS ARGUMENTS BETWEEN PARENT AND CHILD PROCESSES
;	VIA TWO DIFFERENT MECHANISMS
;
;	1.	USING INTERMEDIATE FILES IN THE SCRATCH DIRECTORY
;
;	2.	USING THE VARIABLE-LENGTH SEND/RECEIVE DRIVER
;		PROVIDED ON THE DISTRIBUTION
;
;	BESIDES PERMITTING THE PASSING OF ARGUMENTS BETWEEN TOOLS, THE
;	SEND/RECEIVE DRIVER PERMITS ANY TASK TO SEND ARBITRARY LENGTH
;	MESSAGES TO ANY OTHER TASK.  SEE THE FILE [307,34]SRDRV.DOC
;	FOR MORE DETAILS.
;
.Q1:
	.ASK USESR 1. DO YOU WISH TO USE THE SEND/RECEIVE DRIVER
	.IFT <ESCAPE> .GOTO H1
	.IFF USESR .GOTO CONT1
	.IFLOA SR: .GOTO CONT1
;
;	TOOLGEN IS VERY INCESTUOUS, IN THAT SOME TOOLS ARE USED TO BUILD
;	THE OTHERS.  IN PARTICULAR, THE SHELL MUST BE ABLE TO SPAWN
;	CHILD PROCESSES AND PASS ARGUMENTS TO THEM.  IF THE SEND/RECEIVE
;	DRIVER WAS CHOSEN, THEN IT MUST BE BUILT AND LOADED INTO MEMORY
;	BEFORE TOOLGEN CAN CONTINUE
;
;
;	SINCE SR: IS NOT LOADED, WE WILL TERMINATE
;	THIS SESSION.  CONSULT THE FILE [307,34]SRDRV.DOC FOR INFORMATION
;	ON THE DRIVER, AND IN PARTICULAR, ON HOW TO BUILD IT.
;
	.EXIT
.CONT1:
.;
.;	CLEAN UP AFTER ANY PREVIOUSLY ABORTED TOOLGEN'S
.;
	.IFINS SHX REM SHX
	.IFINS LSX REM LSX
	.IFINS CHX REM CHX
	.IFINS LDX REM LDX
	.IFINS FCX REM FCX
	.IFF XPD .GOTO Q2
.H2:
;
;	ALL OF THE IMAGE AND READ-ONLY TEXT FILES ARE KEPT IN DIRECTORIES
;	ON THE LOGICAL DEVICE ST0:.  THE DIRECTORIES ARE GIVEN THE
;	PROTECTION [RWE,RWE,RWE,RE]
;
.Q2:
	.ASKS DEV 2. DEVICE AND UNIT FOR ST0 [ DDN - DEFAULT: LB0 ]
	.IFT <ESCAPE> .GOTO H2
	.IF <STRLEN> = 0 .SETS DEV "LB0"
	.SETS RDEV DEV+":"
	.SETS TMPS DEV
	.IFF XPD .GOTO Q3
.H3:
;
;	THE SCRATCH DIRECTORY AND THAT FOR FORMATTED LPR FILES RESIDE
;	ON THE LOGICAL DEVICE ST1:.  THESE DIRECTORIES ARE GIVEN THE
;	PROTECTION [RWE,RWE,RWE,RWE]
;
.Q3:
	.ASKS DEV 3. DEVICE AND UNIT FOR ST1 [ DDN - DEFAULT: 'TMPS' ]
	.IFT <ESCAPE> .GOTO H3
	.IF <STRLEN> = 0 .SETS DEV TMPS
	.SETS WDEV DEV+":"
	ASN 'RDEV'=ST0:
	ASN 'WDEV'=ST1:
	.IFF XPD .GOTO Q4
.H4:
;
;	THE TOOLS OCCUPY 6 UIC'S, ALL IN THE SAME GROUP.  THE DEFAULT
;	GROUP IS 105, BUT YOU MAY CHANGE THIS AT THIS TIME.
;
.Q4:
	.ASKN [0:377:105] GRP 4. GROUP FOR TOOLS SYSTEM
	.IFT <ESCAPE> .GOTO H4
	.IFF XPD .GOTO Q5
.H5:
;
;	THE TOOLS OCCUPY 6 CONSECUTIVE MEMBER NUMBERS IN GROUP 'GRP'.
;	THE DEFAULT BASE FOR THIS SEQUENCE IS 1, BUT YOU MAY CHANGE THIS
;	AT THIS TIME
;
.Q5:
	.ASKN [1:370:1] MEM 5. MEMBER NO FOR BIN DIRECTORY
	.IFT <ESCAPE> .GOTO H5
	.SETS BIN "'GRP'"+","+"'MEM'"
	.INC MEM
	.SETS USR "'GRP'"+","+"'MEM'"
	.INC MEM
	.SETS TMP "'GRP'"+","+"'MEM'"
	.INC MEM
	.SETS LPR "'GRP'"+","+"'MEM'"
	.INC MEM
	.SETS MSG "'GRP'"+","+"'MEM'"
	.INC MEM
	.SETS MAN "'GRP'"+","+"'MEM'"
;
;	NOW CREATE THE NECESSARY UIC'S ON THE TARGET DISKS WITH
;	THE APPROPRIATE PROTECTION
;
	UFD 'RDEV'['BIN']/PRO=[RWE,RWE,RWE,RE]
	UFD 'RDEV'['USR']/PRO=[RWE,RWE,RWE,RE]
	UFD 'WDEV'['TMP']/PRO=[RWE,RWE,RWE,RWE]
	UFD 'WDEV'['LPR']/PRO=[RWE,RWE,RWE,RWE]
	UFD 'WDEV'['MSG']/PRO=[RWE,RWE,RWE,RE]
	UFD 'RDEV'['MAN']/PRO=[RWE,RWE,RWE,RE]
	.IFF XPD .GOTO Q5A
.H5A:
;
;	IF YOU ARE DOING YOUR SECOND OR WORSE TOOLGEN ON THE SAME DIRECTORIES,
;	IT IS NECESSARY TO CLEAN UP ALL DIRECTORIES BUT ['USR']
;	IF YOU ANSWER NO, WE EXIT TO PERMIT YOU TO SAVE APPROPRIATE FILES
;
.Q5A:
	.ASK CLEAND 5A. DELETE ALL OLD FILES ON THE TOOLS DIRECTORIES
	.IFT <ESCAPE> .GOTO H5A
	.IFF CLEAND .EXIT
	.IFF XPD .GOTO Q6
.H6:
;
;	IF YOU OBTAINED YOUR DISTRIBUTION FROM THE DECUS SIG SYMPOSIUM
;	TAPE, THEN YOU HAVE ALREADY BRU'ED THE NECESSARY FILES ONTO A
;	DISK.  SOME OF YOU MAY HAVE RECEIVED YOUR DISTRIBUTION IN DOS
;	FORMAT VIA DIFFERENT DISTRIBUTION.  TOOLGEN WILL PERMIT
;	THE PEOPLE IN THE LATTER CATEGORY TO BUILD THE SYSTEM DIRECTLY
;	FROM THE TAPE, ALTHOUGH THAT IS MUCH SLOWER.   A COPY OF FFL
;	IS PROVIDED IN [307,30] IF YOU WISH TO STOP NOW AND ZAP THE
;	FILES TO DISK
;
.Q6:
	.ASK IFTAPE 6. BUILDING DIRECTLY FROM DOS DISTN TAPE
	.IFT <ESCAPE> .GOTO H6
	.IFF IFTAPE .GOTO CONT2
	.IFF XPD .GOTO Q6A
.H6A:
;
;	INPUT THE NAME OF THE MAG TAPE DEVICE UPON WHICH THE DOS TAPE
;	IS MOUNTED.  TOOLGEN WILL CHECK TO SEE IF FLX IS INSTALLED, AND
;	WILL INSTALL IT IF NOT.
;
.Q6A:
	.ASKS IDEV 6A. TAPE DEVICE AND UNIT NUMBER [ DDN - DEFAULT: MM0 ]
	.IFT <ESCAPE> .GOTO H6A
	.IF <STRLEN> = 0 .SETS IDEV "MM0"
	.IFINS FLX .GOTO CONT3
	.SETT REMFLX
	INS $FLX
	.GOTO CONT3
.CONT2:
	.IFF XPD .GOTO Q6B
.H6B:
;
;	INPUT THE NAME OF THE DISK UPON WHICH THE UIC [307,31]
;	HAS BEEN COPIED FROM THE DISTN TAPE.  TOOLGEN WILL CHECK
;	TO SEE IF PIP IS INSTALLED, AND WILL INSTALL IT IF NOT.
;
.Q6B:
	.ASKS IDEV 6B. DISK DEVICE AND UNIT [ DDN - DEFAULT: LB0 ]
	.IFT <ESCAPE> .GOTO H6B
	.IF <STRLEN> = 0 .SETS IDEV "LB0"
.CONT3:
	.SETS TAPE IDEV+":"
	.IFF XPD .GOTO Q7
.H7:
;
;	THE TOOLS WORK WITH BOTH THE FORTRAN IV AND 77/4+ COMPILERS.
;	THIS QUESTION INDICATES TO TOOLGEN WHICH GENERIC COMPILER YOU WISH TO
;	USE.
;
.Q7:
	.ASK COMPLR 7. DO YOU WISH TO USE THE F77/F4P COMPILER
	.IFT <ESCAPE> .GOTO H7
	.SETS FORTRN "F77"
	.SETS FORTSW "/NOTR/NOCK/CO:19./RO"
	.IFF COMPLR .GOTO CONT4P
.Q7A:
	.ASK F77O4P 7A. IS IT F77
	.IFT <ESCAPE> .GOTO Q7A
	.IFF F77O4P .SETS FORTRN "F4P"
	.GOTO CONT4
.CONT4P:
	.SETS FORTRN "FOR"
	.SETS FORTSW "/NOSN/NOVA/NOLO/RO"
.CONT4:
	.SETS CMPNAM FORTRN
	.IFINS 'FORTRN' .GOTO CONT5
;
;	YOU DO NOT HAVE 'FORTRN' INSTALLED UNDER THAT NAME.  TOOLGEN
;	MUST INSTALL IT UNDER THAT NAME, BUT WILL REMOVE IT AT THE END.
;
;	IN ADDITION, YOU MUST ANSWER THE NEXT QUESTION TO PERMIT FC TO
;	BE BUILT PROPERLY FOR THE WAY YOU NORMALLY INSTALL 'FORTRN'
;
	.SETT REMFOR
	.IFF XPD .GOTO Q7B
.H7B:
;
;	ENTER THE NAME UNDER WHICH THE COMPILER IS NORMALLY INSTALLED.  IF
;	YOU USE A CATCH ALL TASK, GIVE THE NAME OF THE TASK IMAGE AS IT
;	RESIDES IN THE KNOWN DIRECTORY - I.E IF IT IS [1,54]F30.TSK (TO
;	PERMIT BOTH F4P 2.51 AND 3.0 TO RESIDE IN THE SAME SYSTEM) THEN
;	RESPOND 	F30
;
.Q7B:
	.ASKS CMPNAM 7B. WHAT IS THE NORMAL NAME OF THE COMPILER
	.IFT <ESCAPE> .GOTO H7B
	.IF <STRLEN> > 0 .GOTO CONT5
;
;	YOU MUST GIVE AN ANSWER TO QUESTION 7A, SINCE I MUST INSTALL THE DAMN
;	COMPILER.
;
	.GOTO Q7B
.CONT5:
	.IFNINS 'FORTRN' INS $'CMPNAM'/TASK=...'FORTRN'
	.IFF XPD .GOTO Q8
.H8:
;
;	MANY SITES DO NOT PLACE THE FORTRAN OBJECT TIME SYSTEM (OTS)
;	LIBRARY INTO LB:[1,1]SYSLIB.  THIS QUESTION QUERIES THAT SITUATION.
;
.Q8:
	.ASK SYSOTS 8. IS THE FORTRAN OTS IN LB:[1,1]SYSLIB.OLB
	.IFT <ESCAPE> .GOTO H8
	.SETS OTSFIL "LB0:[1,1]SYSLIB"
	.IFT SYSOTS .GOTO CONT6
	.IFF XPD .GOTO Q8A
.H8A:
;
;	INPUT THE FILE SPEC OF THE FORTRAN OTS LIBRARY.  IT MUST BE THE
;	FULL FILE SPECIFICATON - I.E DDN:[G,M]NAME
;
;	FOR EXAMPLE	LB:[1,1]'CMPNAM'OTS
;
.Q8A:
	.ASKS OTSFIL 8A. FILE SPEC FOR OTS LIB [DEFAULT: LB:[1,1]'CMPNAM'OTS]
	.IFT <ESCAPE> .GOTO H8A
	.IF <STRLEN> = 0 .SETS OTSFIL "LB:[1,1]'CMPNAM'OTS"
.CONT6:
	.SETT FPP
	.SETS LDFIL "LDFP"
	.IFT COMPLR .GOTO CONT7
	.IFF XPD .GOTO Q9
.H9:
;
;	YOUR SITE MAY BE RUNNING FORTRAN IV FOR COMPATIBILITY WITH OTHER
;	PDP11'S WITHOUT FPP, BUT YOU MAY BE USING THE FPPOTS FOR FORTRAN
;	IV ON YOUR MACHINE WITH A FLOATING POINT PROCESSOR.  THE FOLLOWING
;	QUESTION PERMITS LD TO BUILD THE TASKS /FP IF THIS IS THE CASE.
;
.Q9:
	.ASK FPP 9. DO YOU WISH THE TASKS BUILT /FP
	.IFT <ESCAPE> .GOTO H9
	.IFF FPP .SETS LDFIL "LDNOFP"
.CONT7:
	.SETS FPSW "/FP"
	.IFF FPP .SETS FPSW "/-FP"
	.IFF XPD .GOTO Q10
.H10:
;
;	IF YOU HAVE AN FCS RESIDENT LIBRARY INSTALLED, THE TOOLS MAY BE
;	TASKBUILT OVER IT.  THIS RESULTS IN CONSIDERABLE SAVINGS IN
;	THE DISK SPACE REQUIRED FOR THE TASK IMAGES, SINCE EACH TOOL
;	WILL DRAG IN APPROX. 6500 BYTES OF FCS.  IN ADDITION, FCSRES
;	GREATLY REDUCES THE CHECKPOINT ACTIVITY OF YOUR SYSTEM.  SEE
;	[307,30]RELEASE.DOC FOR MORE DETAILS ON FCSRES
;
.Q10:
	.ASK FCSRES 10. DO YOU WISH TO LINK TO AN FCS RESIDENT LIBRARY
	.IFT <ESCAPE> .GOTO H10
	.SETS RESLIB ";"
	.IFF FCSRES .GOTO CONT8
	.IFF XPD .GOTO Q10A
.H10A:
;
;	INPUT THE TKB OPTION LINE FOR LINKING TO THE RESIDENT LIBRARY
;	THE DEFAULT IS "LIBR=FCSRES:RO"
;
;	ON M+ SYSTEMS WITH A SUPERVISOR MODE FCS LIBRARY, INPUT
;
;			SUPLIB=FCSFSL:SV
;
.Q10A:
;	INPUT THE TKB OPTION LINE FOR LINKING TO THE RESIDENT LIBRARY
	.ASKS RESLIB TKB OPTION LINE [DEFAULT - LIBR=FCSRES:RO ]
	.IFT <ESCAPE> .GOTO H10A
	.IF <STRLEN> = 0 .SETS RESLIB "LIBR=FCSRES:RO"
.CONT8:
	.IFF XPD .GOTO Q11
.H11:
;
;	THE FOLLLOWING TWO QUESTIONS PERMIT THE USER TO CONTROL THE AMOUNT
;	OF SPACE THAT THE COMPLETED SYSTEM WILL TAKE UP ON THE TARGET DISK.
;
;	IF NONE OF THE FILES ARE DELETED DURING THE PROCESSING, THE ENTIRE
;	SYSTEM OCCUPIES APPROX 16600 BLOCKS
;
;	IF THE FORTRAN AND MACRO SOURCE FILES ARE DELETED ALONG THE WAY,
;	A SAVINGS OF 2575 BLOCKS ENSUES.
;
;	IF THE OBJECT FILES ARE DELETED AFTER USE, WE SAVE ANOTHER 3325 BLOCKS
;
;	DELETED		SPACE OCCUPIED
;	-------		--------------
;	 NONE		   16600
;	  .F		   14050
;	 .OBJ		   13300
;	 BOTH		   10725
;
;	OF COURSE, IF YOU LINK WITH FCSRES, YOUR TOTAL SPACE WILL BE
;	SMALLER BY ANOTHER 2800 BLOCKS
;
.Q11:
	.ASK $SRCDE 11A. DELETE THE FORTRAN AND MACRO SOURCES AS WE PROGRESS
	.IFT <ESCAPE> .GOTO H11
	.ASK $OBJDE 11B. DELETE THE OBJECT FILES AS WE GO ALONG
	.IFT <ESCAPE> .GOTO H11
	.IFF XPD .GOTO Q12
.H12:
;
;	If your system supports the PLAS directives, a memory-overlaid
;	version of the history shell can be built which includes the
;	capability of defining and using aliases.  If this option is
;	not selected, the usual history shell is built.
;
.Q12:
	.ASK MOVSHL 12. DO YOU WANT THE MEMORY-OVERLAID HISTORY SHELL
	.IFT <ESCAPE> .GOTO H12
;
;	NOW WE START TO PROCESS
;
;	FIRST COPY THE FILES TO THE APPROPRIATE DIRECTORIES
;
	ASN 'RDEV'=SY:
.CONT9:
	.IFF CLEAND .GOTO CONT10
	PIP ['BIN']*.*;*/DE/NM
	PIP ST1:['TMP']*.*;*/DE/NM
	PIP ST1:['LPR']*.*;*/DE/NM
	PIP ST1:['MSG']*.*;*/DE/NM
	PIP ['MAN']*.*;*/DE/NM
.CONT10:
	.IFT IFTAPE FLX ['BIN']/RS='TAPE'[307,31]*.*/DO
	.IFF IFTAPE PIP ['BIN']*.*;*='TAPE'[307,31]*.*;*
;
;	EXTRACT NEEDED TASK IMAGES FROM UNIVERSAL LIBRARY
;
	LBR ['BIN']CHX.TSK=['BIN']SUPPORT.ULB/EX:CH
	LBR ['BIN']LS.TSK=['BIN']SUPPORT.ULB/EX:LS
	PIP ['BIN']SUPPORT.ULB;*/DE
;
;	MAKE SURE .F FILES ARE VERSION 1
;
	PIP ['BIN']*.F;1=['BIN']*.F;*/RE
	PIP ['BIN']*.;1=['BIN']*.;*/RE
;
;	NOW MODIFY THE SOURCE FILES WHICH REFERENCE ['BIN'] -> ['MAN']
;
	INS ['BIN']CHX/TASK=...CHX
	PIP ['BIN']GETDIR.SRC=['BIN']GETDIR.MAC
	CHX <['BIN']GETDIR.SRC >['BIN']T.1 105,1 'BIN'
	CHX <['BIN']T.1 >['BIN']T.2 105,2 'USR'
	CHX <['BIN']T.2 >['BIN']T.1 105,3 'TMP'
	CHX <['BIN']T.1 >['BIN']T.2 105,4 'LPR'
	CHX <['BIN']T.2 >['BIN']T.1 105,5 'MSG'
	CHX <['BIN']T.1 >['BIN']GETDIR.MAC 105,6 'MAN'
	PIP ['BIN']CRLOCK.SRC=['BIN']CRLOCK.MAC
	CHX <['BIN']CRLOCK.SRC >['BIN']CRLOCK.MAC 105,3 'TMP'
	CHX <['BIN']BSPAWN.SRC >['BIN']T.1 105,1 'BIN'
	CHX <['BIN']T.1 >['BIN']BSPAWN.SRC 105,3 'TMP'
	PIP ['BIN']T.*;*/DE
;
;	NOW BUILD SITE-DEPENDENT FILES FROM ANSWERS TO ABOVE QUESTIONS
;
	PIP ['BIN']LD.FF=['BIN']'LDFIL'.FF
	.TEST CMPNAM
	.IFT COMPLR CHX <['BIN']FCF4P.FF >['BIN']FC.FF 3HF4P '<STRLEN>'H'CMPNAM'
	.IFF COMPLR CHX <['BIN']FCFOR.FF >['BIN']FC.FF 3HFOR '<STRLEN>'H'CMPNAM'
	.SETS ALFBET "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	.SETS X TZONE[1:1]
	.SETN I 1
.101:
	.IF I > 26. .GOTO 102
	.SETS Y ALFBET['I':'I']
	.IF X = Y .GOTO 102
	.INC I
	.GOTO 101
.102:
	.SETN I I+64.
	CHX <['BIN']PRIMPST.FF >['BIN']PRIM.FF "TZONE(1)/80" "TZONE(1)/'I'"
	.OPEN ['BIN']ASM.PRE
	.DATA 	.NLIST
	.IFT USESR .DATA SRDRV=0
	.IFT NEWVER .DATA NEWVER=0
	.DATA 	.LIST
	.CLOSE
	.OPENA ['BIN']RATDEF.
	.DATA DEFINE(TIME_ZONE,"'TZONE'")
	.DATA DEFINE(FORT_COMP,'FORTRN')
	.TEST CMPNAM
	.DATA DEFINE(COMP_NAME,'<STRLEN>'H'CMPNAM')
	.IFT FPP .DATA DEFINE(FLOAT_PT,YES)
	.IFF FPP .DATA DEFINE(FLOAT_PT,NO)
	.CLOSE
	.SETF NERFIL
	.OPEN ['BIN']TOOLS.TKB
	.IFF COMPLR .GOTO X1
	.TESTFILE LB:[1,1]'CMPNAM'NER.OBJ
	.IF <FILERR> <> 1 .GOTO X1
	.SETT NERFIL
	.DATA LB:[1,1]'CMPNAM'NER.OBJ
.X1:
	.DATA 'OTSFIL'/LB:$SHORT
	.IFF SYSOTS .DATA 'OTSFIL'/LB
	.DATA /
	.DATA UNITS=8
	.DATA ACTFIL=7
	.IFT FCSRES .DATA 'RESLIB'
	.DATA //
	.CLOSE
	.OPEN ['BIN']BIGTOOL.TKB
	.DATA ['BIN']BIGTOOL/CP'FPSW'=
	.DATA ['BIN']BIGTOOL
	.DATA ['BIN']RLIB/LB:.MAIN.
	.DATA ['BIN']RLIB/LB
	.IFT NERFIL .DATA LB:[1,1]'CMPNAM'NER.OBJ
	.DATA 'OTSFIL'/LB:$SHORT
	.IFF SYSOTS .DATA 'OTSFIL'/LB
	.DATA /
	.DATA UNITS=8
	.DATA ACTFIL=7
	.DATA //
	.CLOSE
;
;	HERE IS THE TEMPLATE TKB COMMAND FILE USED TO TASK BUILD THE TOOLS
;
PIP TI:=['BIN']TOOLS.TKB
;
;	NOW WE BUILD THE TOOLS LIBRARY, RLIB.OLB
;
;	ASSEMBLE ALL OF THE .MAC FILES
;
	INS ['BIN']LS/TASK=...LSX
	LSX /'BIN'/.MAC >/'BIN'/T.1
	CHX </'BIN'/T.1 >/'BIN'/T.2 ".?*$"
	CHX </'BIN'/T.2 >/'BIN'/ASSEMBLE.CMD "%?*$" "['BIN']&=['BIN']ASM.PRE,&"
	PIP TI:=['BIN']ASSEMBLE.CMD
	MAC @['BIN']ASSEMBLE
	PIP ['BIN']ASSEMBLE.OBS=['BIN']*.OBJ
.CONT11:
	LBR ['BIN']RLIB.OLB/CR:400.:1024.:1024.=['BIN']ASSEMBLE.OBS
	PIP ['BIN']*.OBS;*/DE,T.*;*,ASSEMBLE.CMD;*,GETDIR.SRC;*,PRIMPST.FF;*
	.IFT $SRCDE PIP ['BIN']*.MAC;*/DE
	.IFT $OBJDE PIP ['BIN']*.OBJ;*/DE
;
;	NOW COMPILE THE PRIMITIVE FUNCTIONS IN RATFOR AND PLACE THEM IN
;	THE LIBRARY
;
	'FORTRN' ['BIN']PRIM=['BIN']PRIM.FF'FORTSW'
	'FORTRN' ['BIN']LIB=['BIN']LIB.FF'FORTSW'
	LBR ['BIN']RLIB/RP=['BIN']PRIM,LIB
	.IFT $SRCDE PIP ['BIN']PRIM.FF;*/DE,LIB.FF;*
	.IFT $OBJDE PIP ['BIN']PRIM.OBJ;*/DE,LIB.OBJ;*
	.IFF MOVSHL .GOTO MOV1
;
;	NOW COMPILE THE MEMORY-OVERLAID VERSION OF THE SHELL AND INSTALL
;	THE MODULES INTO A LIBRARY
;
	'FORTRN' ['BIN']MOVHSH=['BIN']MOVHSH.FF'FORTSW'
	LBR ['BIN']MOVHSH.OLB/CR=['BIN']MOVHSH.OBJ
;
;	Build the command and ODL files to build the memory-overlaid
;	version of the shell.  Then build the task.
;
.OPEN	['BIN']MOVHSH.TKB
.IFT	FPP	.DATA ST0:['BIN']HSH/FP/CP=ST0:['BIN']MOVHSH/MP
.IFF	FPP	.DATA ST0:['BIN']HSH/CP=ST0:['BIN']MOVHSH/MP
		.DATA UNITS=8
		.DATA ACTFIL=7
.IFT	FCSRES	.DATA 'RESLIB'
		.DATA //
.CLOSE
.SETS	RLIBST	"ST:["+BIN+"]RLIB/LB"
.SETS	SHST	"ST:["+BIN+"]MOVHSH/LB"
.OPEN	['BIN']MOVHSH.ODL
.ENABLE	DATA
	.NAME	SHROOT
	.NAME	SHINIT
	.NAME	SHINPT
	.NAME	SHPARS
	.NAME	SHEXEC
	.ROOT	SHROOT-MAIN-*!(SHINIT-INIT,SHINPT-INPUT,SHPARS-PARSE,SHEXEC-EXEC)
.DISABLE DATA
.IFT	SYSOTS	.DATA MAIN:	.FCTR	COMMON-MAIN1-MAIN2-FORTS-SLIB
.IFF	SYSOTS	.DATA MAIN:	.FCTR	COMMON-MAIN1-MAIN2-FORTS-FLIB-SLIB
.ENABLE	DATA
COMMON:	.FCTR	CDSMEM-SHFLAG-STDSUB-CPBACK-CSCLIN-CPARS
	.PSECT	CDSMEM,RW,D,GBL,REL,OVR
	.PSECT	SHFLAG,RW,D,GBL,REL,OVR
	.PSECT	STDSUB,RW,D,GBL,REL,OVR
	.PSECT	CPBACK,RW,D,GBL,REL,OVR
	.PSECT	CSCLIN,RW,D,GBL,REL,OVR
	.PSECT	CPARS,RW,D,GBL,REL,OVR
MAIN1:	.FCTR	MAIN11-MAIN12-MAIN13-MAIN14-MAIN15-MAIN16-MAIN17
MAIN11:	.FCTR	'RLIBST':.MAIN.:CLOWER:CONCAT:DSFREE:DSGET:ENTDEF
MAIN12:	.FCTR	'RLIBST':ENTER:ERROR:FDEL:FGENR8:FLFIND:FXLATE
MAIN13:	.FCTR	'RLIBST':GETCH:GETDIR:GETLIN:GETPNM:GETTYP:GLOCNM
MAIN14:	.FCTR	'RLIBST':GWDIR:HOMDIR:ITOC:LOCCOM:LOOKUP:LUDEF
MAIN15:	.FCTR	'RLIBST':MINLIB:MINPRM:MKPATH:PUTSTR:QUERY:R$CVTF
MAIN16:	.FCTR	'RLIBST':R$GUIC:REALDV:REMARK:REMOVE:RESDEF:RESTIL
MAIN17:	.FCTR	'RLIBST':SCOPY:SCRATF:SDUPL:SKIPBL:STLU:PROMPT
MAIN2:	.FCTR	'SHST':ENDSH:MAIN
.DISABLE DATA
.IFT	SYSOTS	.DATA INIT:	.FCTR	INIT1-INIT2-SLIB
.IFF	SYSOTS	.DATA INIT:	.FCTR	INIT1-INIT2-FLIB
.ENABLE DATA
INIT1:	.FCTR	INIT11-INIT12
INIT11:	.FCTR	'RLIBST':DELARG:DSINIT:ENBINT:GETARG:IMPATH:MKTABL
INIT12:	.FCTR	'RLIBST':PBINIT:TOOLDR
INIT2:	.FCTR	'SHST':ARGLIN:INITSH:RLOGIN
.DISABLE DATA
.IFT	SYSOTS	.DATA INPUT:	.FCTR	INPUT1-INPUT2-SLIB
.IFF	SYSOTS	.DATA INPUT:	.FCTR	INPUT1-INPUT2-FLIB
.ENABLE DATA
INPUT1:	.FCTR	INP11-INP12-INP13-INP14-INP15-INP16-INP17-INP18
INP11:	.FCTR	'RLIBST':ADDINT:ADDSET:AMATCH:CATSUB:CTOI:DODASH
INP12:	.FCTR	'RLIBST':EDLINE:ESC:FILSET:GETCCL:LOCATE:LOGEND
INP13:	.FCTR	'RLIBST':LOGPMT:MAKPAT:MAKSUB:MATCH:NOTE:OMATCH
INP14:	.FCTR	'RLIBST':PATSIZ:PLOG00:PLOG01:PLOG03:PLOG04:PLOG06
INP15:	.FCTR	'RLIBST':PLOG07:PLOG08:PLOG09:PLOG10:PLOG11:PLOG12
INP16:	.FCTR	'RLIBST':PLOG13:PLOG14:PLOG15:PLOG16:PLOG17:PLOG18
INP17:	.FCTR	'RLIBST':PLOG19:PLOG20:PLOG21:PLOG22:PUTINT:SEEK
INP18:	.FCTR	'RLIBST':STCLOS
INPUT2:	.FCTR	'SHST':SHLINE
.DISABLE DATA
.IFT	SYSOTS	.DATA PARSE:	.FCTR	PARSE1-PARSE2-SLIB
.IFF	SYSOTS	.DATA PARSE:	.FCTR	PARSE1-PARSE2-FLIB
.ENABLE DATA
PARSE1:	.FCTR	'RLIBST':NGETCH:PBSTR:PUTBAK
PARSE2:	.FCTR	PAR21-PAR22-PAR23-PAR24
PAR21:	.FCTR	'SHST':ATBEG:DOPAR:DOVERB:MKTOKS:MKTREE:NEXTP
PAR22:	.FCTR	'SHST':PARAM:PARSER:PASTBL:PUTBAC:QS:SETREE
PAR23:	.FCTR	'SHST':SHTOK:SPEC:STXERR:SYN1:SYN2:SYN3
PAR24:	.FCTR	'SHST':SYNTAX
.DISABLE DATA
.IFT	SYSOTS	.DATA EXEC:	.FCTR	EXEC1-EXEC2-SLIB
.IFF	SYSOTS	.DATA EXEC:	.FCTR	EXEC1-EXEC2-FLIB
.ENABLE DATA
EXEC1:	.FCTR	EXEC11-EXEC12-EXEC13-EXEC14-EXEC15
EXEC11:	.FCTR	'RLIBST':APPRED:ASSNGI:BCKSPN:CLOSDR:CWDIR:DELETE
EXEC12:	.FCTR	'RLIBST':DOPEN:EXTPNM:FILNFO:GENPNM:GETPRI:GTMODE
EXEC13:	.FCTR	'RLIBST':INDEXS:OPENDR:RCVDAT:RMDEF:SCTABL:SDAT
EXEC14:	.FCTR	'RLIBST':SNDARG:SPWSUB:SRDA:SRESET:SSPAWN:STDDEV
EXEC15:	.FCTR	'RLIBST':STDDIR:STMODE:STSPWN:UPPER
EXEC2:	.FCTR	EXEC21-EXEC22-EXEC23-EXEC24-EXEC25
EXEC21:	.FCTR	'SHST':CHGDIR:CMDTYP:DOAMPR:DOCOM:DOPARN:DOPIPE
EXEC22:	.FCTR	'SHST':DOSEMI:DSPCOM:DSPPTH:DSPTBL:ERRF:EXECUT
EXEC23:	.FCTR	'SHST':GETCL:GPAR:GPNAME:GTASK:HERDOC:INF
EXEC24:	.FCTR	'SHST':KILLDF:MVNEXT:NXTBR:OUTF:PICKUP:PROCDF
EXEC25:	.FCTR	'SHST':PWDIR:SCRF:SHCOM:SHELLC:STRIPB:DASK
.DISABLE DATA
.IFT	NERFIL	.DATA FORTS:	.FCTR	LB:[1,1]'CMPNAM'NER.OBJ-'OTSFIL'/LB:$SHORT
.IFF	NERFIL	.DATA FORTS:	.FCTR	'OTSFIL'/LB:$SHORT
.IFF	SYSOTS	.DATA FLIB:	.FCTR	'OTSFIL'/LB
		.DATA SLIB:	.FCTR	LB:[1,1]SYSLIB/LB
		.DATA 	.END
.CLOSE
	TKB @['BIN']MOVHSH.TKB
.MOV1:
	.IFT $SRCDE PIP ['BIN']MOVHSH.FF;*/DE
	.IFT $OBJDE PIP ['BIN']MOVHSH.OBJ;*/DE
;
;	NOW BUILD LD AND FC, WHICH AUTOMATE THE REST OF THE TOOLGEN
;
	'FORTRN' ['BIN']LD=['BIN']LD.FF'FORTSW'
	'FORTRN' ['BIN']FC=['BIN']FC.FF'FORTSW'
	.IFT $SRCDE PIP ['BIN']LD.FF;*/DE,FC.FF;*,FCFOR.FF;*,FCF4P.*;*
	.IFT $SRCDE PIP ['BIN']LDFP.FF;*/DE,LDNOFP.FF;*
	.OPEN ['BIN']LD.TKB
	.DATA ['BIN']LD/CP'FPSW'=
	.DATA ['BIN']LD
	.DATA ['BIN']RLIB/LB:.MAIN.
	.DATA ['BIN']RLIB/LB
	.CLOSE
	PIP ['BIN']LD.TKB/AP=['BIN']TOOLS.TKB
	TKB @['BIN']LD.TKB
	INS ['BIN']LD/TASK=...LDX
	LDX -V ['BIN']FC
	REM LDX
	.IFT $OBJDE PIP ['BIN']LD.OBJ;*/DE,FC.OBJ;*
	INS ['BIN']FC/TASK=...FCX
	.OPEN ['BIN']FEL.TKB
	.DATA ['BIN']FELLTREE/CP/-FP=['BIN']RLIB/LB:FEL
	.DATA /
	.DATA UNITS=1
	.DATA TASK=...FEL
	.DATA STACK=64
	.DATA //
	.CLOSE
	TKB @['BIN']FEL.TKB
;
;
;	NOW BUILD A COMMAND FILE TO COMPILE AND LINK ALL OF THE TOOLS
;
	LSX /'BIN'/.F$ >/'BIN'/T.1
	CHX </'BIN'/T.1 >/'BIN'/FLIST ".?*$"
;
;	TAKE A LONG BREAK - IT TAKES BETWEEN ONE AND TWO HOURS TO BUILD
;	THESE TASKS
;
	.OPENR ['BIN']FLIST.
.10:
	.READ FILE
	.IF <FILERR> <> 1 .GOTO 20
	.IFF FCSRES .GOTO 12
	.IF FILE = "ED" .GOTO 11
	.IF FILE = "HSH" .GOTO 14
	.IF FILE = "RATP1" .GOTO 11
	.GOTO 12
.14:
	.IFT MOVSHL .GOTO 13
.11:
	FCX -C ['BIN']'FILE'.F
	CHX <['BIN']BIGTOOL.TKB >['BIN']'FILE'.TKB BIGTOOL 'FILE'
	TKB @['BIN']'FILE'.TKB
	.GOTO 13
.12:
	FCX ['BIN']'FILE'.F
.13:
	.IFT $SRCDE PIP ['BIN']'FILE'.F;*/DE/NM
	.IFT $OBJDE PIP ['BIN']'FILE'.OBJ;*/DE/NM
	.GOTO 10
.20:
	.CLOSE
	PIP ['BIN']T.*;*/DE,FLIST.*;*,CHX.TSK;*
;
;	NOW WE JUST HAVE A LITTLE BIT OF CLEANUP LEFT
;
;	FIXUP SCRIPT FILES REFERENCING ['BIN'] -> ['MAN']
;
	INS ST0:['BIN']SH/TASK=...SHX
	SHX -X ['BIN']FIXUP 'BIN' 'TMP'
	PIP ST1:['MSG']*.*=['BIN']MSGHLP.
	PIP ['BIN']MSGHLP.;*/DE
;
;	FIXUP FILES NEEDING TO KNOW THE VALUES OF ST0: AND ST1:
;
	SHX -X ['BIN']DFIXUP 'RDEV' 'WDEV'
;
;	BUILD DICTIONARY INDEX FOR SPELL TOOL
;
	SHX -C "ISAM <['BIN']DICT >['BIN']DICTDX -D20"
;
;	TRIM THE FILES IN ['BIN']
;
	PIP ['BIN']FIXUP.;*/DE,DFIXUP.;*
	PIP ['BIN']*.*;*/PR/WO:RE
	PIP ['BIN']*.*;*/TR
;
;	BUILD DOCUMENTATION DIRECTORY ['MAN']
;
	PIP ['MAN']S1.;1=['BIN']SECT1.;1/RE
	PIP ['MAN']S2.;1=['BIN']SECT2.;1/RE
	PIP ['MAN']S3.;1=['BIN']SECT3.;1/RE
	PIP ['MAN']S4.;1=['BIN']SECT4.;1/RE
	PIP ['MAN']MINTRO.;1=['BIN']MINTRO.;1/RE
	PIP ['MAN']MPATH.;1=['BIN']MPATH.;1/RE
	SHX -C "ASAM <['MAN']S1 | SORT >['MAN']I1"
	SHX -C "ASAM <['MAN']S2 | SORT >['MAN']I2"
	SHX -C "ASAM <['MAN']S3 | SORT >['MAN']I3"
	SHX -C "ASAM <['MAN']S4 | SORT >['MAN']I4"
	PIP ['MAN']*.*;*/PR/WO:RE
	PIP ['MAN']*.*;*/TR
;
;	PREPARE FOR BUILDING THE MAIL SYSTEM
;
;	FIRST WE MUST SAVE OUR UIC AND SET UIC TO [1,1]
;	THIS IS NECESSARY FOR ADDR TO BE ABLE TO READ [0,0]RSX11.SYS FOR
;	THE ACCOUNT INFORMATION
;
	.SETS SUIC "'<UIC>'"
	SET /UIC=[1,1]
;
;	READ [0,0]RSX11.SYS AND SORT THE OUTPUT FILE ONTO ST1:['MSG']ADDRESS
;
;	THE FORMAT OF AN ENTRY IN ST1:['MSG']ADDRESS IS:
;
;	USERNAME	HOME DIRECTORY		UIC		INFO
;
	SHX -C "ADDR | SORT >ST1:['MSG']ADDRESS"
	PIP ST1:['MSG']*.*;*/PR/WO:RE
	PIP ST1:['MSG']*.*;*/TR
;
;	NOW REMOVE ALL INSTALLED TASKS
;
	.IFINS SHX REM SHX
	.IFINS LSX REM LSX
	.IFINS CHX REM CHX
	.IFINS LDX REM LDX
	.IFINS FCX REM FCX
	.IFT REMFLX REM FLX
	.IFT REMPIP REM PIP
	.IFT REMFOR REM 'FORTRN'
	.IFT REMLBR REM LBR
	.IFT REMMAC REM MAC
	.IFT REMTKB REM TKB
	ASN =ST0:
	ASN =ST1:
	ASN =SY:
;
;	HERE IS A LISTING OF THE SUGGESTED TOOLS SPECIFIC STARTUP FILE
;
;	THIS FILE SHOULD BE COPIED TO LB:[1,2] AND INVOKED FROM
;	LB:[1,2]STARTUP.CMD TO CAUSE THE TOOLS SYSTEM TO BE KNOWN
;	WHEN THE SYSTEM BOOTS
;
	PIP TI:='RDEV'['BIN']TOOLS.CMD
;
;
;	IF ANY OF THE TASK BUILDS FAILED WITH AN "illegal memory limits"
;	ERROR MESSAGE, CONSULT [307,30]RELEASE.DOC FOR THE APPROPRIATE
;	COURSE OF ACTION TO TAKE.
;
;
;
;	THE SUGGESTED PROCEDURE FROM HERE IS AS FOLLOWS
;
;	>@'RDEV'['BIN']TOOLS		! GET TOOLS RUNNING NOW
;	>SET /UIC=[1,2]
;	>PIP *.*/NV='RDEV'['BIN']TOOLS.CMD	! COPY STARTUP TO [1,2]
;	>EDIT STARTUP.CMD TO INVOKE TOOLS.CMD
;
;
;	IF YOU WISH TO SUPPORT BACKGROUND PROCESSING FROM THE SHELL,
;	IT WILL BE NECESSARY FOR YOU TO RUN A SEPARATE COMMAND FILE.
;	SIMPLY TYPE:
;
;	>@'RDEV'['BIN']BSPBLD
;
;	WHEN THIS COMMAND FILE COMPLETES
;
;
;	IF YOU WISH TO BUILD A MULTI-USER VERSION OF THE SHELL,
;	IT WILL BE NECESSARY FOR YOU TO EXECUTE THE FOLLOWING
;	COMMANDS AT THE COMPLETION OF TOOLGEN:
;
;	1. COPY SH.TCS FROM THE DISTRIBUTION DEVICE TO A WORKING UIC
;	2. @ST0:['BIN']MUSHBLD
;
;	THE MULTI-USER VERSION OF THE SHELL WILL BE BUILT ON THE
;	DEFAULT UIC WHEN THE COMMAND FILE IS INVOKED
;
;
;
;	TO BUILD ONE OF THE SOFTWARE TOOLS MAIL SYSTEMS, CONSULT THE
;	FILE [307,36]MSGREADME.1ST.
;
;
;
;
;	TOOLGEN COMPLETED ON '<DATE>' AT '<TIME>'
;
;	START 'BEGINT'
;	END   '<DATE>' '<TIME>'
;
	SET /UIC='SUIC'
