1 $! MKSHARED.COM -- script to created shareable images on VMS
3 $! No command line parameters. This should be run at the start of the source
4 $! tree (the same directory where one finds INSTALL.VMS).
6 $! Input: [.UTIL]LIBEAY.NUM,[.AXP.EXE.CRYPTO]LIBCRYPTO.OLB
7 $! [.UTIL]SSLEAY.NUM,[.AXP.EXE.SSL]LIBSSL.OLB
8 $! Output: [.AXP.EXE.CRYPTO]LIBCRYPTO.OPT,.MAP,.EXE
9 $! [.AXP.EXE.SSL]LIBSSL.OPT,.MAP,.EXE
11 $! So far, tests have only been made on VMS for Alpha. VAX will come in time.
12 $! ===========================================================================
14 $! ----- Prepare info for processing: version number and file info
15 $ gosub read_version_info
18 $ write sys$error "ERROR: Couldn't find any library version info..."
22 $ if f$getsyi("CPU") .ge. 128
25 $ libnum = "[.UTIL]LIBEAY.NUM"
26 $ libdir = "[.AXP.EXE.CRYPTO]"
27 $ libolb = "''libdir'LIBCRYPTO.OLB"
28 $ libopt = "''libdir'LIBCRYPTO.OPT"
29 $ libmap = "''libdir'LIBCRYPTO.MAP"
30 $ libgoal= "''libdir'LIBCRYPTO.EXE"
32 $ gosub create_axp_shr
34 $ libnum = "[.UTIL]SSLEAY.NUM"
35 $ libdir = "[.AXP.EXE.SSL]"
36 $ libolb = "''libdir'LIBSSL.OLB"
37 $ libopt = "''libdir'LIBSSL.OPT"
38 $ libmap = "''libdir'LIBSSL.MAP"
39 $ libgoal= "''libdir'LIBSSL.EXE"
40 $ libref = "[.AXP.EXE.CRYPTO]LIBCRYPTO.EXE"
41 $ gosub create_axp_shr
43 $ libtit = "CRYPTO_TRANSFER_VECTOR"
45 $ libnum = "[.UTIL]LIBEAY.NUM"
46 $ libdir = "[.VAX.EXE.CRYPTO]"
47 $ libmar = "''libdir'LIBCRYPTO.MAR"
48 $ libolb = "''libdir'LIBCRYPTO.OLB"
49 $ libopt = "''libdir'LIBCRYPTO.OPT"
50 $ libobj = "''libdir'LIBCRYPTO.OBJ"
51 $ libmap = "''libdir'LIBCRYPTO.MAP"
52 $ libgoal= "''libdir'LIBCRYPTO.EXE"
54 $ libvec = "LIBCRYPTO"
55 $ gosub create_vax_shr
56 $ libtit = "SSL_TRANSFER_VECTOR"
58 $ libnum = "[.UTIL]SSLEAY.NUM"
59 $ libdir = "[.VAX.EXE.SSL]"
60 $ libmar = "''libdir'LIBSSL.MAR"
61 $ libolb = "''libdir'LIBSSL.OLB"
62 $ libopt = "''libdir'LIBSSL.OPT"
63 $ libobj = "''libdir'LIBSSL.OBJ"
64 $ libmap = "''libdir'LIBSSL.MAP"
65 $ libgoal= "''libdir'LIBSSL.EXE"
66 $ libref = "[.VAX.EXE.CRYPTO]LIBCRYPTO.EXE"
68 $ gosub create_vax_shr
72 $! ----- Soubroutines to actually build the shareable libraries
73 $! The way things work, there's a main shareable library creator for each
74 $! supported architecture, which is called from the main code above.
75 $! The creator will define a number of variables to tell the next levels of
76 $! subroutines what routines to use to write to the option files, call the
77 $! main processor, read_func_num, and when that is done, it will write version
78 $! data at the end of the .opt file, close it, and link the library.
80 $! read_func_num reads through a .num file and calls the writer routine for
81 $! each line. It's also responsible for checking that order is properly kept
82 $! in the .num file, check that each line applies to VMS and the architecture,
83 $! and to fill in "holes" with dummy entries.
85 $! The creator routines depend on the following variables:
86 $! libnum The name of the .num file to use as input
87 $! libolb The name of the object library to build from
88 $! libid The identification string of the shareable library
89 $! libopt The name of the .opt file to write
90 $! libtit The title of the assembler transfer vector file (VAX only)
91 $! libmar The name of the assembler transfer vector file (VAX only)
92 $! libmap The name of the map file to write
93 $! libgoal The name of the shareable library to write
94 $! libref The name of a shareable library to link in
96 $! read_func_num depends on the following variables from the creator:
97 $! libwriter The name of the writer routine to call for each .num file line
100 $! ----- Subroutines for AXP
102 $! The creator routine
104 $ open/write opt 'libopt'
105 $ write opt "identification=""",libid," ",libverstr,""""
106 $ write opt libolb,"/lib"
107 $ if libref .nes. "" then write opt libref,"/SHARE"
108 $ write opt "SYMBOL_VECTOR=(-"
109 $ libfirstentry := true
111 $ libwriter := write_axp_transfer_entry
113 $ gosub read_func_num
115 $ write opt "GSMATCH=",libvmatch,",",libver
117 $ link/map='libmap'/full/share='libgoal' 'libopt'/option
120 $! The record writer routine
121 $ write_axp_transfer_entry:
122 $ if libentry .eqs. ".dummy" then return
123 $ if info_kind .eqs. "VARIABLE"
129 $ textcount_this = f$length(pr) + f$length(libentry) + 5
130 $ if textcount + textcount_this .gt. 1024
133 $ write opt "SYMBOL_VECTOR=(-"
135 $ libfirstentry := true
139 $ write 'libwrch' " ",libentry,"=",pr," -"
141 $ write 'libwrch' " ,",libentry,"=",pr," -"
143 $ libfirstentry := false
144 $ textcount = textcount + textcount_this
147 $! ----- Subroutines for AXP
149 $! The creator routine
151 $ open/write mar 'libmar'
152 $ type sys$input:/out=mar:
154 ; Transfer vector for VAX shareable image
156 $ write mar " .TITLE ",libtit
157 $ write mar " .IDENT /",libid,"/"
158 $ type sys$input:/out=mar:
160 ; Define macro to assist in building transfer vector entries. Each entry
161 ; should take no more than 8 bytes.
163 .MACRO FTRANSFER_ENTRY routine
168 .ENDM FTRANSFER_ENTRY
170 ; Place entries in own program section.
172 $ write mar " .PSECT $$",libvec,",QUAD,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT"
173 $ write mar libvec,"_xfer:"
175 $ libwriter := write_vax_ftransfer_entry
176 $ gosub read_func_num
177 $ type sys$input:/out=mar:
179 ; Allocate extra storage at end of vector to allow for expansion.
181 $ write mar " .BLKB 32768-<.-",libvec,"_xfer> ; 64 pages total."
182 $! libwriter := write_vax_vtransfer_entry
183 $! gosub read_func_num
186 $ open/write opt 'libopt'
187 $ write opt "identification=""",libid," ",libverstr,""""
189 $ write opt libolb,"/lib"
190 $ if libref .nes. "" then write opt libref,"/SHARE"
191 $ type sys$input:/out=opt:
193 ! Ensure transfer vector is at beginning of image
196 $ write opt "COLLECT=FIRST,$$",libvec
197 $ write opt "GSMATCH=",libvmatch,",",libver
198 $ type sys$input:/out=opt:
200 ! make psects nonshareable so image can be installed.
202 PSECT_ATTR=$CHAR_STRING_CONSTANTS,NOWRT
204 $ libwriter := write_vax_psect_attr
205 $ gosub read_func_num
207 $ macro/obj='libobj' 'libmar'
208 $ link/map='libmap'/full/share='libgoal' 'libopt'/option
211 $! The record writer routine for VAX functions
212 $ write_vax_ftransfer_entry:
213 $ if info_kind .nes. "FUNCTION" then return
214 $ if libentry .eqs ".dummy"
216 $ write 'libwrch' " .BLKB 8" ! Dummy is zeroes...
218 $ write 'libwrch' " FTRANSFER_ENTRY ",libentry
221 $! The record writer routine for VAX variables (should never happen!)
222 $ write_vax_psect_attr:
223 $ if info_kind .nes. "VARIABLE" then return
224 $ if libentry .eqs ".dummy" then return
225 $ write 'libwrch' "PSECT_ATTR=",libentry,",NOSHR"
228 $! ----- Common subroutines
230 $! The .num file reader. This one has great responsability.
232 $ open libnum 'libnum'
237 $ liblastentry:=false
240 $ read/end=loop_end/err=loop_end libnum line
241 $ entrynum=f$int(f$element(1," ",f$edit(line,"COMPRESS,TRIM")))
242 $ entryinfo=f$element(2," ",f$edit(line,"COMPRESS,TRIM"))
243 $ curentry=f$element(0," ",f$edit(line,"COMPRESS,TRIM"))
244 $ info_exist=f$element(0,":",entryinfo)
245 $ info_platforms=","+f$element(1,":",entryinfo)+","
246 $ info_kind=f$element(2,":",entryinfo)
247 $ info_algorithms=","+f$element(3,":",entryinfo)+","
248 $ if info_exist .eqs. "NOEXIST" then goto loop
254 $ plat_entry = f$element(plat_i,",",info_platforms)
255 $ plat_i = plat_i + 1
256 $ if plat_entry .eqs. "" then goto loop1
257 $ if plat_entry .nes. ","
259 $ if f$extract(0,1,plat_entry) .nes. "!" then negatives = 0
260 $ if f$getsyi("CPU") .lt. 128
262 $ if plat_entry .eqs. "EXPORT_VAR_AS_FUNCTION" then -
263 $ truesum = truesum + 1
264 $ if plat_entry .eqs. "!EXPORT_VAR_AS_FUNCTION" then -
265 $ falsesum = falsesum + 1
267 $ if plat_entry .eqs. "VMS" then truesum = truesum + 1
268 $ if plat_entry .eqs. "!VMS" then falsesum = falsesum + 1
272 $!DEBUG!$ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
274 $!DEBUG!$ write sys$output line
275 $!DEBUG!$ write sys$output " truesum = ",truesum,-
276 $!DEBUG! ", negatives = ",negatives,", falsesum = ",falsesum
278 $ if falsesum .ne. 0 then goto loop
279 $ if truesum+negatives .eq. 0 then goto loop
282 $ alg_entry = f$element(alg_i,",",info_algorithms)
284 $ if alg_entry .eqs. "" then goto loop2
285 $ if alg_entry .nes. ","
287 $ if alg_entry .eqs. "KRB5" then goto loop ! Special for now
288 $ if alg_entry .eqs. "STATIC_ENGINE" then goto loop ! Special for now
289 $ if f$trnlnm("OPENSSL_NO_"+alg_entry) .nes. "" then goto loop
293 $ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
295 $!DEBUG!$ write sys$output curentry," ; ",entrynum," ; ",entryinfo
299 $ tolibentry=curentry
300 $ if libentrynum .ne. entrynum
302 $ entrycount=entrycount+1
303 $ if entrycount .lt. entrynum
305 $!DEBUG!$ write sys$output "Info: entrycount: ''entrycount', entrynum: ''entrynum' => 0"
306 $ tolibentry=".dummy"
309 $ if entrycount .gt. entrynum
311 $ write sys$error "Decreasing library entry numbers! Can't continue"
312 $ write sys$error """",line,""""
316 $ libentry=tolibentry
317 $!DEBUG!$ write sys$output entrycount," ",libentry," ",entryinfo
318 $ if libentry .nes. "" .and. libwriter .nes. "" then gosub 'libwriter'
320 $ write sys$error "Info: ""''curentry'"" is an alias for ""''libentry'"". Overriding..."
322 $ libentrynum=entrycount
328 $! The version number reader
331 $ open/read vf [.CRYPTO]OPENSSLV.H
333 $ read/err=endloop_rvi/end=endloop_rvi vf rvi_line
334 $ if rvi_line - "SHLIB_VERSION_NUMBER """ .eqs. rvi_line then -
336 $ libverstr = f$element(1,"""",rvi_line)
337 $ libvmajor = f$element(0,".",libverstr)
338 $ libvminor = f$element(1,".",libverstr)
339 $ libvedit = f$element(2,".",libverstr)
340 $ libvpatch = f$cvui(0,8,f$extract(1,1,libvedit)+"@")-f$cvui(0,8,"@")
341 $ libvedit = f$extract(0,1,libvedit)
342 $ libver = f$string(f$int(libvmajor)*100)+","+-
343 f$string(f$int(libvminor)*100+f$int(libvedit)*10+f$int(libvpatch))
344 $ if libvmajor .eqs. "0"
346 $ libvmatch = "EQUAL"
348 $ ! Starting with the 1.0 release, backward compatibility should be
349 $ ! kept, so switch over to the following
350 $ libvmatch = "LEQUAL"