kusano fc6ab3
$! make libz under VMS written by
kusano fc6ab3
$! Martin P.J. Zinser
kusano fc6ab3
$!
kusano fc6ab3
$! In case of problems with the install you might contact me at
kusano fc6ab3
$! zinser@zinser.no-ip.info(preferred) or
kusano fc6ab3
$! martin.zinser@eurexchange.com (work)
kusano fc6ab3
$!
kusano fc6ab3
$! Make procedure history for Zlib
kusano fc6ab3
$!
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20060120 First version to receive a number
kusano fc6ab3
$! 0.02 20061008 Adapt to new Makefile.in
kusano fc6ab3
$! 0.03 20091224 Add support for large file check
kusano fc6ab3
$! 0.04 20100110 Add new gzclose, gzlib, gzread, gzwrite
kusano fc6ab3
$! 0.05 20100221 Exchange zlibdefs.h by zconf.h.in
kusano fc6ab3
$! 0.06 20120111 Fix missing amiss_err, update zconf_h.in, fix new exmples
kusano fc6ab3
$!               subdir path, update module search in makefile.in
kusano fc6ab3
$! 0.07 20120115 Triggered by work done by Alexey Chupahin completly redesigned
kusano fc6ab3
$!               shared image creation
kusano fc6ab3
$! 0.08 20120219 Make it work on VAX again, pre-load missing symbols to shared
kusano fc6ab3
$!               image
kusano fc6ab3
$! 0.09 20120305 SMS.  P1 sets builder ("MMK", "MMS", " " (built-in)).
kusano fc6ab3
$!               "" -> automatic, preference: MMK, MMS, built-in.
kusano fc6ab3
$!
kusano fc6ab3
$ on error then goto err_exit
kusano fc6ab3
$!
kusano fc6ab3
$ true  = 1
kusano fc6ab3
$ false = 0
kusano fc6ab3
$ tmpnam = "temp_" + f$getjpi("","pid")
kusano fc6ab3
$ tt = tmpnam + ".txt"
kusano fc6ab3
$ tc = tmpnam + ".c"
kusano fc6ab3
$ th = tmpnam + ".h"
kusano fc6ab3
$ define/nolog tconfig 'th'
kusano fc6ab3
$ its_decc = false
kusano fc6ab3
$ its_vaxc = false
kusano fc6ab3
$ its_gnuc = false
kusano fc6ab3
$ s_case   = False
kusano fc6ab3
$!
kusano fc6ab3
$! Setup variables holding "config" information
kusano fc6ab3
$!
kusano fc6ab3
$ Make    = "''p1'"
kusano fc6ab3
$ name     = "Zlib"
kusano fc6ab3
$ version  = "?.?.?"
kusano fc6ab3
$ v_string = "ZLIB_VERSION"
kusano fc6ab3
$ v_file   = "zlib.h"
kusano fc6ab3
$ ccopt   = "/include = []"
kusano fc6ab3
$ lopts   = ""
kusano fc6ab3
$ dnsrl   = ""
kusano fc6ab3
$ aconf_in_file = "zconf.h.in#zconf.h_in#zconf_h.in"
kusano fc6ab3
$ conf_check_string = ""
kusano fc6ab3
$ linkonly = false
kusano fc6ab3
$ optfile  = name + ".opt"
kusano fc6ab3
$ mapfile  = name + ".map"
kusano fc6ab3
$ libdefs  = ""
kusano fc6ab3
$ vax      = f$getsyi("HW_MODEL").lt.1024
kusano fc6ab3
$ axp      = f$getsyi("HW_MODEL").ge.1024 .and. f$getsyi("HW_MODEL").lt.4096
kusano fc6ab3
$ ia64     = f$getsyi("HW_MODEL").ge.4096
kusano fc6ab3
$!
kusano fc6ab3
$! 2012-03-05 SMS.
kusano fc6ab3
$! Why is this needed?  And if it is needed, why not simply ".not. vax"?
kusano fc6ab3
$!
kusano fc6ab3
$!!! if axp .or. ia64 then  set proc/parse=extended
kusano fc6ab3
$!
kusano fc6ab3
$ whoami = f$parse(f$environment("Procedure"),,,,"NO_CONCEAL")
kusano fc6ab3
$ mydef  = F$parse(whoami,,,"DEVICE")
kusano fc6ab3
$ mydir  = f$parse(whoami,,,"DIRECTORY") - "]["
kusano fc6ab3
$ myproc = f$parse(whoami,,,"Name") + f$parse(whoami,,,"type")
kusano fc6ab3
$!
kusano fc6ab3
$! Check for MMK/MMS
kusano fc6ab3
$!
kusano fc6ab3
$ if (Make .eqs. "")
kusano fc6ab3
$ then
kusano fc6ab3
$   If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS"
kusano fc6ab3
$   If F$Type (MMK) .eqs. "STRING" Then Make = "MMK"
kusano fc6ab3
$ else
kusano fc6ab3
$   Make = f$edit( Make, "trim")
kusano fc6ab3
$ endif
kusano fc6ab3
$!
kusano fc6ab3
$ gosub find_version
kusano fc6ab3
$!
kusano fc6ab3
$  open/write topt tmp.opt
kusano fc6ab3
$  open/write optf 'optfile'
kusano fc6ab3
$!
kusano fc6ab3
$ gosub check_opts
kusano fc6ab3
$!
kusano fc6ab3
$! Look for the compiler used
kusano fc6ab3
$!
kusano fc6ab3
$ gosub check_compiler
kusano fc6ab3
$ close topt
kusano fc6ab3
$ close optf
kusano fc6ab3
$!
kusano fc6ab3
$ if its_decc
kusano fc6ab3
$ then
kusano fc6ab3
$   ccopt = "/prefix=all" + ccopt
kusano fc6ab3
$   if f$trnlnm("SYS") .eqs. ""
kusano fc6ab3
$   then
kusano fc6ab3
$     if axp
kusano fc6ab3
$     then
kusano fc6ab3
$       define sys sys$library:
kusano fc6ab3
$     else
kusano fc6ab3
$       ccopt = "/decc" + ccopt
kusano fc6ab3
$       define sys decc$library_include:
kusano fc6ab3
$     endif
kusano fc6ab3
$   endif
kusano fc6ab3
$!
kusano fc6ab3
$! 2012-03-05 SMS.
kusano fc6ab3
$! Why /NAMES = AS_IS?  Why not simply ".not. vax"?  And why not on VAX?
kusano fc6ab3
$!
kusano fc6ab3
$   if axp .or. ia64
kusano fc6ab3
$   then
kusano fc6ab3
$       ccopt = ccopt + "/name=as_is/opt=(inline=speed)"
kusano fc6ab3
$       s_case = true
kusano fc6ab3
$   endif
kusano fc6ab3
$ endif
kusano fc6ab3
$ if its_vaxc .or. its_gnuc
kusano fc6ab3
$ then
kusano fc6ab3
$    if f$trnlnm("SYS").eqs."" then define sys sys$library:
kusano fc6ab3
$ endif
kusano fc6ab3
$!
kusano fc6ab3
$! Build a fake configure input header
kusano fc6ab3
$!
kusano fc6ab3
$ open/write conf_hin config.hin
kusano fc6ab3
$ write conf_hin "#undef _LARGEFILE64_SOURCE"
kusano fc6ab3
$ close conf_hin
kusano fc6ab3
$!
kusano fc6ab3
$!
kusano fc6ab3
$ i = 0
kusano fc6ab3
$FIND_ACONF:
kusano fc6ab3
$ fname = f$element(i,"#",aconf_in_file)
kusano fc6ab3
$ if fname .eqs. "#" then goto AMISS_ERR
kusano fc6ab3
$ if f$search(fname) .eqs. ""
kusano fc6ab3
$ then
kusano fc6ab3
$   i = i + 1
kusano fc6ab3
$   goto find_aconf
kusano fc6ab3
$ endif
kusano fc6ab3
$ open/read/err=aconf_err aconf_in 'fname'
kusano fc6ab3
$ open/write aconf zconf.h
kusano fc6ab3
$ACONF_LOOP:
kusano fc6ab3
$ read/end_of_file=aconf_exit aconf_in line
kusano fc6ab3
$ work = f$edit(line, "compress,trim")
kusano fc6ab3
$ if f$extract(0,6,work) .nes. "#undef"
kusano fc6ab3
$ then
kusano fc6ab3
$   if f$extract(0,12,work) .nes. "#cmakedefine"
kusano fc6ab3
$   then
kusano fc6ab3
$       write aconf line
kusano fc6ab3
$   endif
kusano fc6ab3
$ else
kusano fc6ab3
$   cdef = f$element(1," ",work)
kusano fc6ab3
$   gosub check_config
kusano fc6ab3
$ endif
kusano fc6ab3
$ goto aconf_loop
kusano fc6ab3
$ACONF_EXIT:
kusano fc6ab3
$ write aconf ""
kusano fc6ab3
$ write aconf "/* VMS specifics added by make_vms.com: */"
kusano fc6ab3
$ write aconf "#define VMS 1"
kusano fc6ab3
$ write aconf "#include <unistd.h>"</unistd.h>
kusano fc6ab3
$ write aconf "#include <unixio.h>"</unixio.h>
kusano fc6ab3
$ write aconf "#ifdef _LARGEFILE"
kusano fc6ab3
$ write aconf "# define off64_t __off64_t"
kusano fc6ab3
$ write aconf "# define fopen64 fopen"
kusano fc6ab3
$ write aconf "# define fseeko64 fseeko"
kusano fc6ab3
$ write aconf "# define lseek64 lseek"
kusano fc6ab3
$ write aconf "# define ftello64 ftell"
kusano fc6ab3
$ write aconf "#endif"
kusano fc6ab3
$ write aconf "#if !defined( __VAX) && (__CRTL_VER >= 70312000)"
kusano fc6ab3
$ write aconf "# define HAVE_VSNPRINTF"
kusano fc6ab3
$ write aconf "#endif"
kusano fc6ab3
$ close aconf_in
kusano fc6ab3
$ close aconf
kusano fc6ab3
$ if f$search("''th'") .nes. "" then delete 'th';*
kusano fc6ab3
$! Build the thing plain or with mms
kusano fc6ab3
$!
kusano fc6ab3
$ write sys$output "Compiling Zlib sources ..."
kusano fc6ab3
$ if make.eqs.""
kusano fc6ab3
$ then
kusano fc6ab3
$   if (f$search( "example.obj;*") .nes. "") then delete example.obj;*
kusano fc6ab3
$   if (f$search( "minigzip.obj;*") .nes. "") then delete minigzip.obj;*
kusano fc6ab3
$   CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
kusano fc6ab3
                adler32.c zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
