/*
 *				b u i l d 1 . c
 *
 * Op sys strings and things
 */

#include	<stdio.h>
#include	"build.h"

/*
 * Default model strings
 *
 * Note the following:
 *	SRC and COPYINCLUDE must be such that, if neither is changed,
 *	the copy may be omitted.
 */

char		*comm_model =
/*
 *	comm_model is common to all operating systems.
 *
 * Note: several of the following are rewritten on various operating systems.
 * Others are specified here so they are defined during processing.
 */
"\
$(SRC)		= {}\n\
$(BIN)		= {}\n\
$(FIRST)	= {}\n\
$(LAST)		= {}\n\
$(COPYCOMMENT)	= {}\n\
$(DELCOMMENT)	= {}\n\
$(ALLOWEXECUTE)	= {}\n\
$(ALLOWREAD)	= {}\n\
$(POSTFIX)	= {}\n\
$(TERMINATE)	= {}\n\
$(INCLUDE)	= {}\n\
$(FILES)	= {}\n\
$(MPINSTALL)	= {}\n\
$(MP)		= {}\n\
$(DIFFINSTALL)	= {}\n\
$(UTLIB)	= {}\n\
$(EOF)		= {^Z}\n\
$(EXIT)		= {^Z}\n\
$(SOURCE)	= {$(SRC)$?}\n\
$(VXLINK)	= { link/nomap/exe=$(BIN)$(PROGRAM) $(VXOBJS)\n}\n\
$(RXLINK)	= { tkb $(LINK1)$(BIN)$(PROGRAM)=$(RXOBJS)$(RXARGS)\n}\n\
$(RTLINK)	= { LINK\n$(BIN)$(PROGRAM)=$(LINK1)$(RTOBJS)$(LINK2)\n}\n\
$(RXODL)	= { $(PROGRAM).TMP/MP}\n\
$(RXARGS)	= {}\n\
$(STACK)	= 2000\n\
$(TKBOPTIONS)	= {}\n\
$(OBJS)		= {}\n\
$(DTOA)		= {}\n\
$(LIBS)		= {}\n\
$(OVR)		= {}\n\
$(ODL)		= {}\n\
$(LINK1)	= {}\n\
$(LINK2)	= {}\n\
$(LBR.1)	= $(LBR)\n\
$(VXLIBR)	= { library/create/object $? $(VXOBJS)\n}\n\
$(RXLIBR)	= { $(LBR) $?/CR=$(RXOBJS)\n}\n\
$(RTLIBR)	= { LIBR\n$?=$(LINK1)$(RTOBJS)$(LINK2)\n}\n\
";

