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,[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB
7 $! [.UTIL]SSLEAY.NUM,[.xxx.EXE.SSL]LIBSSL.OLB
8 $! Output: [.xxx.EXE.CRYPTO]LIBCRYPTO.OPT,.MAP,.EXE
9 $! [.xxx.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").lt.128)
26 $ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
27 $ if (arch .eqs. "") then arch = "UNK"
34 $ libnum = "[.UTIL]LIBEAY.NUM"
35 $ libdir = "[.''ARCH'.EXE.CRYPTO]"
36 $ libolb = "''libdir'LIBCRYPTO.OLB"
37 $ libopt = "''libdir'LIBCRYPTO.OPT"
38 $ libmap = "''libdir'LIBCRYPTO.MAP"
39 $ libgoal= "''libdir'LIBCRYPTO.EXE"
41 $ if f$search(libdir+libolb) .nes. "" then gosub create_nonvax_shr
43 $ libnum = "[.UTIL]SSLEAY.NUM"
44 $ libdir = "[.''ARCH'.EXE.SSL]"
45 $ libolb = "''libdir'LIBSSL.OLB"
46 $ libopt = "''libdir'LIBSSL.OPT"
47 $ libmap = "''libdir'LIBSSL.MAP"
48 $ libgoal= "''libdir'LIBSSL.EXE"
49 $ libref = "[.''ARCH'.EXE.CRYPTO]LIBCRYPTO.EXE"
50 $ if f$search(libdir+libolb) .nes. "" then gosub create_nonvax_shr
53 $ libnum = "[.UTIL]LIBEAY.NUM"
54 $ libdir = "[.''ARCH'.EXE.CRYPTO]"
55 $ libolb = "''libdir'LIBCRYPTO32.OLB"
56 $ libopt = "''libdir'LIBCRYPTO32.OPT"
57 $ libmap = "''libdir'LIBCRYPTO32.MAP"
58 $ libgoal= "''libdir'LIBCRYPTO32.EXE"
60 $ if f$search(libdir+libolb) .nes. "" then gosub create_nonvax_shr
62 $ libnum = "[.UTIL]SSLEAY.NUM"
63 $ libdir = "[.''ARCH'.EXE.SSL]"
64 $ libolb = "''libdir'LIBSSL32.OLB"
65 $ libopt = "''libdir'LIBSSL32.OPT"
66 $ libmap = "''libdir'LIBSSL32.MAP"
67 $ libgoal= "''libdir'LIBSSL32.EXE"
68 $ libref = "[.''ARCH'.EXE.CRYPTO]LIBCRYPTO32.EXE"
69 $ if f$search(libdir+libolb) .nes. "" then gosub create_nonvax_shr
72 $ libtit = "CRYPTO_TRANSFER_VECTOR"
74 $ libnum = "[.UTIL]LIBEAY.NUM"
75 $ libdir = "[.''ARCH'.EXE.CRYPTO]"
76 $ libmar = "''libdir'LIBCRYPTO.MAR"
77 $ libolb = "''libdir'LIBCRYPTO.OLB"
78 $ libopt = "''libdir'LIBCRYPTO.OPT"
79 $ libobj = "''libdir'LIBCRYPTO.OBJ"
80 $ libmap = "''libdir'LIBCRYPTO.MAP"
81 $ libgoal= "''libdir'LIBCRYPTO.EXE"
83 $ libvec = "LIBCRYPTO"
84 $ if f$search(libdir+libolb) .nes. "" then gosub create_vax_shr
85 $ libtit = "SSL_TRANSFER_VECTOR"
87 $ libnum = "[.UTIL]SSLEAY.NUM"
88 $ libdir = "[.''ARCH'.EXE.SSL]"
89 $ libmar = "''libdir'LIBSSL.MAR"
90 $ libolb = "''libdir'LIBSSL.OLB"
91 $ libopt = "''libdir'LIBSSL.OPT"
92 $ libobj = "''libdir'LIBSSL.OBJ"
93 $ libmap = "''libdir'LIBSSL.MAP"
94 $ libgoal= "''libdir'LIBSSL.EXE"
95 $ libref = "[.''ARCH'.EXE.CRYPTO]LIBCRYPTO.EXE"
97 $ if f$search(libdir+libolb) .nes. "" then gosub create_vax_shr
101 $! ----- Subroutines to build the shareable libraries
102 $! For each supported architecture, there's a main shareable library
103 $! creator, which is called from the main code above.
104 $! The creator will define a number of variables to tell the next levels of
105 $! subroutines what routines to use to write to the option files, call the
106 $! main processor, read_func_num, and when that is done, it will write version
107 $! data at the end of the .opt file, close it, and link the library.
109 $! read_func_num reads through a .num file and calls the writer routine for
110 $! each line. It's also responsible for checking that order is properly kept
111 $! in the .num file, check that each line applies to VMS and the architecture,
112 $! and to fill in "holes" with dummy entries.
114 $! The creator routines depend on the following variables:
115 $! libnum The name of the .num file to use as input
116 $! libolb The name of the object library to build from
117 $! libid The identification string of the shareable library
118 $! libopt The name of the .opt file to write
119 $! libtit The title of the assembler transfer vector file (VAX only)
120 $! libmar The name of the assembler transfer vector file (VAX only)
121 $! libmap The name of the map file to write
122 $! libgoal The name of the shareable library to write
123 $! libref The name of a shareable library to link in
125 $! read_func_num depends on the following variables from the creator:
126 $! libwriter The name of the writer routine to call for each .num file line
129 $! ----- Subroutines for non-VAX
131 $! The creator routine
133 $ open/write opt 'libopt'
134 $ write opt "identification=""",libid," ",libverstr,""""
135 $ write opt libolb,"/lib"
136 $ if libref .nes. "" then write opt libref,"/SHARE"
137 $ write opt "SYMBOL_VECTOR=(-"
138 $ libfirstentry := true
140 $ libwriter := write_nonvax_transfer_entry
142 $ gosub read_func_num
144 $ write opt "GSMATCH=",libvmatch,",",libver
146 $ link/map='libmap'/full/share='libgoal' 'libopt'/option
149 $! The record writer routine
150 $ write_nonvax_transfer_entry:
151 $ if libentry .eqs. ".dummy" then return
152 $ if info_kind .eqs. "VARIABLE"
158 $ textcount_this = f$length(pr) + f$length(libentry) + 5
159 $ if textcount + textcount_this .gt. 1024
162 $ write opt "SYMBOL_VECTOR=(-"
164 $ libfirstentry := true
168 $ write 'libwrch' " ",libentry,"=",pr," -"
170 $ write 'libwrch' " ,",libentry,"=",pr," -"
172 $ libfirstentry := false
173 $ textcount = textcount + textcount_this
176 $! ----- Subroutines for VAX
178 $! The creator routine
180 $ open/write mar 'libmar'
181 $ type sys$input:/out=mar:
183 ; Transfer vector for VAX shareable image
185 $ write mar " .TITLE ",libtit
186 $ write mar " .IDENT /",libid,"/"
187 $ type sys$input:/out=mar:
189 ; Define macro to assist in building transfer vector entries. Each entry
190 ; should take no more than 8 bytes.
192 .MACRO FTRANSFER_ENTRY routine
197 .ENDM FTRANSFER_ENTRY
199 ; Place entries in own program section.
201 $ write mar " .PSECT $$",libvec,",QUAD,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT"
202 $ write mar libvec,"_xfer:"
204 $ libwriter := write_vax_ftransfer_entry
205 $ gosub read_func_num
206 $ type sys$input:/out=mar:
208 ; Allocate extra storage at end of vector to allow for expansion.
210 $ write mar " .BLKB 32768-<.-",libvec,"_xfer> ; 64 pages total."
211 $! libwriter := write_vax_vtransfer_entry
212 $! gosub read_func_num
215 $ open/write opt 'libopt'
216 $ write opt "identification=""",libid," ",libverstr,""""
218 $ write opt libolb,"/lib"
219 $ if libref .nes. "" then write opt libref,"/SHARE"
220 $ type sys$input:/out=opt:
222 ! Ensure transfer vector is at beginning of image
225 $ write opt "COLLECT=FIRST,$$",libvec
226 $ write opt "GSMATCH=",libvmatch,",",libver
227 $ type sys$input:/out=opt:
229 ! make psects nonshareable so image can be installed.
231 PSECT_ATTR=$CHAR_STRING_CONSTANTS,NOWRT
233 $ libwriter := write_vax_psect_attr
234 $ gosub read_func_num
236 $ macro/obj='libobj' 'libmar'
237 $ link/map='libmap'/full/share='libgoal' 'libopt'/option
240 $! The record writer routine for VAX functions
241 $ write_vax_ftransfer_entry:
242 $ if info_kind .nes. "FUNCTION" then return
243 $ if libentry .eqs ".dummy"
245 $ write 'libwrch' " .BLKB 8" ! Dummy is zeroes...
247 $ write 'libwrch' " FTRANSFER_ENTRY ",libentry
250 $! The record writer routine for VAX variables (should never happen!)
251 $ write_vax_psect_attr:
252 $ if info_kind .nes. "VARIABLE" then return
253 $ if libentry .eqs ".dummy" then return
254 $ write 'libwrch' "PSECT_ATTR=",libentry,",NOSHR"
257 $! ----- Common subroutines
259 $! The .num file reader. This one has great responsability.
261 $ open libnum 'libnum'
266 $ liblastentry:=false
269 $ read/end=loop_end/err=loop_end libnum line
270 $ entrynum=f$int(f$element(1," ",f$edit(line,"COMPRESS,TRIM")))
271 $ entryinfo=f$element(2," ",f$edit(line,"COMPRESS,TRIM"))
272 $ curentry=f$element(0," ",f$edit(line,"COMPRESS,TRIM"))
273 $ info_exist=f$element(0,":",entryinfo)
274 $ info_platforms=","+f$element(1,":",entryinfo)+","
275 $ info_kind=f$element(2,":",entryinfo)
276 $ info_algorithms=","+f$element(3,":",entryinfo)+","
277 $ if info_exist .eqs. "NOEXIST" then goto loop
283 $ plat_entry = f$element(plat_i,",",info_platforms)
284 $ plat_i = plat_i + 1
285 $ if plat_entry .eqs. "" then goto loop1
286 $ if plat_entry .nes. ","
288 $ if f$extract(0,1,plat_entry) .nes. "!" then negatives = 0
289 $ if f$getsyi("CPU") .lt. 128
291 $ if plat_entry .eqs. "EXPORT_VAR_AS_FUNCTION" then -
292 $ truesum = truesum + 1
293 $ if plat_entry .eqs. "!EXPORT_VAR_AS_FUNCTION" then -
294 $ falsesum = falsesum + 1
297 $ if ((plat_entry .eqs. "VMS") .or. -
298 (arch_vax .and. (plat_entry .eqs. "VMSVAX"))) then -
299 truesum = truesum + 1
301 $ if ((plat_entry .eqs. "!VMS") .or. -
302 (arch_vax .and. (plat_entry .eqs. "!VMSVAX"))) then -
303 falsesum = falsesum + 1
308 $!DEBUG!$ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
310 $!DEBUG!$ write sys$output line
311 $!DEBUG!$ write sys$output " truesum = ",truesum,-
312 $!DEBUG! ", negatives = ",negatives,", falsesum = ",falsesum
314 $ if falsesum .ne. 0 then goto loop
315 $ if truesum+negatives .eq. 0 then goto loop
318 $ alg_entry = f$element(alg_i,",",info_algorithms)
320 $ if alg_entry .eqs. "" then goto loop2
321 $ if alg_entry .nes. ","
323 $ if alg_entry .eqs. "KRB5" then goto loop ! Special for now
324 $ if alg_entry .eqs. "STATIC_ENGINE" then goto loop ! Special for now
325 $ if f$trnlnm("OPENSSL_NO_"+alg_entry) .nes. "" then goto loop
329 $ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
331 $!DEBUG!$ write sys$output curentry," ; ",entrynum," ; ",entryinfo
335 $ tolibentry=curentry
336 $ if libentrynum .ne. entrynum
338 $ entrycount=entrycount+1
339 $ if entrycount .lt. entrynum
341 $!DEBUG!$ write sys$output "Info: entrycount: ''entrycount', entrynum: ''entrynum' => 0"
342 $ tolibentry=".dummy"
345 $ if entrycount .gt. entrynum
347 $ write sys$error "Decreasing library entry numbers! Can't continue"
348 $ write sys$error """",line,""""
352 $ libentry=tolibentry
353 $!DEBUG!$ write sys$output entrycount," ",libentry," ",entryinfo
354 $ if libentry .nes. "" .and. libwriter .nes. "" then gosub 'libwriter'
356 $ write sys$error "Info: ""''curentry'"" is an alias for ""''libentry'"". Overriding..."
358 $ libentrynum=entrycount
364 $! The version number reader
367 $ open/read vf [.CRYPTO]OPENSSLV.H
369 $ read/err=endloop_rvi/end=endloop_rvi vf rvi_line
370 $ if rvi_line - "SHLIB_VERSION_NUMBER """ .eqs. rvi_line then -
372 $ libverstr = f$element(1,"""",rvi_line)
373 $ libvmajor = f$element(0,".",libverstr)
374 $ libvminor = f$element(1,".",libverstr)
375 $ libvedit = f$element(2,".",libverstr)
376 $ libvpatch = f$cvui(0,8,f$extract(1,1,libvedit)+"@")-f$cvui(0,8,"@")
377 $ libvedit = f$extract(0,1,libvedit)
378 $ libver = f$string(f$int(libvmajor)*100)+","+-
379 f$string(f$int(libvminor)*100+f$int(libvedit)*10+f$int(libvpatch))
380 $ if libvmajor .eqs. "0"
382 $ libvmatch = "EQUAL"
384 $ ! Starting with the 1.0 release, backward compatibility should be
385 $ ! kept, so switch over to the following
386 $ libvmatch = "LEQUAL"