kusano fc6ab3
                compress.c zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
kusano fc6ab3
                crc32.c zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
kusano fc6ab3
                deflate.c deflate.h zutil.h zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" -
kusano fc6ab3
                gzclose.c zutil.h zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" -
kusano fc6ab3
                gzlib.c zutil.h zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" -
kusano fc6ab3
                gzread.c zutil.h zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" -
kusano fc6ab3
                gzwrite.c zutil.h zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
kusano fc6ab3
                infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
kusano fc6ab3
$   CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
kusano fc6ab3
                inffast.c zutil.h zlib.h zconf.h inffast.h
kusano fc6ab3
$   CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" -
kusano fc6ab3
                inflate.c zutil.h zlib.h zconf.h infblock.h
kusano fc6ab3
$   CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" -
kusano fc6ab3
                inftrees.c zutil.h zlib.h zconf.h inftrees.h
kusano fc6ab3
$   CALL MAKE trees.OBJ "CC ''CCOPT' trees" -
kusano fc6ab3
                trees.c deflate.h zutil.h zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" -
kusano fc6ab3
                uncompr.c zlib.h zconf.h
kusano fc6ab3
$   CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" -
kusano fc6ab3
                zutil.c zutil.h zlib.h zconf.h
kusano fc6ab3
$   write sys$output "Building Zlib ..."
kusano fc6ab3
$   CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ
kusano fc6ab3
$   write sys$output "Building example..."
kusano fc6ab3
$   CALL MAKE example.OBJ "CC ''CCOPT' [.test]example" -
kusano fc6ab3
                [.test]example.c zlib.h zconf.h