char		*op_base[] = {
/*
 *	op_base contains operating system specific strings, such
 *	as those needed to copy files.
 */

/*
 * NONE		Undefined
 */
"",

/*
 * VAX
 */
"\
$(INITIALIZE)	= { $$! Vax $(MODE) command file built on $(DATE)\n\
$$ was_verify = 'f$$verify(1)'\n}\n\
$(VXLIB)	= { SYS$$LIBRARY:CRTLIB/LIB}\n\
$(RXLIB)	= { C:C/LB}\n\
$(BIN)		= BIN:\n\
$(MCR)		= { $ mcr }\n\
$(PREFIX)	= { $$!\n$$! ** Compile $(PROGRAM)\n$$!\n}\n\
$(COPYINCLUDE)	= { $$ $(COPYCOMMENT)copy $(SOURCE) $?\n}\n\
$(COPYODL)	= { $$ create $(PROGRAM).TMP\n$(ODL)\n$$EOD\n}\n\
$(DELETEODL)	= { $$ delete $(PROGRAM).TMP;\n}\n\
$(COMMENT)	= {!! }\n\
$(LBR)		= { mcr lbr}\n\
$(EOF)		= { $$EOD\n}\
$(CLEANUP)	= { $$ $(DELCOMMENT)delete $*.OBJ;\n}\n\
$(EXECUTABLE)	= { $$ set protection=(world=e) $(BIN)$(PROGRAM).EXE;\n}\n\
$(READABLE)	= { $$ set protection=(world=r) $?\n}\n\
$(POSTFIX)	= { $$ $(PROGRAM) :== $$$(BIN)$(PROGRAM)\n}\n\
$(TERMINATE)	= { $$ if .not. 'was_verify' then set noverify\n}\n\
",
/*
 * RSX
 */
"\
$(MCR)		= {}\n\
$(PREFIX)	= { ;\n; Compile $(PROGRAM)\n;\n}\n\
$(COPYINCLUDE)	= { $(COPYCOMMENT)pip $?=$(SOURCE)\n}\n\
$(COPYODL)	= {\
.OPEN $(PROGRAM).TMP\n\
.ENABLE DATA\n\
$(ODL)\n\
.DISABLE DATA\n\
.CLOSE\n\}\n\
$(DELETEODL)	= { pip $(PROGRAM).TMP;/de\n}\n\
$(EXECUTABLE)	= { pip $(BIN)$(PROGRAM).TSK;/pr/wo:r\n}\n\
$(READABLE)	= { pip $?/pr/wo:r\n}\n\
$(COMMENT)	= {;; }\n\
$(LBR)		= lbr\n\
$(CLEANUP)	= { $(DELCOMMENT)pip $*.OBJ;/de\n}\n\
",
/*
 * RSTS
 */
"\
$(INITIALIZE)	= {\n\
SWITCH BASIC\n\
! RSTS $(MODE) command file built on $(DATE)\n\
}\n\
$(MCR)		= {}\n\
$(PREFIX)	= { !\n! ** Compile $(PROGRAM)\n!\n}\n\
$(COPYINCLUDE)	= { $(COPYCOMMENT)pip $?=$(SOURCE)\n}\n\
$(COPYODL)	= { pip $(PROGRAM).TMP=_kb:\n$(ODL)\n$(EOF)\n}\n\
$(DELETEODL)	= { pip $(PROGRAM).TMP/de\n}\n\
$(READABLE)	= { pip $?<40>/re\n}\n\
$(COMMENT)	= {!! }\n\
$(LBR)		= lbr\n\
$(CLEANUP)	= { $(DELCOMMENT)pip $*.OBJ/de\n}\n\
",
/*
 * RT11
 */
"\
$(PREFIX)	= { !\n! ** Compile $(PROGRAM)\n!\n}\n\
$(COPYINCLUDE)	= {\
SET ERROR NONE\n\
$(COPYCOMMENT)COPY $(SOURCE) $?\n\
SET ERROR ERROR\n}\n\
$(COMMENT)	= {!! }\n\
$(CLEANUP)	= { $(DELCOMMENT)DELETE/NOQ $*.OBJ\n}\n\
$(EXECUTABLE)	= {}\n\
$(READABLE)	= {}\n\
$(EXIT)		= {^C}\n\
",
};

