$ ! Procedure:	BUILD_WOLF3D.COM
$ __vfy = "VFY_''f$parse(f$environment("procedure"),,,"name")'"
$ if (f$type('__vfy') .eqs. "") then __vfy = 0
$ __vfy_saved = f$verify(&__vfy)
$
$err: subroutine
$ set noon
$ severity = f$edit(P1,"COLLAPSE,UPCASE")
$ identification = f$edit(P2,"COLLAPSE,UPCASE")
$ text = f$edit(P3,"TRIM")
$ continuation = (f$edit(P4,"COLLAPSE,UPCASE") .nes. "")
$ say = "write sys$output"
$ percent = "%"
$ if (continuation) then percent = "-"
$ if ((severity .eqs. "") .or. (identification .eqs. "") .or. (text .eqs. ""))
$ then say "%''facility'-F-SPOTTHEERR, <''severity'><''identification'><''text'>"
$ else say "''percent'''facility'-''severity'-''identification', ''text'"
$ endif
$ exitt 1
$ endsubroutine
$
$ procedure = f$element(0,";",f$environment("PROCEDURE"))
$ procedure_name = f$parse(procedure,,,"NAME")
$ facility = procedure_name
$ location = f$parse(procedure,,,"DEVICE","NO_CONCEAL") -
		+ f$parse(procedure,,,"DIRECTORY","NO_CONCEAL") - "]["
$
$ set noon
$ set symbol/scope=(nolocal)
$ on warning then goto bail_out
$ on control_y then goto bail_out
$ vax = (f$getsyi("HW_MODEL") .lt. 1024)
$ axp = (f$getsyi("HW_MODEL") .ge. 1024)
$ say = "write sys$output"
$ ask = "read sys$command/prompt="
$ err = "call___ err"
$ saysym = "write/symbol sys$output"
$
$ arch = "axp"
$ if (vax) then arch = "vax"
$
$ !++
$ ! Returns 1 if c is more recent. Returns 3 if object is more recent.
$ !--
$compare_objdate: subroutine
$ c_filespec = f$edit(p1, "UPCASE,COLLAPSE,TRIM")
$ o_filetype = f$edit(p2, "UPCASE,COLLAPSE,TRIM")
$
$ c_filename = f$parse(c_filespec,,,"NAME",)
$ o_filespec = c_filename + o_filetype
$
$ return_status = 1
$
$ if (f$search(o_filespec) .nes. "")
$ then
$    c_revdate = f$file_attributes(c_filespec, "RDT")
$    o_revdate = f$file_attributes(o_filespec, "RDT")
$
$    c_revdate = f$cvtime(c_revdate, "COMPARISON", "DATETIME")
$    o_revdate = f$cvtime(o_revdate, "COMPARISON", "DATETIME")
$
$    if (o_revdate .gts. c_revdate) then return_status = 3
$ endif
$
$ exit return_status
$ endsubroutine
$
$ program_list = "VI_MAIN"
$ dont_compile = "VI_NULL,VI_SDL,SD_OSS,SD_NULL,VI_SVGA"
$ cc_options = "/NODEBUG/OBJECT=*.''arch'_OBJ/NOWARNING" -
		+ "/INCLUDE=([],decw$include)" -
		+ "/DEFINE=(""__inline__=inline"",""HAVE_DIRENT_H=1"")"
$
$ dirspec = f$environment("DEFAULT")
$
$start:
$ say ""
$ say " Building WOLF3D V1.0 for OpenVMS"
$ say ""
$
$ say " Compiling..."
$ say ""
$
$ if (f$search("wolf3d_objects.''arch'_olb") .nes. "") then -
	delete/nolog wolf3d_objects.'arch'_olb;*
$
$ library/create/object wolf3d_objects.'arch'_olb
$
$compile_loop:
$ c_filespec = f$search("*.c")
$ if (c_filespec .eqs. "") then goto compile_loop_end
$ c_filename = f$parse(c_filespec,,,"NAME",)
$ c_objspec = c_filename + ".'arch'_OBJ"
$ count = 0
$skip_loop:
$ skip_name = f$element(count, ",", dont_compile)
$ if (skip_name .eqs. c_filename) then goto compile_loop
$ if (skip_name .eqs. "" .or. skip_name .eqs. ",") then goto skip_loop_end
$ count = count + 1
$ goto skip_loop
$skip_loop_end:
$
$ call compare_objdate "''c_filespec'" ".''arch'_obj"
$ if ($status .eq. 3) then goto skip_compile
$ err I COMP "Compiling ''c_filename'.C"
$ cc 'cc_options' 'c_filespec'
$skip_compile:
$ count = 0
$library_loop:
$ program_name = f$element(count, ",", program_list)
$ if (program_name .eqs. c_filename) then goto compile_loop
$ if (program_name .eqs. "" .or. program_name .eqs. ",") then -
	goto library_loop_end
$ count = count + 1
$ goto library_loop
$library_loop_end:
$ err I LIB "Inserting ''c_filename' into object library"
$ library/replace wolf3d_objects.'arch'_olb 'c_objspec'
$ goto compile_loop
$compile_loop_end:
$
$ if (vax)
$ then
$    err I MACRO "Assembing FIXEDBYFRAC"
$    macro fixedbyfrac.mar/object=*.'arch'_obj
$    err I LIB "Inserting FIXEDBYFRAC into object library"
$    library/replace wolf3d_objects.'arch'_olb fixedbyfrac.'arch'_obj
$ endif
$
$ say ""
$ say " Linking..."
$ say ""
$
$ count = 0
$program_loop:
$ program_name = f$element(count, ",", program_list)
$ if (program_name .eqs. "" .or. program_name .eqs. ",") then -
	goto program_loop_end
$ err I LINK "Linking ''program_name'"
$     link 'program_name'.'arch'_obj/exe='program_name'.'arch'_exe, -
		wolf3d_objects.'arch'_olb/library,wolf3d/options
$ count = count + 1
$ goto program_loop
$program_loop_end:
$
$ if (f$search("vi_main.''arch'_exe") .nes. "") then -
	rename/nolog vi_main.'arch'_exe [.-]wolf3d.'arch'_exe
$
$ say ""
$ say ""
$ say "    WOLF3D Installation Completed Successfully"
$ say ""
$ say ""
$ say "        eg. $ wolf3d == ""$sys$disk:[]wolf3d.''arch'_exe"""
$ say ""
$ say ""
$
$bail_out:
$ exitt 1.or.(0*f$verify(__vfy_saved))
$ !+==========================================================================
$ !
$ ! Procedure:	BUILD_WOLF3D.COM
$ !
$ ! Purpose:	WOLF3D build procedure.
$ !
$ ! Parameters: None.
$ !
$ ! History:
$ !		20-TES-2003, TES; Version V1-001
$ !	001 -	Original version.
$ !-==========================================================================
