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