kusano fc6ab3
$   call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb
kusano fc6ab3
$   write sys$output "Building minigzip..."
kusano fc6ab3
$   CALL MAKE minigzip.OBJ "CC ''CCOPT' [.test]minigzip" -
kusano fc6ab3
              [.test]minigzip.c zlib.h zconf.h
kusano fc6ab3
$   call make minigzip.exe -
kusano fc6ab3
              "LINK minigzip,libz.olb/lib" -
kusano fc6ab3
              minigzip.obj libz.olb
kusano fc6ab3
$ else
kusano fc6ab3
$   gosub crea_mms
kusano fc6ab3
$   write sys$output "Make ''name' ''version' with ''Make' "
kusano fc6ab3
$   'make'
kusano fc6ab3
$ endif
kusano fc6ab3
$!
kusano fc6ab3
$! Create shareable image
kusano fc6ab3
$!
kusano fc6ab3
$ gosub crea_olist
kusano fc6ab3
$ write sys$output "Creating libzshr.exe"
kusano fc6ab3
$ call map_2_shopt 'mapfile' 'optfile'
kusano fc6ab3
$ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,'optfile'/opt
kusano fc6ab3
$ write sys$output "Zlib build completed"
kusano fc6ab3
$ delete/nolog tmp.opt;*
kusano fc6ab3
$ exit
kusano fc6ab3
$AMISS_ERR:
kusano fc6ab3
$ write sys$output "No source for config.hin found."
kusano fc6ab3
$ write sys$output "Tried any of ''aconf_in_file'"
kusano fc6ab3
$ goto err_exit
kusano fc6ab3
$CC_ERR:
kusano fc6ab3
$ write sys$output "C compiler required to build ''name'"
kusano fc6ab3
$ goto err_exit
kusano fc6ab3
$ERR_EXIT:
kusano fc6ab3
$ set message/facil/ident/sever/text
kusano fc6ab3
$ close/nolog optf
kusano fc6ab3
$ close/nolog topt
kusano fc6ab3
$ close/nolog aconf_in
kusano fc6ab3
$ close/nolog aconf
kusano fc6ab3
$ close/nolog out
kusano fc6ab3
$ close/nolog min
kusano fc6ab3
$ close/nolog mod
kusano fc6ab3
$ close/nolog h_in
kusano fc6ab3
$ write sys$output "Exiting..."
kusano fc6ab3
$ exit 2
kusano fc6ab3
$!
kusano fc6ab3
$!
kusano fc6ab3
$MAKE: SUBROUTINE   !SUBROUTINE TO CHECK DEPENDENCIES
kusano fc6ab3
$ V = 'F$Verify(0)
kusano fc6ab3
$! P1 = What we are trying to make
kusano fc6ab3
$! P2 = Command to make it
kusano fc6ab3
$! P3 - P8  What it depends on
kusano fc6ab3
$
kusano fc6ab3
$ If F$Search(P1) .Eqs. "" Then Goto Makeit
kusano fc6ab3
$ Time = F$CvTime(F$File(P1,"RDT"))
kusano fc6ab3
$arg=3
kusano fc6ab3
$Loop:
kusano fc6ab3
$       Argument = P'arg
kusano fc6ab3
$       If Argument .Eqs. "" Then Goto Exit
kusano fc6ab3
$       El=0
kusano fc6ab3
$Loop2:
kusano fc6ab3
$       File = F$Element(El," ",Argument)
kusano fc6ab3
$       If File .Eqs. " " Then Goto Endl
kusano fc6ab3
$       AFile = ""
kusano fc6ab3
$Loop3:
kusano fc6ab3
$       OFile = AFile
kusano fc6ab3
$       AFile = F$Search(File)
kusano fc6ab3
$       If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
kusano fc6ab3
$       If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
kusano fc6ab3
$       Goto Loop3
kusano fc6ab3
$NextEL:
kusano fc6ab3
$       El = El + 1
kusano fc6ab3
$       Goto Loop2
kusano fc6ab3
$EndL:
kusano fc6ab3
$ arg=arg+1
kusano fc6ab3
$ If arg .Le. 8 Then Goto Loop
kusano fc6ab3
$ Goto Exit
kusano fc6ab3
$
kusano fc6ab3
$Makeit:
kusano fc6ab3
$ VV=F$VERIFY(0)
kusano fc6ab3
$ write sys$output P2
kusano fc6ab3
$ 'P2
kusano fc6ab3
$ VV='F$Verify(VV)
kusano fc6ab3
$Exit:
kusano fc6ab3
$ If V Then Set Verify
kusano fc6ab3
$ENDSUBROUTINE
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Check command line options and set symbols accordingly
kusano fc6ab3
$!
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20041206 First version to receive a number
kusano fc6ab3
$! 0.02 20060126 Add new "HELP" target
kusano fc6ab3
$ CHECK_OPTS:
kusano fc6ab3
$ i = 1
kusano fc6ab3
$ OPT_LOOP:
kusano fc6ab3
$ if i .lt. 9
kusano fc6ab3
$ then
kusano fc6ab3
$   cparm = f$edit(p'i',"upcase")
kusano fc6ab3
$!
kusano fc6ab3
$! Check if parameter actually contains something
kusano fc6ab3
$!
kusano fc6ab3
$   if f$edit(cparm,"trim") .nes. ""
kusano fc6ab3
$   then
kusano fc6ab3
$     if cparm .eqs. "DEBUG"
kusano fc6ab3
$     then
kusano fc6ab3
$       ccopt = ccopt + "/noopt/deb"
kusano fc6ab3
$       lopts = lopts + "/deb"
kusano fc6ab3
$     endif
kusano fc6ab3
$     if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
kusano fc6ab3
$     then
kusano fc6ab3
$       start = f$locate("=",cparm) + 1
kusano fc6ab3
$       len   = f$length(cparm) - start
kusano fc6ab3
$       ccopt = ccopt + f$extract(start,len,cparm)
kusano fc6ab3
$       if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
kusano fc6ab3
          then s_case = true
