1 $ ! vms/vmsbuild.com -- compile and link NetHack 3.6.* [pr]
2 $ version_number = "3.5.0"
3 $ ! $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$
6 $ ! $ set default [.src] !or [-.-.src] if starting from [.sys.vms]
7 $ ! $ @[-.sys.vms]vmsbuild [compiler-option] [link-option] [cc-switches]
9 $ ! compiler-option : either "VAXC", "DECC" or "GNUC" or "" !default VAXC
10 $ ! link-option : either "SHARE[able]" or "LIB[rary]" !default SHARE
11 $ ! cc-switches : optional qualifiers for CC (such as "/noOpt/Debug")
13 $ ! If the symbol "CC" is defined, compiler-option is not used.
14 $ ! The link-option refers to VAXCRTL (C Run-Time Library) handling;
15 $ ! to specify it while letting compiler-option default, use "" as
16 $ ! the compiler-option.
17 $ ! To re-link without compiling, use "LINK" as special 'compiler-option';
18 $ ! to re-link with GNUC library, 'CC' must begin with "G" (or "g").
19 $ ! Default wizard definition moved to include/vmsconf.h.
21 $ decc_dflt = f$trnlnm("DECC$CC_DEFAULT")
22 $ j = (decc_dflt.nes."") .and. 1
23 $ vaxc_ = "CC" + f$element(j,"#","#/VAXC") + "/NOLIST/OPTIMIZE=NOINLINE"
24 $ decc_ = "CC" + f$element(j,"#","#/DECC") + "/PREFIX=ALL/NOLIST"
26 $ if f$type(gcc).eqs."STRING" then gnuc_ = gcc
27 $ gnulib = "gnu_cc:[000000]gcclib/Library" !(not used w/ vaxc)
28 $ ! common CC options (/obj=file doesn't work for GCC 1.36, use rename instead)
29 $ c_c_ = "/INCLUDE=[-.INCLUDE]"
30 $ veryold_vms = f$extract(1,1,f$getsyi("VERSION")).eqs."4" -
31 .and. f$extract(3,3,f$getsyi("VERSION")).lts."6"
32 $ if veryold_vms then c_c_ = c_c_ + "/DEFINE=(""VERYOLD_VMS"")"
33 $ axp = (f$getsyi("CPU").ge.128) !f$getsyi("ARCH_NAME").eqs."Alpha"
34 $ ! miscellaneous setup
35 $ ivqual = %x00038240 !DCL-W-IVQUAL (used to check for ancient vaxc)
36 $ abort := exit %x1000002A
37 $ cur_dir = f$environment("DEFAULT")
38 $ vmsbuild = f$environment("PROCEDURE")
39 $ ! validate first parameter
41 $ if p1.eqs."" .and. (axp .or. decc_dflt.eqs."/DECC") then p1 = "DECC"
42 $ o_VAXC = 0 !(c_opt substring positions)
47 $ c_opt = f$locate("|"+p1, "|VAXC|DECC|GNUC|LINK|SPECIAL|") !5
48 $ if (c_opt/5)*5 .eq. c_opt then goto p1_ok
49 $ copy sys$input: sys$error: !p1 usage
50 %first arg is compiler option; it must be one of
51 "VAXC" -- use VAX C to compile everything
52 or "DECC" -- use DEC C to compile everything
53 or "GNUC" -- use GNU C to compile everything
54 or "LINK" -- skip compilation, just relink nethack.exe
55 or "SPEC[IAL]" -- just compile and link lev_comp.exe
56 or "" -- default operation (VAXC unless 'CC' is defined)
58 Note: if a DCL symbol for CC is defined, "VAXC" and "GNUC" are no-ops.
59 If the symbol value begins with "G" (or "g"), then the GNU C
60 library will be included in all link operations. Do not rebuild
61 lev_comp with "SPECIAL" unless you have a CC symbol setup with
65 $ ! validate second parameter
67 $ l_opt = f$locate("|"+p2, "|SHAREABLE|LIBRARY__|NONE_____|") !10
68 $ if (l_opt/10)*10 .eq. l_opt then goto p2_ok
69 $ copy sys$input: sys$error: !p2 usage
70 %second arg is C run-time library handling; it must be one of
71 "SHAREABLE" -- link with SYS$SHARE:VAXCRTL.EXE/SHAREABLE
72 or "LIBRARY" -- link with SYS$LIBRARY:VAXCRTL.OLB/LIBRARY
73 or "NONE" -- explicitly indicate DECC$SHR
74 or "" -- default operation (use shareable image)
76 Note: for MicroVMS 4.x, "SHAREABLE" (which is the default) is required.
77 Specify "NONE" if using DEC C with a CC symbol overriding 1st arg.
80 $ ! start from a known location -- [.sys.vms], then move to [-.-.src]
81 $ set default 'f$parse(vmsbuild,,,"DEVICE")''f$parse(vmsbuild,,,"DIRECTORY")'
82 $ set default [-.-.src] !move to source directory
83 $ ! compiler setup; if a symbol for "CC" is already defined it will be used
84 $ if f$type(cc).eqs."STRING" then goto got_cc
85 $ cc = vaxc_ !assume "VAXC" requested or defaulted
86 $ if c_opt.eq.o_GNUC then goto chk_gcc !explicitly invoked w/ "GNUC" option
87 $ if c_opt.eq.o_DECC then cc = decc_
88 $ if c_opt.ne.o_VAXC then goto got_cc !"SPEC" or "LINK", skip compiler check
89 $ ! we want to prevent function inlining with vaxc v3.x (/opt=noinline)
90 $ ! but we can't use noInline with v2.x, so need to determine version
92 $ msgenv = f$environment("MESSAGE")
93 $ set message/noFacil/noSever/noIdent/noText
94 $ cc/noObject _NLA0:/Include=[] !strip 'noinline' if error
96 $ if sts then goto reset_msg !3.0 or later will check out OK
97 $ ! must be dealing with vaxc 2.x; ancient version (2.2 or earlier)
98 $ ! can't handle /include='dir', needs c$include instead
99 $ cc = cc - "=NOINLINE" - ",NOINLINE" - "NOINLINE,"
100 $ if sts.ne.IVQUAL then goto reset_msg
101 $ define/noLog c$include [-.INCLUDE]
102 $ c_c_ = "/DEFINE=(""ANCIENT_VAXC"")"
103 $ if veryold_vms then c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
105 $ set message 'msgenv'
111 $ ! old versions of gcc-vms don't have <varargs.h> or <stdarg.h> available
112 $ c_c_ = "/DEFINE=(""USE_OLDARGS"")"
113 $ if veryold_vms then c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
114 $ if veryold_vms then goto chk_gas !avoid varargs & stdarg
115 $ if f$search("gnu_cc_include:[000000]varargs.h").nes."" then -
116 c_c_ = "/DEFINE=(""USE_VARARGS"")"
117 $ if f$search("gnu_cc_include:[000000]stdarg.h").nes."" then -
118 c_c_ = "/DEFINE=(""USE_STDARG"")"
120 $ ! test whether this version of gas handles the 'const' construct correctly
121 $ gas_chk_tmp = "sys$scratch:gcc-gas-chk.tmp"
122 $ if f$search(gas_chk_tmp).nes."" then delete/noconfirm/nolog 'gas_chk_tmp';*
123 $ gas_ok = 0 !assume bad
124 $ on warning then goto skip_gas
125 $ define/user/nolog sys$error 'gas_chk_tmp'
126 $ mcr gnu_cc:[000000]gcc-as sys$input: -o _NLA0:
133 $ gas_ok = 1 !assume good
134 $ if f$search(gas_chk_tmp).eqs."" then goto skip_gas
135 $ ! if the error file is empty, gas can deal properly with const
136 $ gas_ok = f$file_attrib(gas_chk_tmp,"EOF") .eq. 0
137 $ delete/noconfirm/nolog 'gas_chk_tmp';*
139 $ on warning then continue
140 $ if .not.gas_ok then c_c_ = c_c_ - ")" + ",""const="")"
141 $ c_c_ = "/INCLUDE=[-.INCLUDE]" + c_c_
144 $ cc = cc + c_c_ !append common qualifiers
145 $ if p3.nes."" then cc = cc + p3 !append optional user preferences
146 $ g := 'f$extract(0,1,cc)'
147 $ if g.eqs."$" then g := 'f$extract(1,1,cc)' !"foreign" gcc
148 $ if f$edit(f$extract(1,1,cc),"UPCASE").eqs."E" then g := X !GEMC
149 $ if g.nes."G" .and. c_opt.ne.o_GNUC then gnulib = ""
150 $ ! linker setup; if a symbol for "LINK" is defined, we'll use it
151 $ if f$type(link).nes."STRING" then link = "LINK/NOMAP"
152 $ if p4.nes."" then link = link + p4 !append optional user preferences
153 $ if f$trnlnm("F").nes."" then close/noLog f
154 $ create crtl.opt !empty
155 $ open/Append f crtl.opt
156 $ write f "! crtl.opt"
157 $ if c_opt.eq.o_DECC .or. l_opt.eq.20
158 $ then $! l_opt=="none", leave crtl.opt empty (shs$share:decc$shr.exe/Share)
160 $ ! gnulib order: vaxcrtl.exe+gcclib.olb vs gcclib.olb+vaxcrtl.olb
161 $ if l_opt.eq.0 then write f "sys$share:vaxcrtl.exe/Shareable"
162 $ if gnulib.nes."" then write f gnulib
163 $ if l_opt.ne.0 then write f "sys$library:vaxcrtl.olb/Library"
166 $ if f$search("crtl.opt;-2").nes."" then purge/Keep=2/noLog crtl.opt
167 $ ! version ID info for linker to record in .EXE files
169 $ open/Append f ident.opt
170 $ write f "! ident.opt"
171 $ write f "identification=""",version_number,""" !version"
173 $ if f$search("ident.opt;-1").nes."" then purge/noLog ident.opt
175 $ nethacklib = "[-.src]nethack.olb"
178 nethack.olb/Library/Include=(vmsmain)
179 sys$library:starlet.olb/Include=(lib$initialize)
180 psect_attr=lib$initialize, Con,Usr,noPic,Rel,Gbl,noShr,noExe,Rd,noWrt,Long
182 $ if f$search("nethack.opt;-2").nes."" then purge/Keep=2/noLog nethack.opt
183 $ milestone = "write sys$output f$fao("" !5%T "",0),"
184 $ if c_opt.eq.o_LINK then goto link !"LINK" requested, skip compilation
185 $ rename := rename/New_Vers
186 $ touch := set file/Truncate
187 $ makedefs := $sys$disk:[-.util]makedefs
189 $ goto begin !skip subroutines
191 $compile_file: !input via 'c_file'
192 $ no_lib = ( f$extract(0,1,c_file) .eqs. "#" )
193 $ if no_lib then c_file = f$extract(1,255,c_file)
194 $ c_name = f$edit(f$parse(c_file,,,"NAME"),"LOWERCASE")
195 $ f_opts = "" !options for this file
196 $ if f$type('c_name'_options).nes."" then f_opts = 'c_name'_options
197 $ milestone " (",c_name,")"
198 $ if f$search("''c_name'.obj").nes."" then delete 'c_name'.obj;*
199 $ cc 'f_opts' 'c_file'
200 $ if .not.no_lib then nh_obj_list == nh_obj_list + ",''c_name'.obj;0"
203 $compile_list: !input via 'c_list'
208 $ c_file = f$element(j,",",c_list) !get next file
209 $ if c_file.eqs."," then goto c_done
210 $ c_file = c_file + ".c"
214 $ nh_obj_list == f$extract(1,999,nh_obj_list)
215 $ if nh_obj_list.nes."" then libr/Obj 'nethacklib' 'nh_obj_list'/Replace
216 $ if nh_obj_list.nes."" then delete 'nh_obj_list'
217 $ delete/symbol/global nh_obj_list
222 $! miscellaneous special source file setup
224 $ if f$search("pmatchregex.c").eqs."" then copy [-.sys.share]pmatchregex.c []*.*
225 $ if f$search("random.c").eqs."" then copy [-.sys.share]random.c []*.*
226 $ if f$search("tclib.c") .eqs."" then copy [-.sys.share]tclib.c []*.*
227 $ if f$search("[-.util]lev_yacc.c").eqs."" then @[-.sys.vms]spec_lev.com
229 $! create object library
231 $ if c_opt.ne.o_SPCL .or. f$search(nethacklib).eqs."" then -
232 libr/Obj 'nethacklib'/Create=(Block=3000,Hist=0)
233 $ if f$search("''nethacklib';-1").nes."" then purge 'nethacklib'
235 $! compile and link makedefs, then nethack, lev_comp+dgn_comp, dlb+recover.
237 $ milestone "<compiling...>"
238 $ c_list = "[-.sys.vms]vmsmisc,[-.sys.vms]vmsfiles,[]alloc,dlb,monst,objects"
239 $ if c_opt.eq.o_SPCL then c_list = c_list + ",decl,drawing"
241 $ if c_opt.eq.o_SPCL then goto special !"SPECIAL" requested, skip main build
242 $ set default [-.util]
243 $ c_list = "#makedefs"
245 $ link makedefs.obj,'nethacklib'/Lib,[-.src]ident.opt/Opt,[-.src]crtl/Opt
246 $ milestone "makedefs"
247 $! create some build-time files
249 $ makedefs -o !onames.h
250 $ makedefs -v !date.h
252 $ makedefs -m !../src/monstr.c
253 $ makedefs -z !../src/vis_tab.c, ../include/vis_tab.h
255 $ set default [-.src]
256 $! compile most of the source files:
257 $ c_list = "decl,version,[-.sys.vms]vmsmain,[-.sys.vms]vmsunix" -
258 + ",[-.sys.vms]vmstty,[-.sys.vms]vmsmail" -
259 + ",[]random,[]tclib,[]pmatchregex" !copied from [-.sys.share]
261 $ c_list = "[-.win.tty]getline,[-.win.tty]termcap" -
262 + ",[-.win.tty]topl,[-.win.tty]wintty"
264 $ c_list = "allmain,apply,artifact,attrib,ball,bones,botl,cmd,dbridge,detect" -
265 + ",dig,display,do,do_name,do_wear,dog,dogmove,dokick,dothrow,drawing" -
266 + ",dungeon,eat,end,engrave,exper,explode,extralev,files,fountain"
268 $ c_list = "hack,hacklib,invent,light,lock,mail,makemon,mapglyph,mcastu" -
269 + ",mhitm,mhitu,minion,mklev,mkmap,mkmaze,mkobj,mkroom,mon,mondata" -
270 + ",monmove,monstr,mplayer,mthrowu,muse,music,o_init,objnam,options" -
273 $ c_list = "pline,polyself,potion,pray,priest,quest,questpgr,read" -
274 + ",rect,region,restore,rip,rnd,role,rumors,save,shk,shknam,sit" -
275 + ",sounds,sp_lev,spell,steal,steed,sys,teleport,timeout,topten" -
276 + ",track,trap,u_init"
278 $ c_list = "uhitm,vault,vision,vis_tab,weapon,were,wield,windows" -
279 + ",wizard,worm,worn,write,zap"
283 $ milestone "<linking...>"
284 $ link/Exe=nethack.exe nethack.opt/Options,ident.opt/Options,crtl.opt/Options
285 $ milestone "NetHack"
286 $ if c_opt.eq.o_LINK then goto done !"LINK" only
289 $! build special level and dungeon compilers
291 $ set default [-.util]
292 $ c_list = "#panic,#lev_main,#lev_yacc,#dgn_main,#dgn_yacc"
293 $ if c_opt.eq.o_SPCL then c_list = "[-.sys.vms]vmsfiles," + c_list
295 $ c_list = "#lev_lex,#dgn_lex"
296 $ copy [-.sys.vms]lev_lex.h stdio.*/Prot=(s:rwd,o:rwd)
298 $ rename stdio.h lev_lex.*
299 $ link/exe=lev_comp.exe lev_main.obj,lev_yacc.obj,lev_lex.obj,-
300 panic.obj,'nethacklib'/Lib,[-.src]ident.opt/Opt,[-.src]crtl.opt/Opt
301 $ milestone "lev_comp"
302 $ link/exe=dgn_comp.exe dgn_main.obj,dgn_yacc.obj,dgn_lex.obj,-
303 panic.obj,'nethacklib'/Lib,[-.src]ident.opt/Opt,[-.src]crtl.opt/Opt
304 $ milestone "dgn_comp"
306 $ c_list = "#dlb_main,#recover"
308 $ link/exe=dlb.exe dlb_main.obj,-
309 panic.obj,'nethacklib'/Lib,[-.src]ident.opt/Opt,[-.src]crtl.opt/Opt
311 $ link/exe=recover.exe recover.obj,-
312 'nethacklib'/Lib,[-.src]ident.opt/Opt,[-.src]crtl.opt/Opt
313 $ milestone "recover"
316 $ set default 'cur_dir'