char		*op_model[] = {
/*
 *	op_model contains strings needed to compile and link C
 *	programs.
 */

/*
 * NONE		Undefined
 */
"",

/*
 * VNATIVE	Vax native
 */
"\
$(MODE)		= native\n\
$(CC)		= { $$ cc/nolist $(SOURCE)\n}\n\
$(CCTEST)	= { $$! Sorry, no test on vax native\n}\n\
$(CCMP)		= $(CC)\n\
$(CCMPTEST)	= $(CCTEST)\n\
$(LINK)		= { $$ $(VXLINK)}\n\
$(LIBRARY)	= { $$ $(VXLIBR)}\n\
$(UTLIB)	= { C:VAXLIB/LIB}\n\
$(DTOA.OBJ)	= {}\n\
",
/*
 * VBOTH	Vax rsx and native together
 */
"\
$(VN)		= { if .not. native then }\n\
$(RX)		= { if native then }\n\
$(RSXP)		= {}\n\
$(INITIALIZE)	= { $$! Vax command file built on $(DATE)\n\
$$ if \"''native'\" .eqs. \"\" then inquire native\
 \"Use native C <yes/no> (No)\"\n\
$$ was_verify = 'f$$verify(1)'\n}\n\
$(CC)		= {\
$$ $(VN) cc/nolist $(SOURCE)\n\
$$ $(RX) xcc $(SOURCE) $(RSXP)\n\
$$ $(RX) xas $*.S -d\n}\n\
$(CCTEST)	= {\
$$ $(RX) xcc $(SOURCE) $(RSXP)\n\
$$ $(RX) rename $*.S $*.OLS\n\
$$ $(RX) newcc $(SOURCE) $(RSXP)\n\
$$ $(RX) diff $*.OLS $*.S\n\
$$ $(RX) delete $*.OLS;,$*.S;\n}\n\
$(CCMP)		= {\
$$ $(VN) cc/nolist $(SOURCE)\n\
$$ $(RX) mp $(SOURCE) $*.MP\n\
$$ $(RX) xcc $*.MP $(RSXP)\n\
$$ $(RX) xas $*.S -d\n\
$$ $(RX) delete $*.MP;\n}\n\
$(CCMPTEST)	= {\
$$ $(RX) mp $(SOURCE) $*.mp\n\
$$ $(RX) xcc $$.MP $(RSXP)\n\
$$ $(RX) rename $*.S $*.OLS\n\
$$ $(RX) newcc $*.MP $(RSXP)\n\
$$ $(RX) diff $*.OLS $*.S\n\
$$ $(RX) delete $*.MP;,$*.OLS;,$*.S;\n}\n\
$(LINK)		= {\
$$ $(VN) -\n $(VXLINK)\
$$ $(RX) mcr $(RXLINK)}\
$(LIBRARY)	= {\
$$ $(VN) -\n $(VXLIBR)\
$$ $(RX) $(RXLIBR)}\
$(LBR.1)	= { $$ $(RX) mcr lbr}\n\
$(DTOA.OBJ)	= { C:DTOA}\n\
",
/*
 * VRSX		Vax Rsx
 */
"\
$(MODE)		= compatibility\n\
$(RSXP)		= {}\n\
$(DTOA.OBJ)	= { C:DTOA}\n\
$(CC)		= {\
$$ xcc $(SOURCE) $(RSXP)\n\
$$ xas $*.S -d\n}\n\
$(CCTEST)	= {\
$$ xcc $(SOURCE) $(RSXP)\n\
$$ rename $*.S $*.OLS\n\
$$ newcc $(SOURCE) $(RSXP)\n\
$$ diff $*.OLS $*.S\n\
$$ delete $*.OLS;,$*.S;\n}\n\
$(CCMP)		= {\
$$ mpx $(SOURCE) $*.MP\n\
$$ xcc $*.MP $(RSXP)\n\
$$ xas $*.S -d\n\
$$ delete $*.MP;\n}\n\
$(CCMPTEST)	= {\
$$ mpx $(SOURCE) $*.MP\n\
$$ xcc $*.MP $(RSXP)\n\
$$ rename $*.S $*.OLS\n\
$$ newcc $*.MP $(RSXP)\n\
$$ diff $*.OLS $*.S\n\
$$ delete $*.MP;,$*.OLS;,$*.S;\n}\n\
$(LINK)		= { $$ mcr $(RXLINK)}\
$(LIBRARY)	= { $$ $(RXLIBR)}\n\
$(LBR.1)	= { $$ mcr lbr}\n\
",
/*
 * RSXNATIVE
 */
"\
$(INITIALIZE)	= { ; RSX native command file built on $(DATE)\n\
.IFNINS XCC INS $$CC\n\
.IFNINS XAS INS $$AS\n}\n\
$(RXLIB)	= { LB:[1,1]C/LB}\n\
$(DTOA.OBJ)	= { C:DTOA}\n\
$(RSXP)		= {}\n\
$(MPINSTALL)	= {.IFNINS MPX INS $$MP\n}\n\
$(CC)		= {\n\
xcc $(SOURCE) -a $(RSXP)\n\
.IF <EXSTAT> NE 1 .EXIT\n\
}\n\
$(CCTEST)	= {\n\
xcc $(SOURCE) $(RSXP)\n\
pip $*.OLS=$*.S/re\n\
newcc $(SOURCE) $(RSXP)\n\
diff $*.OLS $*.S\n\
pip $*.OLS;,$*.S;/de\n}\n\
$(CCMP)		= {\
mpx $(SOURCE) $*.MP\n\
.IF <EXSTAT> NE 1 .EXIT\n\
xcc $*.MP -a $(RSXP)\n\
.IF <EXSTAT> NE 1 .EXIT\n\
pip $*.MP;/de\n}\n\
$(CCMPTEST)	= {\
mpx $(SOURCE) $*.MP\n\
xcc $*.MP $(RSXP)\n\
pip $*.OLS=$*.S/re\n\
newcc $*.MP $(RSXP)\n\
diff $*.OLS $*.S\n\
pip $*.MP;,$*.OLS;,$*.S;/de\n}\n\
$(LINK)		= {\
.OPEN $(PROGRAM).TKB\n\
.ENABLE DATA\n\
$(BIN)$(PROGRAM)/CP=$(RXOBJS)$(RXARGS)\n\
.DISABLE DATA\n\
.CLOSE\n\
tkb @$(PROGRAM).TKB\n\
.IF <EXSTAT> NE 1 .EXIT\n\
pip $(PROGRAM).TKB;/de\n}\n\
$(LIBRARY)	= $(RXLIBR)\n\
",
/*
 * RSTSRSX	RSTS RSX mode
 */
"\
$(MODE)		= RSX\n\
$(RXLIB)	= { C:C/LB}\n\
$(DTOA.OBJ)	= { C:RXDTOA}\n\
$(RSXP)		= {}\n\
$(CC)		= {\
xcc $(SOURCE) $(RSXP)\n\
xas $*.S -d\n}\n\
$(CCTEST)	= {\
xcc $(SOURCE) $(RSXP)\n\
pip $*.OLS=$*.S/re\n\
newxcc $(SOURCE) $(RSXP)\n\
diff $*.OLS $*.S\n\
pip $*.OLS,$*.S/de\n}\n\
$(CCMP)		= {\
mp $(SOURCE) $*.MP\n\
xcc $*.MP $(RSXP)\n\
xas $*.S -d\n\
pip $*.MP/de\n}\n\
$(CCMPTEST)	= {\n\
mp $(SOURCE) $*.MP\n\
xcc $*.MP $(RSXP)\n\
pip $*.OLS=$*.S/re\n\
newxcc $*.MP $(RSXP)\n\
diff $*.OLS $*.S\n\
pip $*.MP,$*.OLS,$*.S/de\n}\n\
$(LINK)		= $(RXLINK)\n^Z\n\
$(LIBRARY)	= $(RXLIBR)\n^Z\n\
$(EXECUTABLE)	= { pip $(BIN)$(PROGRAM).TSK<104>/re\n}\n\
",
/*
 * RSTSRT	RSTS RT11 mode
 */
"\
$(MODE)		= RT11\n\
$(SUPORT)	= { c:suport}\n\
$(RTLIB)	= { c:clib}\n\
$(DTOA.OBJ)	= { c:rtdtoa}\n\
$(RT11P)	= {}\n\
$(CC)		= {\
cc $(SOURCE)$(RT11P)\n\
as $*.S/d\n}\n\
$(CCTEST)	= {\
cc $(SOURCE)$(RT11P)\n\
pip $*.OLS=$*.S/re\n\
newcc $(SOURCE)$(RT11P)\n\
diff $*.OLS $*.S\n\
pip $*.OLS,$*.S/de\n}\n\
$(CCMP)		= {\
mp $(SOURCE) $*.MP\n\
cc $*.MP$(RT11P)\n\
as $*.S/d\n\
pip $*.MP/de\n}\n\
$(CCMPTEST)	= {\
mp $(SOURCE) $*.MP\n\
cc $*.MP$(RT11P)\n\
pip $*.OLS=$*.S/re\n\
newcc $*.MP$(RT11P)\n\
diff $*.OLS $*.S\n\
pip $*.MP,$*.OLS,$*.S/de\n}\n\
$(LINK)		= { RUN $$$(RTLINK)}\n\
$(LIBRARY)	= { RUN $$$(RTLIBR)}\n\
$(EXECUTABLE)	= { pip $(BIN)$(PROGRAM).SAV<104>/re\n}\n\
",
/*
 * RT11NATIVE
 */
"\
$(INITIALIZE)	= { ! RT11 native command file built on $(DATE)\n}\n\
$(SUPORT)	= { c:suport}\n\
$(RTLIB)	= { c:clib}\n\
$(DTOA.OBJ)	= { c:dtoa}\n\
$(RT11P)	= {}\n\
$(CC)		= {\
RUN C:CC\n$(SOURCE)$(RT11P)\n\
RUN C:AS\n$*.S/d\n}\n\
$(CCTEST)	= {\
RUN C:CC\n$(SOURCE)$(RT11P)\n\
RENAME/NOQ $*.S $*.OLS\n\
RUN C:NEWCC\n$(SOURCE)$(RT11P)\n\
RUN C:DIFF\n$*.OLS $*.S\n\
DELETE/NOQ $*.OLS,$*.S\n}\n\
$(CCMP)		= {\
RUN C:MP\n$(SOURCE) $*.MP\n\
RUN C:CC\n$*.MP$(RT11P)\n\
RUN C:AS\n$*.S/d\n\
DELETE/NOQ $*.MP\n}\n\
$(CCMPTEST)	= {\
RUN C:MP\n$(SOURCE) $*.MP\n\
RUN C:CC\n$*.MP$(RT11P)\n\
RENAME/NOQ $*.S $*.OLS\n\
RUN C:NEWCC\n$*.MP$(RT11P)\n\
RUN C:DIFF\n$*.OLS $*.S\n\
DELETE/NOQ $*.MP,$*.OLS,$*.S\n}\n\
$(LINK)		= { R $(RTLINK)}\n\
$(LIBRARY)	= { R $(RTLIBR)}\n\
",
};