kusano fc6ab3
$     endif
kusano fc6ab3
$     if cparm .eqs. "LINK" then linkonly = true
kusano fc6ab3
$     if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
kusano fc6ab3
$     then
kusano fc6ab3
$       start = f$locate("=",cparm) + 1
kusano fc6ab3
$       len   = f$length(cparm) - start
kusano fc6ab3
$       lopts = lopts + f$extract(start,len,cparm)
kusano fc6ab3
$     endif
kusano fc6ab3
$     if f$locate("CC=",cparm) .lt. f$length(cparm)
kusano fc6ab3
$     then
kusano fc6ab3
$       start  = f$locate("=",cparm) + 1
kusano fc6ab3
$       len    = f$length(cparm) - start
kusano fc6ab3
$       cc_com = f$extract(start,len,cparm)
kusano fc6ab3
        if (cc_com .nes. "DECC") .and. -
kusano fc6ab3
           (cc_com .nes. "VAXC") .and. -
kusano fc6ab3
           (cc_com .nes. "GNUC")
kusano fc6ab3
$       then
kusano fc6ab3
$         write sys$output "Unsupported compiler choice ''cc_com' ignored"
kusano fc6ab3
$         write sys$output "Use DECC, VAXC, or GNUC instead"
kusano fc6ab3
$       else
kusano fc6ab3
$         if cc_com .eqs. "DECC" then its_decc = true
kusano fc6ab3
$         if cc_com .eqs. "VAXC" then its_vaxc = true
kusano fc6ab3
$         if cc_com .eqs. "GNUC" then its_gnuc = true
kusano fc6ab3
$       endif
kusano fc6ab3
$     endif
kusano fc6ab3
$     if f$locate("MAKE=",cparm) .lt. f$length(cparm)
kusano fc6ab3
$     then
kusano fc6ab3
$       start  = f$locate("=",cparm) + 1
kusano fc6ab3
$       len    = f$length(cparm) - start
kusano fc6ab3
$       mmks = f$extract(start,len,cparm)
kusano fc6ab3
$       if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
kusano fc6ab3
$       then
kusano fc6ab3
$         make = mmks
kusano fc6ab3
$       else
kusano fc6ab3
$         write sys$output "Unsupported make choice ''mmks' ignored"
kusano fc6ab3
$         write sys$output "Use MMK or MMS instead"
kusano fc6ab3
$       endif
kusano fc6ab3
$     endif
kusano fc6ab3
$     if cparm .eqs. "HELP" then gosub bhelp
kusano fc6ab3
$   endif
kusano fc6ab3
$   i = i + 1
kusano fc6ab3
$   goto opt_loop
kusano fc6ab3
$ endif
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Look for the compiler used
kusano fc6ab3
$!
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20040223 First version to receive a number
kusano fc6ab3
$! 0.02 20040229 Save/set value of decc$no_rooted_search_lists
kusano fc6ab3
$! 0.03 20060202 Extend handling of GNU C
kusano fc6ab3
$! 0.04 20090402 Compaq -> hp
kusano fc6ab3
$CHECK_COMPILER:
kusano fc6ab3
$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
kusano fc6ab3
$ then
kusano fc6ab3
$   its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "")
kusano fc6ab3
$   its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "")
kusano fc6ab3
$   its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "")
kusano fc6ab3
$ endif
kusano fc6ab3
$!
kusano fc6ab3
$! Exit if no compiler available
kusano fc6ab3
$!
kusano fc6ab3
$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
kusano fc6ab3
$ then goto CC_ERR
kusano fc6ab3
$ else
kusano fc6ab3
$   if its_decc
kusano fc6ab3
$   then
kusano fc6ab3
$     write sys$output "CC compiler check ... hp C"
kusano fc6ab3
$     if f$trnlnm("decc$no_rooted_search_lists") .nes. ""
kusano fc6ab3
$     then
kusano fc6ab3
$       dnrsl = f$trnlnm("decc$no_rooted_search_lists")
kusano fc6ab3
$     endif
kusano fc6ab3
$     define/nolog decc$no_rooted_search_lists 1
kusano fc6ab3
$   else
kusano fc6ab3
$     if its_vaxc then write sys$output "CC compiler check ... VAX C"
kusano fc6ab3
$     if its_gnuc
kusano fc6ab3
$     then
kusano fc6ab3
$         write sys$output "CC compiler check ... GNU C"
kusano fc6ab3
$         if f$trnlnm(topt) then write topt "gnu_cc:[000000]gcclib.olb/lib"
kusano fc6ab3
$         if f$trnlnm(optf) then write optf "gnu_cc:[000000]gcclib.olb/lib"
kusano fc6ab3
$         cc = "gcc"
kusano fc6ab3
$     endif
kusano fc6ab3
$     if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share"
kusano fc6ab3
$     if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share"
kusano fc6ab3
$   endif
kusano fc6ab3
$ endif
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! If MMS/MMK are available dump out the descrip.mms if required
kusano fc6ab3
$!
kusano fc6ab3
$CREA_MMS:
kusano fc6ab3
$ write sys$output "Creating descrip.mms..."
kusano fc6ab3
$ create descrip.mms
kusano fc6ab3
$ open/append out descrip.mms
kusano fc6ab3
$ copy sys$input: out
kusano fc6ab3
$ deck
kusano fc6ab3
# descrip.mms: MMS description file for building zlib on VMS
kusano fc6ab3
# written by Martin P.J. Zinser
kusano fc6ab3
# <zinser@zinser.no-ip.info martin.zinser@eurexchange.com="" or=""></zinser@zinser.no-ip.info>
kusano fc6ab3
kusano fc6ab3
OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzlib.obj\
kusano fc6ab3
       gzread.obj, gzwrite.obj, uncompr.obj, infback.obj\
kusano fc6ab3
       deflate.obj, trees.obj, zutil.obj, inflate.obj, \
kusano fc6ab3
       inftrees.obj, inffast.obj
kusano fc6ab3
kusano fc6ab3
$ eod
kusano fc6ab3
$ write out "CFLAGS=", ccopt
kusano fc6ab3
$ write out "LOPTS=", lopts
kusano fc6ab3
$ write out "all : example.exe minigzip.exe libz.olb"
kusano fc6ab3
$ copy sys$input: out
kusano fc6ab3
$ deck
kusano fc6ab3
        @ write sys$output " Example applications available"
