mkshared.com 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. $! MKSHARED.COM -- Create shareable images.
  2. $!
  3. $! P1: "64" for 64-bit pointers.
  4. $!
  5. $! P2: Zlib object library path (optional).
  6. $!
  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
  11. $!
  12. $! So far, tests have only been made on VMS for Alpha. VAX will come in time.
  13. $! ===========================================================================
  14. $!
  15. $! Announce/identify.
  16. $!
  17. $ proc = f$environment( "procedure")
  18. $ write sys$output "@@@ "+ -
  19. f$parse( proc, , , "name")+ f$parse( proc, , , "type")
  20. $!
  21. $! Save the original default device:[directory].
  22. $!
  23. $ def_orig = f$environment( "default")
  24. $ on error then goto tidy
  25. $ on control_c then goto tidy
  26. $!
  27. $! SET DEFAULT to the main kit directory.
  28. $!
  29. $ proc = f$environment("procedure")
  30. $ proc = f$parse( "A.;", proc)- "A.;"
  31. $ set default 'proc'
  32. $ set default [-]
  33. $!
  34. $! ----- Prepare info for processing: version number and file info
  35. $ gosub read_version_info
  36. $ if libver .eqs. ""
  37. $ then
  38. $ write sys$error "ERROR: Couldn't find any library version info..."
  39. $ go to tidy:
  40. $ endif
  41. $
  42. $ if (f$getsyi("cpu") .lt. 128)
  43. $ then
  44. $ arch_vax = 1
  45. $ arch = "VAX"
  46. $ else
  47. $ arch_vax = 0
  48. $ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
  49. $ if (arch .eqs. "") then arch = "UNK"
  50. $ endif
  51. $!
  52. $ archd = arch
  53. $ lib32 = "32"
  54. $ shr = "SHR32"
  55. $!
  56. $ if (p1 .nes. "")
  57. $ then
  58. $ if (p1 .eqs. "64")
  59. $ then
  60. $ archd = arch+ "_64"
  61. $ lib32 = ""
  62. $ shr = "SHR"
  63. $ else
  64. $ if (p1 .nes. "32")
  65. $ then
  66. $ write sys$output "Second argument invalid."
  67. $ write sys$output "It should be "32", "64", or nothing."
  68. $ exit
  69. $ endif
  70. $ endif
  71. $ endif
  72. $!
  73. $ ZLIB = p2
  74. $ zlib_lib = ""
  75. $ if (ZLIB .nes. "")
  76. $ then
  77. $ file2 = f$parse( ZLIB, "libz.olb", , , "syntax_only")
  78. $ if (f$search( file2) .eqs. "")
  79. $ then
  80. $ write sys$output ""
  81. $ write sys$output "The Option ", ZLIB, " Is Invalid."
  82. $ write sys$output " Can't find library: ''file2'"
  83. $ write sys$output ""
  84. $ goto tidy
  85. $ endif
  86. $ zlib_lib = ", ''file2' /library"
  87. $ endif
  88. $!
  89. $ if (arch_vax)
  90. $ then
  91. $ libtit = "CRYPTO_TRANSFER_VECTOR"
  92. $ libid = "Crypto"
  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"
  101. $ libref = ""
  102. $ libvec = "LIBCRYPTO"
  103. $ if f$search( libolb) .nes. "" then gosub create_vax_shr
  104. $ libtit = "SSL_TRANSFER_VECTOR"
  105. $ libid = "SSL"
  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"
  115. $ libvec = "LIBSSL"
  116. $ if f$search( libolb) .nes. "" then gosub create_vax_shr
  117. $ else
  118. $ libid = "Crypto"
  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"
  125. $ libref = ""
  126. $ if f$search( libolb) .nes. "" then gosub create_nonvax_shr
  127. $ libid = "SSL"
  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
  136. $ endif
  137. $!
  138. $ tidy:
  139. $!
  140. $! Close any open files.
  141. $!
  142. $ if (f$trnlnm( "libnum", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
  143. close libnum
  144. $!
  145. $ if (f$trnlnm( "mar", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
  146. close mar
  147. $!
  148. $ if (f$trnlnm( "opt", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
  149. close opt
  150. $!
  151. $ if (f$trnlnm( "vf", "LNM$PROCESS", 0, "SUPERVISOR") .nes. "") then -
  152. close vf
  153. $!
  154. $! Restore the original default device:[directory].
  155. $!
  156. $ set default 'def_orig'
  157. $ exit
  158. $
  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.
  166. $!
  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.
  171. $!
  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
  182. $!
  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
  185. $! -----
  186. $
  187. $! ----- Subroutines for non-VAX
  188. $! -----
  189. $! The creator routine
  190. $ create_nonvax_shr:
  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
  197. $ libwrch := opt
  198. $ libwriter := write_nonvax_transfer_entry
  199. $ textcount = 0
  200. $ gosub read_func_num
  201. $ write opt ")"
  202. $ write opt "GSMATCH=",libvmatch,",",libver
  203. $ close opt
  204. $ link /map = 'libmap' /full /share = 'libgoal' 'libopt' /options -
  205. 'zlib_lib'
  206. $ return
  207. $
  208. $! The record writer routine
  209. $ write_nonvax_transfer_entry:
  210. $ if libentry .eqs. ".dummy" then return
  211. $ if info_kind .eqs. "VARIABLE"
  212. $ then
  213. $ pr:=DATA
  214. $ else
  215. $ pr:=PROCEDURE
  216. $ endif
  217. $ textcount_this = f$length(pr) + f$length(libentry) + 5
  218. $ if textcount + textcount_this .gt. 1024
  219. $ then
  220. $ write opt ")"
  221. $ write opt "SYMBOL_VECTOR=(-"
  222. $ textcount = 16
  223. $ libfirstentry := true
  224. $ endif
  225. $ if libfirstentry
  226. $ then
  227. $ write 'libwrch' " ",libentry,"=",pr," -"
  228. $ else
  229. $ write 'libwrch' " ,",libentry,"=",pr," -"
  230. $ endif
  231. $ libfirstentry := false
  232. $ textcount = textcount + textcount_this
  233. $ return
  234. $
  235. $! ----- Subroutines for VAX
  236. $! -----
  237. $! The creator routine
  238. $ create_vax_shr:
  239. $ open /write mar 'libmar'
  240. $ type sys$input:/out=mar:
  241. ;
  242. ; Transfer vector for VAX shareable image
  243. ;
  244. $ write mar " .TITLE ",libtit
  245. $ write mar " .IDENT /",libid,"/"
  246. $ type sys$input:/out=mar:
  247. ;
  248. ; Define macro to assist in building transfer vector entries. Each entry
  249. ; should take no more than 8 bytes.
  250. ;
  251. .MACRO FTRANSFER_ENTRY routine
  252. .ALIGN QUAD
  253. .TRANSFER routine
  254. .MASK routine
  255. JMP routine+2
  256. .ENDM FTRANSFER_ENTRY
  257. ;
  258. ; Place entries in own program section.
  259. ;
  260. $ write mar " .PSECT $$",libvec,",QUAD,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT"
  261. $ write mar libvec,"_xfer:"
  262. $ libwrch := mar
  263. $ libwriter := write_vax_ftransfer_entry
  264. $ gosub read_func_num
  265. $ type sys$input:/out=mar:
  266. ;
  267. ; Allocate extra storage at end of vector to allow for expansion.
  268. ;
  269. $ write mar " .BLKB 32768-<.-",libvec,"_xfer> ; 64 pages total."
  270. $! libwriter := write_vax_vtransfer_entry
  271. $! gosub read_func_num
  272. $ write mar " .END"
  273. $ close mar
  274. $ open /write opt 'libopt'
  275. $ write opt "identification=""",libid," ",libverstr,""""
  276. $ write opt libobj
  277. $ write opt libolb, " /library"
  278. $ if libref .nes. "" then write opt libref,"/SHARE"
  279. $ type sys$input:/out=opt:
  280. !
  281. ! Ensure transfer vector is at beginning of image
  282. !
  283. CLUSTER=FIRST
  284. $ write opt "COLLECT=FIRST,$$",libvec
  285. $ write opt "GSMATCH=",libvmatch,",",libver
  286. $ type sys$input:/out=opt:
  287. !
  288. ! make psects nonshareable so image can be installed.
  289. !
  290. PSECT_ATTR=$CHAR_STRING_CONSTANTS,NOWRT
  291. $ libwrch := opt
  292. $ libwriter := write_vax_psect_attr
  293. $ gosub read_func_num
  294. $ close opt
  295. $ macro/obj='libobj' 'libmar'
  296. $ link /map = 'libmap' /full /share = 'libgoal' 'libopt' /options -
  297. 'zlib_lib'
  298. $ return
  299. $
  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"
  304. $ then
  305. $ write 'libwrch' " .BLKB 8" ! Dummy is zeroes...
  306. $ else
  307. $ write 'libwrch' " FTRANSFER_ENTRY ",libentry
  308. $ endif
  309. $ return
  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"
  315. $ return
  316. $
  317. $! ----- Common subroutines
  318. $! -----
  319. $! The .num file reader. This one has great responsibility.
  320. $ read_func_num:
  321. $ open /read libnum 'libnum'
  322. $ goto read_nums
  323. $
  324. $ read_nums:
  325. $ libentrynum=0
  326. $ liblastentry:=false
  327. $ entrycount=0
  328. $ loop:
  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
  341. $ truesum = 0
  342. $ falsesum = 0
  343. $ negatives = 1
  344. $ plat_i = 0
  345. $ loop1:
  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. ","
  350. $ then
  351. $ if f$extract(0,1,plat_entry) .nes. "!" then negatives = 0
  352. $ if (arch_vax)
  353. $ then
  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
  358. $ endif
  359. $!
  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
  364. $!
  365. $ if ((plat_entry .eqs. "!VMS") .or. -
  366. (arch_vax .and. (plat_entry .eqs. "!VMSVAX"))) then -
  367. falsesum = falsesum + 1
  368. $!
  369. $ goto loop1
  370. $ endif
  371. $ endloop1:
  372. $!DEBUG!$ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
  373. $!DEBUG!$ then
  374. $!DEBUG!$ write sys$output line
  375. $!DEBUG!$ write sys$output " truesum = ",truesum,-
  376. $!DEBUG! ", negatives = ",negatives,", falsesum = ",falsesum
  377. $!DEBUG!$ endif
  378. $ if falsesum .ne. 0 then goto loop
  379. $ if truesum+negatives .eq. 0 then goto loop
  380. $ alg_i = 0
  381. $ loop2:
  382. $ alg_entry = f$element(alg_i,",",info_algorithms)
  383. $ alg_i = alg_i + 1
  384. $ if alg_entry .eqs. "" then goto loop2
  385. $ if alg_entry .nes. ","
  386. $ then
  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
  390. $ goto loop2
  391. $ endif
  392. $ endloop2:
  393. $ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
  394. $ then
  395. $!DEBUG!$ write sys$output curentry," ; ",entrynum," ; ",entryinfo
  396. $ endif
  397. $ redo:
  398. $ next:=loop
  399. $ tolibentry=curentry
  400. $ if libentrynum .ne. entrynum
  401. $ then
  402. $ entrycount=entrycount+1
  403. $ if entrycount .lt. entrynum
  404. $ then
  405. $!DEBUG!$ write sys$output "Info: entrycount: ''entrycount', entrynum: ''entrynum' => 0"
  406. $ tolibentry=".dummy"
  407. $ next:=redo
  408. $ endif
  409. $ if entrycount .gt. entrynum
  410. $ then
  411. $ write sys$error "Decreasing library entry numbers! Can't continue"
  412. $ write sys$error """",line,""""
  413. $ close libnum
  414. $ return
  415. $ endif
  416. $ libentry=tolibentry
  417. $!DEBUG!$ write sys$output entrycount," ",libentry," ",entryinfo
  418. $ if libentry .nes. "" .and. libwriter .nes. "" then gosub 'libwriter'
  419. $ else
  420. $ write sys$error "Info: ""''curentry'"" is an alias for ""''libentry'"". Overriding..."
  421. $ endif
  422. $ libentrynum=entrycount
  423. $ goto 'next'
  424. $ loop_end:
  425. $ close libnum
  426. $ return
  427. $
  428. $! The version number reader
  429. $ read_version_info:
  430. $ libver = ""
  431. $ open /read vf [.CRYPTO]OPENSSLV.H
  432. $ loop_rvi:
  433. $ read/err=endloop_rvi/end=endloop_rvi vf rvi_line
  434. $ if rvi_line - "SHLIB_VERSION_NUMBER """ .eqs. rvi_line then -
  435. goto loop_rvi
  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"
  445. $ then
  446. $ libvmatch = "EQUAL"
  447. $ else
  448. $ ! Starting with the 1.0 release, backward compatibility should be
  449. $ ! kept, so switch over to the following
  450. $ libvmatch = "LEQUAL"
  451. $ endif
  452. $ endloop_rvi:
  453. $ close vf
  454. $ return