1 $! MKSHARED.COM -- Create shareable images.
3 $! P1: "64" for 64-bit pointers.
5 $! P2: Zlib object library path (optional).
7 $! Input: [.UTIL]LIBEAY.NUM,[.xxx.EXE.CRYPTO]SSL_LIBCRYPTO[32].OLB
8 $! [.UTIL]SSLEAY.NUM,[.xxx.EXE.SSL]SSL_LIBSSL[32].OLB
9 $! Output: [.xxx.EXE.CRYPTO]SSL_LIBCRYPTO_SHR[32].OPT,.MAP,.EXE
10 $! [.xxx.EXE.SSL]SSL_LIBSSL_SRH[32].OPT,.MAP,.EXE
12 $! So far, tests have only been made on VMS for Alpha. VAX will come in time.
13 $! ===========================================================================
17 $ proc = f$environment( "procedure")
18 $ write sys$output "@@@ "+ -
19 f$parse( proc, , , "name")+ f$parse( proc, , , "type")
21 $! Save the original default device:[directory].
23 $ def_orig = f$environment( "default")
24 $ on error then goto tidy
25 $ on control_c then goto tidy
27 $! SET DEFAULT to the main kit directory.
29 $ proc = f$environment("procedure")
30 $ proc = f$parse( "A.;", proc)- "A.;"
34 $! ----- Prepare info for processing: version number and file info
35 $ gosub read_version_info
38 $ write sys$error "ERROR: Couldn't find any library version info..."
42 $ if (f$getsyi("cpu") .lt. 128)
48 $ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
49 $ if (arch .eqs. "") then arch = "UNK"
66 $ write sys$output "Second argument invalid."
67 $ write sys$output "It should be "32", "64", or nothing."
77 $ file2 = f$parse( ZLIB, "libz.olb", , , "syntax_only")
78 $ if (f$search( file2) .eqs. "")
81 $ write sys$output "The Option ", ZLIB, " Is Invalid."
82 $ write sys$output " Can't find library: ''file2'"
86 $ zlib_lib = ", ''file2' /library"
91 $ libtit = "CRYPTO_TRANSFER_VECTOR"
93 $ libnum = "[.UTIL]LIBEAY.NUM"
94 $ libdir = "[.''ARCHD'.EXE.CRYPTO]"
95 $ libmar = "''libdir'SSL_LIBCRYPTO_''shr'.MAR"
96 $ libolb = "''libdir'SSL_LIBCRYPTO''lib32'.OLB"
97 $ libopt = "''libdir'SSL_LIBCRYPTO_''shr'.OPT"
98 $ libobj = "''libdir'SSL_LIBCRYPTO_''shr'.OBJ"
99 $ libmap = "''libdir'SSL_LIBCRYPTO_''shr'.MAP"
100 $ libgoal= "''libdir'SSL_LIBCRYPTO_''shr'.EXE"
102 $ libvec = "LIBCRYPTO"
103 $ if f$search( libolb) .nes. "" then gosub create_vax_shr
104 $ libtit = "SSL_TRANSFER_VECTOR"
106 $ libnum = "[.UTIL]SSLEAY.NUM"
107 $ libdir = "[.''ARCHD'.EXE.SSL]"
108 $ libmar = "''libdir'SSL_LIBSSL_''shr'.MAR"
109 $ libolb = "''libdir'SSL_LIBSSL''lib32'.OLB"
110 $ libopt = "''libdir'SSL_LIBSSL_''shr'.OPT"
111 $ libobj = "''libdir'SSL_LIBSSL_''shr'.OBJ"
112 $ libmap = "''libdir'SSL_LIBSSL_''shr'.MAP"
113 $ libgoal= "''libdir'SSL_LIBSSL_''shr'.EXE"
114 $ libref = "[.''ARCHD'.EXE.CRYPTO]SSL_LIBCRYPTO_''shr'.EXE"
116 $ if f$search( libolb) .nes. "" then gosub create_vax_shr
119 $ libnum = "[.UTIL]LIBEAY.NUM"
120 $ libdir = "[.''ARCHD'.EXE.CRYPTO]"
121 $ libolb = "''libdir'SSL_LIBCRYPTO''lib32'.OLB"
122 $ libopt = "''libdir'SSL_LIBCRYPTO_''shr'.OPT"
123 $ libmap = "''libdir'SSL_LIBCRYPTO_''shr'.MAP"
124 $ libgoal= "''libdir'SSL_LIBCRYPTO_''shr'.EXE"
126 $ if f$search( libolb) .nes. "" then gosub create_nonvax_shr
128 $ libnum = "[.UTIL]SSLEAY.NUM"
129 $ libdir = "[.''ARCHD'.EXE.SSL]"
130 $ libolb = "''libdir'SSL_LIBSSL''lib32'.OLB"
131 $ libopt = "''libdir'SSL_LIBSSL_''shr'.OPT"
132 $ libmap = "''libdir'SSL_LIBSSL_''shr'.MAP"
133 $ libgoal= "''libdir'SSL_LIBSSL_''shr'.EXE"
134 $ libref = "[.''ARCHD'.EXE.CRYPTO]SSL_LIBCRYPTO_''shr'.EXE"
135 $ if f$search( libolb) .nes. "" then gosub create_nonvax_shr
140 $! Close any open files.
142 $ if (f$trnlnm( "libnum", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
145 $ if (f$trnlnm( "mar", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
148 $ if (f$trnlnm( "opt", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
151 $ if (f$trnlnm( "vf", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
154 $! Restore the original default device:[directory].
156 $ set default 'def_orig'
159 $! ----- Subroutines to build the shareable libraries
160 $! For each supported architecture, there's a main shareable library
161 $! creator, which is called from the main code above.
162 $! The creator will define a number of variables to tell the next levels of
163 $! subroutines what routines to use to write to the option files, call the
164 $! main processor, read_func_num, and when that is done, it will write version
165 $! data at the end of the .opt file, close it, and link the library.
167 $! read_func_num reads through a .num file and calls the writer routine for
168 $! each line. It's also responsible for checking that order is properly kept
169 $! in the .num file, check that each line applies to VMS and the architecture,
170 $! and to fill in "holes" with dummy entries.
172 $! The creator routines depend on the following variables:
173 $! libnum The name of the .num file to use as input
174 $! libolb The name of the object library to build from
175 $! libid The identification string of the shareable library
176 $! libopt The name of the .opt file to write
177 $! libtit The title of the assembler transfer vector file (VAX only)
178 $! libmar The name of the assembler transfer vector file (VAX only)
179 $! libmap The name of the map file to write
180 $! libgoal The name of the shareable library to write
181 $! libref The name of a shareable library to link in
183 $! read_func_num depends on the following variables from the creator:
184 $! libwriter The name of the writer routine to call for each .num file line
187 $! ----- Subroutines for non-VAX
189 $! The creator routine
191 $ open /write opt 'libopt'
192 $ write opt "identification=""",libid," ",libverstr,""""
193 $ write opt libolb, " /library"
194 $ if libref .nes. "" then write opt libref,"/SHARE"
195 $ write opt "SYMBOL_VECTOR=(-"
196 $ libfirstentry := true
198 $ libwriter := write_nonvax_transfer_entry
200 $ gosub read_func_num
202 $ write opt "GSMATCH=",libvmatch,",",libver
204 $ link /map = 'libmap' /full /share = 'libgoal' 'libopt' /options -
208 $! The record writer routine
209 $ write_nonvax_transfer_entry:
210 $ if libentry .eqs. ".dummy" then return
211 $ if info_kind .eqs. "VARIABLE"
217 $ textcount_this = f$length(pr) + f$length(libentry) + 5
218 $ if textcount + textcount_this .gt. 1024
221 $ write opt "SYMBOL_VECTOR=(-"
223 $ libfirstentry := true
227 $ write 'libwrch' " ",libentry,"=",pr," -"
229 $ write 'libwrch' " ,",libentry,"=",pr," -"
231 $ libfirstentry := false
232 $ textcount = textcount + textcount_this
235 $! ----- Subroutines for VAX
237 $! The creator routine
239 $ open /write mar 'libmar'
240 $ type sys$input:/out=mar:
242 ; Transfer vector for VAX shareable image
244 $ write mar " .TITLE ",libtit
245 $ write mar " .IDENT /",libid,"/"
246 $ type sys$input:/out=mar:
248 ; Define macro to assist in building transfer vector entries. Each entry
249 ; should take no more than 8 bytes.
251 .MACRO FTRANSFER_ENTRY routine
256 .ENDM FTRANSFER_ENTRY
258 ; Place entries in own program section.
260 $ write mar " .PSECT $$",libvec,",QUAD,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT"
261 $ write mar libvec,"_xfer:"
263 $ libwriter := write_vax_ftransfer_entry
264 $ gosub read_func_num
265 $ type sys$input:/out=mar:
267 ; Allocate extra storage at end of vector to allow for expansion.
269 $ write mar " .BLKB 32768-<.-",libvec,"_xfer> ; 64 pages total."
270 $! libwriter := write_vax_vtransfer_entry
271 $! gosub read_func_num
274 $ open /write opt 'libopt'
275 $ write opt "identification=""",libid," ",libverstr,""""
277 $ write opt libolb, " /library"
278 $ if libref .nes. "" then write opt libref,"/SHARE"
279 $ type sys$input:/out=opt:
281 ! Ensure transfer vector is at beginning of image
284 $ write opt "COLLECT=FIRST,$$",libvec
285 $ write opt "GSMATCH=",libvmatch,",",libver
286 $ type sys$input:/out=opt:
288 ! make psects nonshareable so image can be installed.
290 PSECT_ATTR=$CHAR_STRING_CONSTANTS,NOWRT
292 $ libwriter := write_vax_psect_attr
293 $ gosub read_func_num
295 $ macro/obj='libobj' 'libmar'
296 $ link /map = 'libmap' /full /share = 'libgoal' 'libopt' /options -
300 $! The record writer routine for VAX functions
301 $ write_vax_ftransfer_entry:
302 $ if info_kind .nes. "FUNCTION" then return
303 $ if libentry .eqs ".dummy"
305 $ write 'libwrch' " .BLKB 8" ! Dummy is zeroes...
307 $ write 'libwrch' " FTRANSFER_ENTRY ",libentry
310 $! The record writer routine for VAX variables (should never happen!)
311 $ write_vax_psect_attr:
312 $ if info_kind .nes. "VARIABLE" then return
313 $ if libentry .eqs ".dummy" then return
314 $ write 'libwrch' "PSECT_ATTR=",libentry,",NOSHR"
317 $! ----- Common subroutines
319 $! The .num file reader. This one has great responsibility.
321 $ open /read libnum 'libnum'
326 $ liblastentry:=false
329 $ read /end=loop_end /err=loop_end libnum line
330 $ lin = f$edit( line, "COMPRESS,TRIM")
331 $! Skip a "#" comment line.
332 $ if (f$extract( 0, 1, lin) .eqs. "#") then goto loop
333 $ entrynum = f$int(f$element( 1, " ", lin))
334 $ entryinfo = f$element( 2, " ", lin)
335 $ curentry = f$element( 0, " ", lin)
336 $ info_exist = f$element( 0, ":", entryinfo)
337 $ info_platforms = ","+ f$element(1, ":", entryinfo)+ ","
338 $ info_kind = f$element( 2, ":", entryinfo)
339 $ info_algorithms = ","+ f$element( 3, ":", entryinfo)+ ","
340 $ if info_exist .eqs. "NOEXIST" then goto loop
346 $ plat_entry = f$element( plat_i, ",", info_platforms)
347 $ plat_i = plat_i + 1
348 $ if plat_entry .eqs. "" then goto loop1
349 $ if plat_entry .nes. ","
351 $ if f$extract(0,1,plat_entry) .nes. "!" then negatives = 0
354 $ if plat_entry .eqs. "EXPORT_VAR_AS_FUNCTION" then -
355 $ truesum = truesum + 1
356 $ if plat_entry .eqs. "!EXPORT_VAR_AS_FUNCTION" then -
357 $ falsesum = falsesum + 1
360 $ if ((plat_entry .eqs. "VMS") .or. -
361 ((plat_entry .eqs. "ZLIB") .and. (ZLIB .nes. "")) .or. -
362 (arch_vax .and. (plat_entry .eqs. "VMSVAX"))) then -
363 truesum = truesum + 1
365 $ if ((plat_entry .eqs. "!VMS") .or. -
366 (arch_vax .and. (plat_entry .eqs. "!VMSVAX"))) then -
367 falsesum = falsesum + 1
372 $!DEBUG!$ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
374 $!DEBUG!$ write sys$output line
375 $!DEBUG!$ write sys$output " truesum = ",truesum,-
376 $!DEBUG! ", negatives = ",negatives,", falsesum = ",falsesum
378 $ if falsesum .ne. 0 then goto loop
379 $ if truesum+negatives .eq. 0 then goto loop
382 $ alg_entry = f$element(alg_i,",",info_algorithms)
384 $ if alg_entry .eqs. "" then goto loop2
385 $ if alg_entry .nes. ","
387 $ if alg_entry .eqs. "KRB5" then goto loop ! Special for now
388 $ if alg_entry .eqs. "STATIC_ENGINE" then goto loop ! Special for now
389 $ if f$trnlnm("OPENSSL_NO_"+alg_entry) .nes. "" then goto loop
393 $ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
395 $!DEBUG!$ write sys$output curentry," ; ",entrynum," ; ",entryinfo
399 $ tolibentry=curentry
400 $ if libentrynum .ne. entrynum
402 $ entrycount=entrycount+1
403 $ if entrycount .lt. entrynum
405 $!DEBUG!$ write sys$output "Info: entrycount: ''entrycount', entrynum: ''entrynum' => 0"
406 $ tolibentry=".dummy"
409 $ if entrycount .gt. entrynum
411 $ write sys$error "Decreasing library entry numbers! Can't continue"
412 $ write sys$error """",line,""""
416 $ libentry=tolibentry
417 $!DEBUG!$ write sys$output entrycount," ",libentry," ",entryinfo
418 $ if libentry .nes. "" .and. libwriter .nes. "" then gosub 'libwriter'
420 $ write sys$error "Info: ""''curentry'"" is an alias for ""''libentry'"". Overriding..."
422 $ libentrynum=entrycount
428 $! The version number reader
431 $ open /read vf [.CRYPTO]OPENSSLV.H
433 $ read/err=endloop_rvi/end=endloop_rvi vf rvi_line
434 $ if rvi_line - "SHLIB_VERSION_NUMBER """ .eqs. rvi_line then -
436 $ libverstr = f$element(1,"""",rvi_line)
437 $ libvmajor = f$element(0,".",libverstr)
438 $ libvminor = f$element(1,".",libverstr)
439 $ libvedit = f$element(2,".",libverstr)
440 $ libvpatch = f$cvui(0,8,f$extract(1,1,libvedit)+"@")-f$cvui(0,8,"@")
441 $ libvedit = f$extract(0,1,libvedit)
442 $ libver = f$string(f$int(libvmajor)*100)+","+-
443 f$string(f$int(libvminor)*100+f$int(libvedit)*10+f$int(libvpatch))
444 $ if libvmajor .eqs. "0"
446 $ libvmatch = "EQUAL"
448 $ ! Starting with the 1.0 release, backward compatibility should be
449 $ ! kept, so switch over to the following
450 $ libvmatch = "LEQUAL"