kusano fc6ab3
kusano fc6ab3
libz.olb : libz.olb($(OBJS))
kusano fc6ab3
	@ write sys$output " libz available"
kusano fc6ab3
kusano fc6ab3
example.exe : example.obj libz.olb
kusano fc6ab3
              link $(LOPTS) example,libz.olb/lib
kusano fc6ab3
kusano fc6ab3
minigzip.exe : minigzip.obj libz.olb
kusano fc6ab3
              link $(LOPTS) minigzip,libz.olb/lib
kusano fc6ab3
kusano fc6ab3
clean :
kusano fc6ab3
	delete *.obj;*,libz.olb;*,*.opt;*,*.exe;*
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
# Other dependencies.
kusano fc6ab3
adler32.obj  : adler32.c zutil.h zlib.h zconf.h
kusano fc6ab3
compress.obj : compress.c zlib.h zconf.h
kusano fc6ab3
crc32.obj    : crc32.c zutil.h zlib.h zconf.h
kusano fc6ab3
deflate.obj  : deflate.c deflate.h zutil.h zlib.h zconf.h
kusano fc6ab3
example.obj  : [.test]example.c zlib.h zconf.h
kusano fc6ab3
gzclose.obj  : gzclose.c zutil.h zlib.h zconf.h
kusano fc6ab3
gzlib.obj    : gzlib.c zutil.h zlib.h zconf.h
kusano fc6ab3
gzread.obj   : gzread.c zutil.h zlib.h zconf.h
kusano fc6ab3
gzwrite.obj  : gzwrite.c zutil.h zlib.h zconf.h
kusano fc6ab3
inffast.obj  : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h
kusano fc6ab3
inflate.obj  : inflate.c zutil.h zlib.h zconf.h
kusano fc6ab3
inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h
kusano fc6ab3
minigzip.obj : [.test]minigzip.c zlib.h zconf.h
kusano fc6ab3
trees.obj    : trees.c deflate.h zutil.h zlib.h zconf.h
kusano fc6ab3
uncompr.obj  : uncompr.c zlib.h zconf.h
kusano fc6ab3
zutil.obj    : zutil.c zutil.h zlib.h zconf.h
kusano fc6ab3
infback.obj  : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
kusano fc6ab3
$ eod
kusano fc6ab3
$ close out
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Read list of core library sources from makefile.in and create options
kusano fc6ab3
$! needed to build shareable image
kusano fc6ab3
$!
kusano fc6ab3
$CREA_OLIST:
kusano fc6ab3
$ open/read min makefile.in
kusano fc6ab3
$ open/write mod modules.opt
kusano fc6ab3
$ src_check_list = "OBJZ =#OBJG ="
kusano fc6ab3
$MRLOOP:
kusano fc6ab3
$ read/end=mrdone min rec
kusano fc6ab3
$ i = 0
kusano fc6ab3
$SRC_CHECK_LOOP:
kusano fc6ab3
$ src_check = f$element(i, "#", src_check_list)
kusano fc6ab3
$ i = i+1
kusano fc6ab3
$ if src_check .eqs. "#" then goto mrloop
kusano fc6ab3
$ if (f$extract(0,6,rec) .nes. src_check) then goto src_check_loop
kusano fc6ab3
$ rec = rec - src_check
kusano fc6ab3
$ gosub extra_filnam
kusano fc6ab3
$ if (f$element(1,"\",rec) .eqs. "\") then goto mrloop
kusano fc6ab3
$MRSLOOP:
kusano fc6ab3
$ read/end=mrdone min rec
kusano fc6ab3
$ gosub extra_filnam
kusano fc6ab3
$ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop
kusano fc6ab3
$MRDONE:
kusano fc6ab3
$ close min
kusano fc6ab3
$ close mod
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Take record extracted in crea_olist and split it into single filenames
kusano fc6ab3
$!
kusano fc6ab3
$EXTRA_FILNAM:
kusano fc6ab3
$ myrec = f$edit(rec - "\", "trim,compress")
kusano fc6ab3
$ i = 0
kusano fc6ab3
$FELOOP:
kusano fc6ab3
$ srcfil = f$element(i," ", myrec)
kusano fc6ab3
$ if (srcfil .nes. " ")
kusano fc6ab3
$ then
kusano fc6ab3
$   write mod f$parse(srcfil,,,"NAME"), ".obj"
kusano fc6ab3
$   i = i + 1
kusano fc6ab3
$   goto feloop
kusano fc6ab3
$ endif
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Find current Zlib version number
kusano fc6ab3
$!
kusano fc6ab3
$FIND_VERSION:
kusano fc6ab3
$ open/read h_in 'v_file'
kusano fc6ab3
$hloop:
kusano fc6ab3
$ read/end=hdone h_in rec
kusano fc6ab3
$ rec = f$edit(rec,"TRIM")
kusano fc6ab3
$ if (f$extract(0,1,rec) .nes. "#") then goto hloop
kusano fc6ab3
$ rec = f$edit(rec - "#", "TRIM")
kusano fc6ab3
$ if f$element(0," ",rec) .nes. "define" then goto hloop
kusano fc6ab3
$ if f$element(1," ",rec) .eqs. v_string
kusano fc6ab3
$ then
kusano fc6ab3
$   version = 'f$element(2," ",rec)'
kusano fc6ab3
$   goto hdone
kusano fc6ab3
$ endif
kusano fc6ab3
$ goto hloop
kusano fc6ab3
$hdone:
kusano fc6ab3
$ close h_in
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$CHECK_CONFIG:
kusano fc6ab3
$!
kusano fc6ab3
$ in_ldef = f$locate(cdef,libdefs)
kusano fc6ab3
$ if (in_ldef .lt. f$length(libdefs))
kusano fc6ab3
$ then
kusano fc6ab3
$   write aconf "#define ''cdef' 1"
kusano fc6ab3
$   libdefs = f$extract(0,in_ldef,libdefs) + -
kusano fc6ab3
              f$extract(in_ldef + f$length(cdef) + 1, -
kusano fc6ab3
                        f$length(libdefs) - in_ldef - f$length(cdef) - 1, -
kusano fc6ab3
                        libdefs)
kusano fc6ab3
$ else
kusano fc6ab3
$   if (f$type('cdef') .eqs. "INTEGER")
kusano fc6ab3
$   then
kusano fc6ab3
$     write aconf "#define ''cdef' ", 'cdef'
kusano fc6ab3
$   else
kusano fc6ab3
$     if (f$type('cdef') .eqs. "STRING")
kusano fc6ab3
$     then
kusano fc6ab3
$       write aconf "#define ''cdef' ", """", '''cdef'', """"
kusano fc6ab3
$     else
kusano fc6ab3
$       gosub check_cc_def
kusano fc6ab3
$     endif
kusano fc6ab3
$   endif
kusano fc6ab3
$ endif
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Check if this is a define relating to the properties of the C/C++
kusano fc6ab3
$! compiler
kusano fc6ab3
$!
kusano fc6ab3
$ CHECK_CC_DEF:
kusano fc6ab3
$ if (cdef .eqs. "_LARGEFILE64_SOURCE")
kusano fc6ab3
$ then
kusano fc6ab3
$   copy sys$input: 'tc'
kusano fc6ab3
$   deck
kusano fc6ab3
#include "tconfig"
kusano fc6ab3
#define _LARGEFILE
kusano fc6ab3
#include <stdio.h></stdio.h>
kusano fc6ab3
kusano fc6ab3
int main(){
kusano fc6ab3
FILE *fp;
kusano fc6ab3
  fp = fopen("temp.txt","r");
kusano fc6ab3
  fseeko(fp,1,SEEK_SET);
kusano fc6ab3
  fclose(fp);
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
$   eod
kusano fc6ab3
$   test_inv = false
kusano fc6ab3
$   comm_h = false
kusano fc6ab3
$   gosub cc_prop_check
kusano fc6ab3
$   return
kusano fc6ab3
$ endif
kusano fc6ab3
$ write aconf "/* ", line, " */"
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Check for properties of C/C++ compiler
kusano fc6ab3
$!
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20031020 First version to receive a number
kusano fc6ab3
$! 0.02 20031022 Added logic for defines with value
kusano fc6ab3
$! 0.03 20040309 Make sure local config file gets not deleted
kusano fc6ab3
$! 0.04 20041230 Also write include for configure run
kusano fc6ab3
$! 0.05 20050103 Add processing of "comment defines"
kusano fc6ab3
$CC_PROP_CHECK:
kusano fc6ab3
$ cc_prop = true
kusano fc6ab3
$ is_need = false
kusano fc6ab3
$ is_need = (f$extract(0,4,cdef) .eqs. "NEED") .or. (test_inv .eq. true)
kusano fc6ab3
$ if f$search(th) .eqs. "" then create 'th'
kusano fc6ab3
$ set message/nofac/noident/nosever/notext
kusano fc6ab3
$ on error then continue
kusano fc6ab3
$ cc 'tmpnam'
kusano fc6ab3
$ if .not. ($status)  then cc_prop = false
kusano fc6ab3
$ on error then continue
kusano fc6ab3
$! The headers might lie about the capabilities of the RTL
kusano fc6ab3
$ link 'tmpnam',tmp.opt/opt
kusano fc6ab3
$ if .not. ($status)  then cc_prop = false
kusano fc6ab3
$ set message/fac/ident/sever/text
kusano fc6ab3
$ on error then goto err_exit
kusano fc6ab3
$ delete/nolog 'tmpnam'.*;*/exclude='th'
kusano fc6ab3
$ if (cc_prop .and. .not. is_need) .or. -
kusano fc6ab3
     (.not. cc_prop .and. is_need)
kusano fc6ab3
$ then
kusano fc6ab3
$   write sys$output "Checking for ''cdef'... yes"
kusano fc6ab3
$   if f$type('cdef_val'_yes) .nes. ""
kusano fc6ab3
$   then
kusano fc6ab3
$     if f$type('cdef_val'_yes) .eqs. "INTEGER" -
kusano fc6ab3
         then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_yes)
kusano fc6ab3
$     if f$type('cdef_val'_yes) .eqs. "STRING" -
kusano fc6ab3
         then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_yes)
kusano fc6ab3
$   else
kusano fc6ab3
$     call write_config f$fao("#define !AS 1",cdef)
kusano fc6ab3
$   endif
kusano fc6ab3
$   if (cdef .eqs. "HAVE_FSEEKO") .or. (cdef .eqs. "_LARGE_FILES") .or. -
kusano fc6ab3
       (cdef .eqs. "_LARGEFILE64_SOURCE") then -
kusano fc6ab3
      call write_config f$string("#define _LARGEFILE 1")
kusano fc6ab3
$ else
kusano fc6ab3
$   write sys$output "Checking for ''cdef'... no"
kusano fc6ab3
$   if (comm_h)
kusano fc6ab3
$   then
kusano fc6ab3
      call write_config f$fao("/* !AS */",line)
kusano fc6ab3
$   else
kusano fc6ab3
$     if f$type('cdef_val'_no) .nes. ""
kusano fc6ab3
$     then
kusano fc6ab3
$       if f$type('cdef_val'_no) .eqs. "INTEGER" -
kusano fc6ab3
           then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_no)
kusano fc6ab3
$       if f$type('cdef_val'_no) .eqs. "STRING" -
kusano fc6ab3
           then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_no)
