geom_gate userland utility improvements
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

346 lines
8.3 KiB

  1. $!
  2. $!
  3. $ olddir = f$environment("default")
  4. $ on control_y then goto YExit
  5. $!
  6. $ gosub Init
  7. $ if .not. init_status then goto YExit
  8. $!
  9. $ call CompileAll
  10. $ call BuildTransferVectors
  11. $ call LinkShared
  12. $!
  13. $ call Cleanup
  14. $!
  15. $YExit:
  16. $ set noon
  17. $!
  18. $ deassign srcdir
  19. $ if f$search("objdir:*.*;*") .nes. "" then delete objdir:*.*;*
  20. $ deassign objdir
  21. $ delete library_objects.dir;*
  22. $!
  23. $ set default 'olddir'
  24. $exit
  25. $!
  26. $!---------------------------------------------------------------------
  27. $!
  28. $Init:
  29. $!
  30. $!
  31. $ init_status = 1
  32. $ thisid = f$integer( %x'f$getjpi(0,"pid")')
  33. $ mdir = f$environment("procedure")
  34. $ mdir = mdir - f$parse(mdir,,,"name") - f$parse(mdir,,,"type") - f$parse(mdir,,,"version")
  35. $ set default 'mdir'
  36. $!
  37. $ objdir = "[.library_objects]"
  38. $ srcdir = "[-.src]"
  39. $!
  40. $ objdirfile = objdir - "[." - "]" + ".dir"
  41. $ if f$search( objdirfile ) .eqs. ""
  42. $ then
  43. $ create/directory 'objdir'
  44. $ endif
  45. $!
  46. $ define objdir 'objdir'
  47. $ define srcdir 'srcdir'
  48. $!
  49. $ cc_include = "/include=([],[-.include],""/gnv$zlib_include"")"
  50. $ cc_define = "/DEFINE=(_USE_STD_STAT=1)"
  51. $ link_opts = "objdir:libssh2_''thisid'.opt"
  52. $!
  53. $ pipe search [-.include]libssh2.h libssh2_version_major/nohead | (read sys$input l ; l = f$element(2," ",f$edit(l,"trim,compress")) ; -
  54. define/job majorv &l )
  55. $ pipe search [-.include]libssh2.h libssh2_version_minor/nohead | (read sys$input l ; l = f$element(2," ",f$edit(l,"trim,compress")) ; -
  56. define/job minorv &l )
  57. $ pipe search [-.include]libssh2.h libssh2_version_patch/nohead | (read sys$input l ; l = f$element(2," ",f$edit(l,"trim,compress")) ; -
  58. define/job patchv &l )
  59. $!
  60. $ majorv = f$trnlnm("majorv")
  61. $ minorv = f$integer(f$trnlnm("minorv"))
  62. $ patchv = f$integer( f$trnlnm("patchv"))
  63. $!
  64. $ OLBONLY = "FALSE"
  65. $ if p1 .eqs. "OLBONLY"
  66. $ then
  67. $ OLBONLY = "TRUE"
  68. $ endif
  69. $!
  70. $ deassign/job majorv
  71. $ deassign/job minorv
  72. $ deassign/job patchv
  73. $!
  74. $return
  75. $!
  76. $!---------------------------------------------------------------------
  77. $!
  78. $Cleanup: subroutine
  79. $!
  80. $ set noon
  81. $ purge *.opt
  82. $ purge *.olb
  83. $ purge *.exe
  84. $!
  85. $exit 1
  86. $endsubroutine
  87. $!
  88. $!---------------------------------------------------------------------
  89. $!
  90. $LinkShared: subroutine
  91. $!
  92. $!
  93. $!
  94. $ cversion = f$fao("!3ZL",minorv) + f$fao("!3ZL",patchv)
  95. $!
  96. $! General linking options in link_libssh2_version...opt
  97. $! Vectors in link_libssh2_vectors...opt
  98. $!
  99. $ open/write uitv link_libssh2_version_'majorv'_'minorv'_'patchv'.opt
  100. $ write uitv "GSMATCH=LEQUAL,''majorv',''cversion'"
  101. $ write uitv "IDENTIFICATION=""LIBSSH2 ''majorv'.''minorv'.''patchv'"""
  102. $ write uitv "sys$share:ssl$libcrypto_shr32.exe/share"
  103. $ write uitv "sys$share:ssl$libssl_shr32.exe/share"
  104. $ write uitv "gnv$libzshr/share"
  105. $ close uitv
  106. $!
  107. $ link/shared/exe=libssh2_'majorv'_'minorv'_'patchv'.exe -
  108. libssh2.olb/lib, -
  109. link_libssh2_version_'majorv'_'minorv'_'patchv'.opt/opt, -
  110. link_libssh2_vectors_'majorv'_'minorv'_'patchv'.opt/opt
  111. $!
  112. $exit
  113. $endsubroutine
  114. $!
  115. $!---------------------------------------------------------------------
  116. $!
  117. $CompileAll: subroutine
  118. $!
  119. $ set noon
  120. $!
  121. $ if f$search("objdir:*.obj;*") .nes ""
  122. $ then
  123. $ delete objdir:*.obj;*
  124. $ endif
  125. $ if f$search("[.cxx_repository]cxx$demangler_db.;") .nes ""
  126. $ then
  127. $ delete [.cxx_repository]cxx$demangler_db.;*
  128. $ endif
  129. $!
  130. $! Compile all .c files in [-.src], first as_is
  131. $! and then as default all uppercase names
  132. $! and add the resulting object to object libraries
  133. $! libssh2_up.olb and libssh2_as_is.olb.
  134. $!
  135. $ case = 0
  136. $ if OLBONLY then case = 1
  137. $CaseLoop:
  138. $!
  139. $ if case .eq. 0
  140. $ then!camel case names
  141. $ cc_flags = "/names=(shortened,as_is)''cc_define'"
  142. $ objlib = "libssh2_asis.olb"
  143. $ endif
  144. $!
  145. $ if case .eq. 1
  146. $ then!uppercase names
  147. $ if f$search("[.cxx_repository]cxx$demangler_db.;") .nes ""
  148. $ then
  149. $ rename [.cxx_repository]cxx$demangler_db.; *.lowercase
  150. $ purge [.cxx_repository]cxx$demangler_db.lowercase
  151. $ endif
  152. $!
  153. $ cc_flags = "/names=(shortened)''cc_define'"
  154. $ objlib = "libssh2_up.olb"
  155. $ endif
  156. $!
  157. $ if f$search("''objlib';*") .nes. "" then delete 'objlib';*
  158. $ library/create 'objlib'
  159. $!
  160. $Loop:
  161. $ this = f$search("srcdir:*.c;0")
  162. $ if this .eqs. "" then goto EndLoop
  163. $!
  164. $ what = f$parse( this,,,"name")
  165. $!
  166. $ call CompileAndAdd
  167. $!
  168. $ goto Loop
  169. $EndLoop:
  170. $ case = case + 1
  171. $ delete objdir:*.obj;*
  172. $ if case .lt 2 then goto CaseLoop
  173. $!
  174. $ rename libssh2_up.olb libssh2.olb
  175. $ if f$search("[.cxx_repository]cxx$demangler_db.;") .nes ""
  176. $ then
  177. $ rename [.cxx_repository]cxx$demangler_db.; *.uppercase
  178. $ purge [.cxx_repository]cxx$demangler_db.uppercase
  179. $ endif
  180. $!
  181. $ if OLBONLY then exit 4
  182. $!
  183. $! For each function that is too long, create a global symbol
  184. $! low$'shortened-uppercase-name' with as value lowercase shortened
  185. $! name in it, so we can add the proper lower or mixed case
  186. $! shortened name later when building the transfer vectors
  187. $! for the shared image.
  188. $! This is to prevent two very long similar function names
  189. $! that are shortened getting mixed up when sorted alphabetically.
  190. $!
  191. $ inputfile = "[.cxx_repository]cxx$demangler_db.lowercase"
  192. $ gosub GetShortened
  193. $!
  194. $ inputfile = "[.cxx_repository]cxx$demangler_db.uppercase"
  195. $ gosub GetShortened
  196. $!
  197. $exit
  198. $!
  199. $GetShortened:
  200. $!
  201. $ open/read s 'inputfile'
  202. $ namecount = 0
  203. $ReadLoop:
  204. $!
  205. $ read/end=endreadloop s regel
  206. $!
  207. $ shortname = f$element(0,"$",regel) + "$"
  208. $ longname = f$element(1,"$",regel)
  209. $!
  210. $ symvalue = ""
  211. $!
  212. $ if shortname .eqs. f$edit(shortname,"upcase")
  213. $ then
  214. $! this is an uppercase shortname, add it
  215. $ symname = "u$''longname'"
  216. $ symvalue = "''shortname'"
  217. $ low$'shortname' == l$'longname'
  218. $!
  219. $ delete/symbol l$'longname'
  220. $!
  221. $ else
  222. $! this is an lowercase shortname
  223. $ symname = "l$''longname'"
  224. $ symvalue = "''shortname'"
  225. $ 'symname' = "''symvalue'"
  226. $ endif
  227. $!
  228. $ namecount = namecount + 1
  229. $!
  230. $ goto ReadLoop
  231. $EndReadLoop:
  232. $!
  233. $close s
  234. $return
  235. $!
  236. $endsubroutine
  237. $!
  238. $!---------------------------------------------------------------------
  239. $!
  240. $CompileAndAdd: subroutine
  241. $!
  242. $ on error then goto End
  243. $!
  244. $ cc /warn=disable=longextern/lis=objdir:/show=all 'cc_include' 'cc_flags'/object=objdir:'what'.obj srcdir:'what'.c
  245. $ library/insert 'objlib' objdir:'what'.obj
  246. $!
  247. $End:
  248. $exit
  249. $endsubroutine
  250. $!
  251. $!---------------------------------------------------------------------
  252. $!
  253. $BuildTransferVectors: subroutine
  254. $!
  255. $! Do a balanced read of the uppercase library names
  256. $! and the mixed case library names, and build the
  257. $! transfer vectors with uppercase entry points
  258. $! with an alternative in mixed case.
  259. $! For shortened names, use the low$* symbols
  260. $! to avoid being fooled by the sort.
  261. $!
  262. $ thislib = "libssh2.olb"
  263. $ library/lis=libu.'thisid'/names libssh2.olb
  264. $ library/lis=lib_asisu.'thisid'/names libssh2_asis.olb
  265. $!
  266. $! case blind sort of all modules in both the uppercase
  267. $! as the case sensitive object library.
  268. $!
  269. $ sort libu.'thisid' lib.'thisid'/spec=sys$input
  270. /COLLATING_SEQUENCE=(SEQUENCE= ("A" - "Z","0"-"9","_"), FOLD)
  271. $ sort lib_asisu.'thisid' lib_asis.'thisid'/spec=sys$input
  272. /COLLATING_SEQUENCE=(SEQUENCE= ("A" - "Z","0"-"9","_"), FOLD)
  273. $!
  274. $ open/read in lib.'thisid'
  275. $ open/read inasis lib_asis.'thisid'
  276. $ open/write uit link_libssh2_vectors_'majorv'_'minorv'_'patchv'.opt
  277. $!
  278. $ write uit "CASE_SENSITIVE=YES"
  279. $ write uit "SYMBOL_VECTOR= ( -"
  280. $!
  281. $ mode = 0
  282. $ uitregel = ""
  283. $!
  284. $ReadLoop:
  285. $!
  286. $ read/end=ReadAsis in regel
  287. $ReadAsis:
  288. $ read/end=EndReadLoop inasis asisregel
  289. $!
  290. $ regel = f$edit( regel, "trim,compress" )
  291. $ asisregel = f$edit( asisregel, "trim,compress" )
  292. $!
  293. $ if f$element(0," ",regel) .eqs. "Module" .or. -
  294. f$extract(0,1,regel) .eqs. "_" .or. -
  295. f$element(1," ",regel) .nes. " " .or. -
  296. regel .eqs. ""
  297. $ then
  298. $ goto ReadLoop
  299. $ endif
  300. $!
  301. $ if uitregel .nes. "" .and. mode .eq. 1
  302. $ then
  303. $ write uit "''uitregel'=PROCEDURE, -"
  304. $ write uit "''uitasis'/''uitregel'=PROCEDURE, -"
  305. $!
  306. $ uitregel = ""
  307. $ uitasis = ""
  308. $ endif
  309. $!
  310. $ uitregel = regel
  311. $ if f$type( low$'uitregel' ) .nes. ""
  312. $ then
  313. $ uitasis = low$'uitregel'
  314. $ delete/symbol/global low$'uitregel'
  315. $ else
  316. $ uitasis = asisregel
  317. $ endif
  318. $!
  319. $ mode = 1
  320. $!
  321. $ goto ReadLoop
  322. $EndreadLoop:
  323. $!
  324. $! To get the closing brace after the last procedure
  325. $! keyword.
  326. $!
  327. $ if uitregel .nes. ""
  328. $ then
  329. $ write uit "''uitregel'=PROCEDURE, -"
  330. $ write uit "''uitasis'/''uitregel'=PROCEDURE)"
  331. $ endif
  332. $!
  333. $ write uit "CASE_SENSITIVE=NO"
  334. $!
  335. $ close in
  336. $ close inasis
  337. $ close uit
  338. $!
  339. $ delete lib*.'thisid';*
  340. $!
  341. $exit
  342. $endsubroutine
  343. $!
  344. $!---------------------------------------------------------------------
  345. $!