xref: /minix/external/bsd/byacc/dist/vmsbuild.com (revision ebfedea0)
1$! Id: vmsbuild.com,v 1.1 2000/11/21 00:38:46 tom Exp
2$! VMS build-script for BYACC.  Requires installed C compiler
3$!
4$! Screen Configurations
5$! ---------------------
6$! To build BYACC, type:
7$!        $ @vmsbuild [BYACC [<compiler> [bld_target]]]
8$!
9$! where:
10$!        <compiler> :== { decc | vaxc }
11$!
12$! The default compiler on VAX hosts is vaxc, else decc (Alpha hosts).
13$!
14$! -----------------------------------------------------------
15$ hlp = f$edit("''p1'", "UPCASE")
16$ if "''hlp'" .eqs. "HELP" .or. -
17        "''hlp'" .eqs. "-H" .or. -
18                "''hlp'" .eqs. "-?" .or. -
19                        "''hlp'" .eqs. "?" then gosub usage
20$ goto start
21$!
22$ vaxc_config:
23$    comp       = "__vaxc__=1"
24$    CFLAGS     = "/VAXC"
25$    DEFS       = ",HAVE_STRERROR"
26$    using_vaxc = 1
27$    return
28$!
29$ decc_config:
30$    comp   = "__decc__=1"
31$    CFLAGS = "/DECC/prefix=all"
32$    DEFS   = ",HAVE_ALARM,HAVE_STRERROR"
33$    return
34$!
35$ usage:
36$    write sys$output "usage: "
37$    write sys$output "      $ @vmsbuild [BYACC [{decc | vaxc} [<bldtarget>]]]"
38$    exit 2
39$!
40$ start:
41$! -----------------------------------------------------------
42$! pickup user's compiler choice, if any
43$! -----------------------------------------------------------
44$!
45$ comp = ""
46$ using_vaxc = 0
47$ if "''p2'" .nes. ""
48$ then
49$    comp = f$edit(p2, "UPCASE")
50$    if "''comp'" .eqs. "VAXC"
51$    then
52$        gosub vaxc_config
53$    else
54$        if "''comp'" .eqs. "DECC"
55$        then
56$            gosub decc_config
57$        else
58$            gosub usage
59$        endif
60$    endif
61$ endif
62$! -----------------------------------------------------------
63$!      Build the option-file
64$!
65$ open/write optf vms_link.opt
66$ write optf "closure.obj"
67$ write optf "error.obj"
68$ write optf "lalr.obj"
69$ write optf "lr0.obj"
70$ write optf "mkpar.obj"
71$ write optf "output.obj"
72$ write optf "reader.obj"
73$ write optf "skeleton.obj"
74$ write optf "symtab.obj"
75$ write optf "verbose.obj"
76$ write optf "warshall.obj"
77$! ----------------------------------
78$! Look for the compiler used and specify architecture.
79$!
80$ CC = "CC"
81$ if f$getsyi("HW_MODEL").ge.1024
82$ then
83$  arch = "__alpha__=1"
84$  if "''comp'" .eqs. "" then gosub decc_config
85$ else
86$  arch = "__vax__=1"
87$  if "''comp'" .nes. "" then goto screen_config
88$  if f$search("SYS$SYSTEM:VAXC.EXE").nes.""
89$  then
90$   gosub vaxc_config
91$  else
92$   if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").nes.""
93$   then
94$    gosub decc_config
95$   else
96$    DEFS = ",HAVE_STRERROR"
97$    if f$trnlnm("GNU_CC").eqs.""
98$    then
99$     write sys$output "C compiler required to rebuild BYACC"
100$     close optf
101$     exit
102$    else
103$     write optf "gnu_cc:[000000]gcclib.olb/lib"
104$     comp = "__gcc__=1"
105$     CC = "GCC"
106$    endif
107$   endif
108$  endif
109$ endif
110$!
111$ screen_config:
112$!
113$ if using_vaxc .eq. 1 then write optf "sys$library:vaxcrtl.exe/share"
114$ close optf
115$! -------------- vms_link.opt is created -------------
116$ if f$edit("''p1'", "UPCASE") .eqs. "VMS_LINK.OPT"
117$ then
118$!  mms called this script to build vms_link.opt.  all done
119$   exit
120$ endif
121$!
122$ if f$search("SYS$SYSTEM:MMS.EXE").eqs.""
123$ then
124$!  can also use /Debug /Listing, /Show=All
125$
126$   CFLAGS := 'CFLAGS/Diagnostics /Define=("''DEFS'") /Include=([])
127$
128$  	if "''p3'" .nes. "" then goto 'p3
129$!
130$!
131$ all :
132$!
133$	call make closure
134$	call make error
135$	call make lalr
136$	call make lr0
137$	call make main
138$	call make mkpar
139$	call make output
140$	call make reader
141$	call make skeleton
142$	call make symtab
143$	call make verbose
144$	call make warshall
145$!
146$	link /exec='target/map/cross main.obj, vms_link/opt
147$	goto build_last
148$!
149$ install :
150$	WRITE SYS$ERROR "** no rule for install"
151$	goto build_last
152$!
153$ clobber :
154$	if f$search("BYACC.com") .nes. "" then delete BYACC.com;*
155$	if f$search("*.exe") .nes. "" then delete *.exe;*
156$! fallthru
157$!
158$ clean :
159$	if f$search("*.obj") .nes. "" then delete *.obj;*
160$	if f$search("*.bak") .nes. "" then delete *.bak;*
161$	if f$search("*.lis") .nes. "" then delete *.lis;*
162$	if f$search("*.log") .nes. "" then delete *.log;*
163$	if f$search("*.map") .nes. "" then delete *.map;*
164$	if f$search("*.opt") .nes. "" then delete *.opt;*
165$! fallthru
166$!
167$ build_last :
168$	if f$search("*.dia") .nes. "" then delete *.dia;*
169$	if f$search("*.lis") .nes. "" then purge *.lis
170$	if f$search("*.obj") .nes. "" then purge *.obj
171$	if f$search("*.map") .nes. "" then purge *.map
172$	if f$search("*.opt") .nes. "" then purge *.opt
173$	if f$search("*.exe") .nes. "" then purge *.exe
174$	if f$search("*.log") .nes. "" then purge *.log
175$! fallthru
176$!
177$ vms_link_opt :
178$	exit 1
179$!
180$! Runs BYACC from the current directory (used for testing)
181$ byacc_com :
182$	if "''f$search("BYACC.com")'" .nes. "" then delete BYACC.com;*
183$	copy nl: BYACC.com
184$	open/append  test_script BYACC.com
185$	write test_script "$ temp = f$environment(""procedure"")"
186$	write test_script "$ temp = temp -"
187$	write test_script "		- f$parse(temp,,,""version"",""syntax_only"") -"
188$	write test_script "		- f$parse(temp,,,""type"",""syntax_only"")"
189$	write test_script "$ BYACC :== $ 'temp'.exe"
190$	write test_script "$ define/user_mode sys$input  sys$command"
191$	write test_script "$ define/user_mode sys$output sys$command"
192$	write test_script "$ BYACC 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8"
193$	close test_script
194$	write sys$output "** made BYACC.com"
195$	exit
196$!
197$  else
198$   mms/ignore=warning/macro=('comp','mmstar','arch') 'p3
199$  endif
200$ exit
201$ make: subroutine
202$	if f$search("''p1'.obj") .eqs. ""
203$	then
204$		write sys$output "compiling ''p1'"
205$		'CC 'CFLAGS 'p1.c
206$		if f$search("''p1'.dia") .nes. "" then delete 'p1.dia;*
207$	endif
208$exit
209$	return
210$ endsubroutine
211