kusano fc6ab3
$     else
kusano fc6ab3
$       call write_config f$fao("#undef !AS",cdef)
kusano fc6ab3
$     endif
kusano fc6ab3
$   endif
kusano fc6ab3
$ endif
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Check for properties of C/C++ compiler with multiple result values
kusano fc6ab3
$!
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20040127 First version
kusano fc6ab3
$! 0.02 20050103 Reconcile changes from cc_prop up to version 0.05
kusano fc6ab3
$CC_MPROP_CHECK:
kusano fc6ab3
$ cc_prop = true
kusano fc6ab3
$ i    = 1
kusano fc6ab3
$ idel = 1
kusano fc6ab3
$ MT_LOOP:
kusano fc6ab3
$ if f$type(result_'i') .eqs. "STRING"
kusano fc6ab3
$ then
kusano fc6ab3
$   set message/nofac/noident/nosever/notext
kusano fc6ab3
$   on error then continue
kusano fc6ab3
$   cc 'tmpnam'_'i'
kusano fc6ab3
$   if .not. ($status)  then cc_prop = false
kusano fc6ab3
$   on error then continue
kusano fc6ab3
$! The headers might lie about the capabilities of the RTL
kusano fc6ab3
$   link 'tmpnam'_'i',tmp.opt/opt
kusano fc6ab3
$   if .not. ($status)  then cc_prop = false
kusano fc6ab3
$   set message/fac/ident/sever/text
kusano fc6ab3
$   on error then goto err_exit
kusano fc6ab3
$   delete/nolog 'tmpnam'_'i'.*;*
kusano fc6ab3
$   if (cc_prop)
kusano fc6ab3
$   then
kusano fc6ab3
$     write sys$output "Checking for ''cdef'... ", mdef_'i'
kusano fc6ab3
$     if f$type(mdef_'i') .eqs. "INTEGER" -
kusano fc6ab3
         then call write_config f$fao("#define !AS !UL",cdef,mdef_'i')
