1$! $Id: vmsbuild.com,v 1.19 2010/08/28 12:17:47 tom Exp $
2$! VMS build-script for VTTEST.  Requires installed C compiler
3$!
4$! Tested with:
5$!	VMS system version 5.4-2
6$!	VAX-C version 3.2
7$!
8$!	Build the option-file
9$!
10$ open/write optf vms_link.opt
11$ write optf "Identification=""VtTest 2.7"""
12$ write optf "charsets.obj"
13$ write optf "color.obj"
14$ write optf "draw.obj"
15$ write optf "esc.obj"
16$ write optf "keyboard.obj"
17$ write optf "mouse.obj"
18$ write optf "nonvt100.obj"
19$ write optf "printer.obj"
20$ write optf "reports.obj"
21$ write optf "reset.obj"
22$ write optf "setup.obj"
23$ write optf "sixel.obj"
24$ write optf "status.obj"
25$ write optf "tek4014.obj"
26$ write optf "utf8.obj"
27$ write optf "vms_io.obj"
28$ write optf "vt220.obj"
29$ write optf "vt320.obj"
30$ write optf "vt420.obj"
31$ write optf "vt52.obj"
32$ write optf "vt520.obj"
33$ write optf "xterm.obj"
34$!
35$! Look for the compiler used
36$!
37$ CC = "CC"
38$ arch = "UNKNOWN"
39$!
40$ if f$getsyi("ARCH_NAME") .eqs. "Alpha"
41$ then
42$  arch = "__alpha__=1"
43$  comp  = "__decc__=1"
44$  CFLAGS = "/prefix=all"
45$  DEFS = "HAVE_ALARM"
46$  if f$trnlnm("SYS").eqs."" then define sys sys$library:
47$ endif
48$!
49$ if f$getsyi("ARCH_NAME") .eqs. "IA64"
50$ then
51$  arch = "__ia64__=1"
52$  comp  = "__decc__=1"
53$  CFLAGS = "/prefix=all"
54$  DEFS = "HAVE_ALARM,USE_IEEE_FLOAT"
55$  if f$trnlnm("SYS").eqs."" then define sys sys$library:
56$ endif
57$!
58$ if f$getsyi("ARCH_NAME") .eqs. "VAX"
59$ then
60$  arch = "__vax__=1"
61$  if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs.""
62$   then
63$    if f$trnlnm("SYS").eqs."" then define sys sys$library:
64$    DEFS = "HAVE_SYS_ERRLIST"
65$    write optf "sys$library:vaxcrtl.exe/share"
66$    if f$search("SYS$SYSTEM:VAXC.EXE").eqs.""
67$     then
68$     if f$trnlnm("GNU_CC").eqs.""
69$      then
70$       write sys$output "C compiler required to rebuild vttest"
71$       close optf
72$       exit
73$     else
74$      write optf "gnu_cc:[000000]gcclib.olb/lib"
75$      comp = "__gcc__=1"
76$      CC = "GCC"
77$     endif
78$    else
79$    comp  = "__vaxc__=1"
80$    endif
81$   else
82$    if f$trnlnm("SYS").eqs."" then define sys decc$library_include:
83$    comp  = "__decc__=1"
84$  endif
85$ endif
86$
87$ if "''arch'" .eqs. "UNKNOWN"
88$ then
89$   write sys$output "Cannot determine architecture type"
90$   exit 1
91$ endif
92$
93$ close optf
94$
95$! used /G_FLOAT with vaxcrtlg/share in vms_link.opt
96$! can also use /Debug /Listing, /Show=All
97$
98$! -------------- vms_link.opt is created -------------
99$ if f$edit("''p1'", "UPCASE") .eqs. "VMS_LINK.OPT"
100$ then
101$!  mms called this script to build vms_link.opt.  all done
102$   exit
103$ endif
104$
105$ if f$search("SYS$SYSTEM:MMS.EXE").eqs.""
106$  then
107$
108$   CFLAGS := 'CFLAGS/Diagnostics /Define=("''DEFS'") /Include=([])
109$
110$	if "''p1'" .nes. "" then goto 'p1
111$
112$ all :
113$	call make charsets
114$	call make color
115$	call make draw
116$	call make esc
117$	call make keyboard
118$	call make main
119$	call make mouse
120$	call make nonvt100
121$	call make printer
122$	call make reports
123$	call make reset
124$	call make setup
125$	call make sixel
126$	call make status
127$	call make tek4014
128$	call make utf8
129$	call make vt220
130$	call make vt320
131$	call make vt420
132$	call make vt52
133$	call make vt520
134$	call make vms_io
135$	call make xterm
136$
137$	link /exec=VTTEST/map/cross main.obj, vms_link/opt
138$	goto build_last
139$
140$ install :
141$	WRITE SYS$ERROR "** no rule for install"
142$	goto build_last
143$
144$ clean :
145$	if f$search("*.obj") .nes. "" then delete *.obj;*
146$	if f$search("*.bak") .nes. "" then delete *.bak;*
147$	if f$search("*.lis") .nes. "" then delete *.lis;*
148$	if f$search("*.log") .nes. "" then delete *.log;*
149$	if f$search("*.map") .nes. "" then delete *.map;*
150$	if f$search("*.opt") .nes. "" then delete *.opt;*
151$	goto build_last
152$
153$ clobber :
154$	if f$search("vttest.com") .nes. "" then delete vttest.com;*
155$	if f$search("*.exe") .nes. "" then delete *.exe;*
156$	goto build_last
157$
158$ build_last :
159$	if f$search("*.dia") .nes. "" then delete *.dia;*
160$	if f$search("*.lis") .nes. "" then purge *.lis
161$	if f$search("*.obj") .nes. "" then purge *.obj
162$	if f$search("*.map") .nes. "" then purge *.map
163$	if f$search("*.opt") .nes. "" then purge *.opt
164$	if f$search("*.exe") .nes. "" then purge *.exe
165$	if f$search("*.log") .nes. "" then purge *.log
166$	exit
167$
168$ vms_link_opt :
169$	exit 1
170$!
171$! Runs VTTEST from the current directory (used for testing)
172$ vttest_com :
173$	if "''f$search("vttest.com")'" .nes. "" then delete vttest.com;*
174$	copy nl: vttest.com
175$	open/append  test_script vttest.com
176$	write test_script "$ temp = f$environment(""procedure"")"
177$	write test_script "$ temp = temp -"
178$	write test_script "		- f$parse(temp,,,""version"",""syntax_only"") -"
179$	write test_script "		- f$parse(temp,,,""type"",""syntax_only"")"
180$	write test_script "$ vttest :== $ 'temp'.exe"
181$	write test_script "$ define/user_mode sys$input  sys$command"
182$	write test_script "$ define/user_mode sys$output sys$command"
183$	write test_script "$ vttest 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8"
184$	close test_script
185$	write sys$output "** made vttest.com"
186$	exit
187$!
188$! We have MMS installed
189$  else
190$   mms/macro=('comp','arch') 'p1
191$  endif
192$ exit
193$
194$ make: subroutine
195$	if f$search("''p1'.obj") .eqs. ""
196$	then
197$		write sys$output "compiling ''p1'"
198$		'CC 'CFLAGS 'p1.c
199$		if f$search("''p1'.dia") .nes. "" then delete 'p1.dia;*
200$	endif
201$	exit
202$ endsubroutine
203