kusano fc6ab3
$     if f$type('cdef_val'_yes) .eqs. "STRING" -
kusano fc6ab3
         then call write_config f$fao("#define !AS !AS",cdef,mdef_'i')
kusano fc6ab3
$     goto msym_clean
kusano fc6ab3
$   else
kusano fc6ab3
$     i = i + 1
kusano fc6ab3
$     goto mt_loop
kusano fc6ab3
$   endif
kusano fc6ab3
$ endif
kusano fc6ab3
$ write sys$output "Checking for ''cdef'... no"
kusano fc6ab3
$ call write_config f$fao("#undef !AS",cdef)
kusano fc6ab3
$ MSYM_CLEAN:
kusano fc6ab3
$ if (idel .le. msym_max)
kusano fc6ab3
$ then
kusano fc6ab3
$   delete/sym mdef_'idel'
kusano fc6ab3
$   idel = idel + 1
kusano fc6ab3
$   goto msym_clean
kusano fc6ab3
$ endif
kusano fc6ab3
$ return
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Write configuration to both permanent and temporary config file
kusano fc6ab3
$!
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20031029 First version to receive a number
kusano fc6ab3
$!
kusano fc6ab3
$WRITE_CONFIG: SUBROUTINE
kusano fc6ab3
$  write aconf 'p1'
kusano fc6ab3
$  open/append confh 'th'
kusano fc6ab3
$  write confh 'p1'
kusano fc6ab3
$  close confh
kusano fc6ab3
$ENDSUBROUTINE
kusano fc6ab3
$!------------------------------------------------------------------------------
kusano fc6ab3
$!
kusano fc6ab3
$! Analyze the project map file and create the symbol vector for a shareable
kusano fc6ab3
$! image from it
kusano fc6ab3
$!
kusano fc6ab3
$! Version history
kusano fc6ab3
$! 0.01 20120128 First version
kusano fc6ab3
$! 0.02 20120226 Add pre-load logic
kusano fc6ab3
$!
kusano fc6ab3
$ MAP_2_SHOPT: Subroutine
kusano fc6ab3
$!
kusano fc6ab3
$ SAY := "WRITE_ SYS$OUTPUT"
kusano fc6ab3
$!
kusano fc6ab3
$ IF F$SEARCH("''P1'") .EQS. ""
kusano fc6ab3
$ THEN
kusano fc6ab3
$    SAY "MAP_2_SHOPT-E-NOSUCHFILE:  Error, inputfile ''p1' not available"
kusano fc6ab3
$    goto exit_m2s
kusano fc6ab3
$ ENDIF
kusano fc6ab3
$ IF "''P2'" .EQS. ""
kusano fc6ab3
$ THEN
kusano fc6ab3
$    SAY "MAP_2_SHOPT:  Error, no output file provided"
kusano fc6ab3
$    goto exit_m2s
kusano fc6ab3
$ ENDIF
kusano fc6ab3
$!
kusano fc6ab3
$ module1 = "deflate#deflateEnd#deflateInit_#deflateParams#deflateSetDictionary"
kusano fc6ab3
$ module2 = "gzclose#gzerror#gzgetc#gzgets#gzopen#gzprintf#gzputc#gzputs#gzread"
kusano fc6ab3
$ module3 = "gzseek#gztell#inflate#inflateEnd#inflateInit_#inflateSetDictionary"
kusano fc6ab3
$ module4 = "inflateSync#uncompress#zlibVersion#compress"
kusano fc6ab3
$ open/read map 'p1
kusano fc6ab3
$ if axp .or. ia64
kusano fc6ab3
$ then
kusano fc6ab3
$     open/write aopt a.opt
kusano fc6ab3
$     open/write bopt b.opt
kusano fc6ab3
$     write aopt " CASE_SENSITIVE=YES"
kusano fc6ab3
$     write bopt "SYMBOL_VECTOR= (-"
kusano fc6ab3
$     mod_sym_num = 1
kusano fc6ab3
$ MOD_SYM_LOOP:
kusano fc6ab3
$     if f$type(module'mod_sym_num') .nes. ""
kusano fc6ab3
$     then
kusano fc6ab3
$         mod_in = 0
kusano fc6ab3
$ MOD_SYM_IN:
kusano fc6ab3
$         shared_proc = f$element(mod_in, "#", module'mod_sym_num')
kusano fc6ab3
$         if shared_proc .nes. "#"
kusano fc6ab3
$         then
kusano fc6ab3
$             write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",-
kusano fc6ab3
        		       f$edit(shared_proc,"upcase"),shared_proc)
kusano fc6ab3
$             write bopt f$fao("!AS=PROCEDURE,-",shared_proc)
kusano fc6ab3
$             mod_in = mod_in + 1
kusano fc6ab3
$             goto mod_sym_in
kusano fc6ab3
$         endif
kusano fc6ab3
$         mod_sym_num = mod_sym_num + 1
kusano fc6ab3
$         goto mod_sym_loop
kusano fc6ab3
$     endif
kusano fc6ab3
$MAP_LOOP:
kusano fc6ab3
$     read/end=map_end map line
kusano fc6ab3
$     if (f$locate("{",line).lt. f$length(line)) .or. -
kusano fc6ab3
         (f$locate("global:", line) .lt. f$length(line))
kusano fc6ab3
$     then
kusano fc6ab3
$         proc = true
kusano fc6ab3
$         goto map_loop
kusano fc6ab3
$     endif
kusano fc6ab3
$     if f$locate("}",line).lt. f$length(line) then proc = false
kusano fc6ab3
$     if f$locate("local:", line) .lt. f$length(line) then proc = false
kusano fc6ab3
$     if proc
kusano fc6ab3
$     then
kusano fc6ab3
$         shared_proc = f$edit(line,"collapse")
kusano fc6ab3
$         chop_semi = f$locate(";", shared_proc)
kusano fc6ab3
$         if chop_semi .lt. f$length(shared_proc) then -
kusano fc6ab3
              shared_proc = f$extract(0, chop_semi, shared_proc)
kusano fc6ab3
$         write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",-
kusano fc6ab3
        			 f$edit(shared_proc,"upcase"),shared_proc)
kusano fc6ab3
$         write bopt f$fao("!AS=PROCEDURE,-",shared_proc)
kusano fc6ab3
$     endif
kusano fc6ab3
$     goto map_loop
kusano fc6ab3
$MAP_END:
kusano fc6ab3
$     close/nolog aopt
kusano fc6ab3
$     close/nolog bopt
kusano fc6ab3
$     open/append libopt 'p2'
kusano fc6ab3
$     open/read aopt a.opt
kusano fc6ab3
$     open/read bopt b.opt
kusano fc6ab3
$ALOOP:
kusano fc6ab3
$     read/end=aloop_end aopt line
kusano fc6ab3
$     write libopt line
kusano fc6ab3
$     goto aloop
kusano fc6ab3
$ALOOP_END:
kusano fc6ab3
$     close/nolog aopt
kusano fc6ab3
$     sv = ""
kusano fc6ab3
$BLOOP:
kusano fc6ab3
$     read/end=bloop_end bopt svn
kusano fc6ab3
$     if (svn.nes."")
kusano fc6ab3
$     then
kusano fc6ab3
$        if (sv.nes."") then write libopt sv
kusano fc6ab3
$        sv = svn
kusano fc6ab3
$     endif
kusano fc6ab3
$     goto bloop
kusano fc6ab3
$BLOOP_END:
kusano fc6ab3
$     write libopt f$extract(0,f$length(sv)-2,sv), "-"
kusano fc6ab3
$     write libopt ")"
kusano fc6ab3
$     close/nolog bopt
kusano fc6ab3
$     delete/nolog/noconf a.opt;*,b.opt;*
kusano fc6ab3
$ else
kusano fc6ab3
$     if vax
kusano fc6ab3
$     then
kusano fc6ab3
$     open/append libopt 'p2'
kusano fc6ab3
$     mod_sym_num = 1
kusano fc6ab3
$ VMOD_SYM_LOOP:
kusano fc6ab3
$     if f$type(module'mod_sym_num') .nes. ""
kusano fc6ab3
$     then
kusano fc6ab3
$         mod_in = 0
kusano fc6ab3
$ VMOD_SYM_IN:
kusano fc6ab3
$         shared_proc = f$element(mod_in, "#", module'mod_sym_num')
kusano fc6ab3
$         if shared_proc .nes. "#"
kusano fc6ab3
$         then
kusano fc6ab3
$     	      write libopt f$fao("UNIVERSAL=!AS",-
kusano fc6ab3
      	  			     f$edit(shared_proc,"upcase"))
kusano fc6ab3
$             mod_in = mod_in + 1
kusano fc6ab3
$             goto vmod_sym_in
kusano fc6ab3
$         endif
kusano fc6ab3
$         mod_sym_num = mod_sym_num + 1
kusano fc6ab3
$         goto vmod_sym_loop
kusano fc6ab3
$     endif
kusano fc6ab3
$VMAP_LOOP:
kusano fc6ab3
$     	  read/end=vmap_end map line
kusano fc6ab3
$     	  if (f$locate("{",line).lt. f$length(line)) .or. -
kusano fc6ab3
   	      (f$locate("global:", line) .lt. f$length(line))
kusano fc6ab3
$     	  then
kusano fc6ab3
$     	      proc = true
kusano fc6ab3
$     	      goto vmap_loop
kusano fc6ab3
$     	  endif
kusano fc6ab3
$     	  if f$locate("}",line).lt. f$length(line) then proc = false
kusano fc6ab3
$     	  if f$locate("local:", line) .lt. f$length(line) then proc = false
kusano fc6ab3
$     	  if proc
kusano fc6ab3
$     	  then
kusano fc6ab3
$     	      shared_proc = f$edit(line,"collapse")
kusano fc6ab3
$     	      chop_semi = f$locate(";", shared_proc)
kusano fc6ab3
$     	      if chop_semi .lt. f$length(shared_proc) then -
kusano fc6ab3
      	  	  shared_proc = f$extract(0, chop_semi, shared_proc)
kusano fc6ab3
$     	      write libopt f$fao("UNIVERSAL=!AS",-
kusano fc6ab3
      	  			     f$edit(shared_proc,"upcase"))
kusano fc6ab3
$     	  endif
kusano fc6ab3
$     	  goto vmap_loop
kusano fc6ab3
$VMAP_END:
kusano fc6ab3
$     else
kusano fc6ab3
$         write sys$output "Unknown Architecture (Not VAX, AXP, or IA64)"
kusano fc6ab3
$         write sys$output "No options file created"
kusano fc6ab3
$     endif
kusano fc6ab3
$ endif
kusano fc6ab3
$ EXIT_M2S:
kusano fc6ab3
$ close/nolog map
kusano fc6ab3
$ close/nolog libopt
kusano fc6ab3
$ endsubroutine