make_vms.com 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. $! make libz under VMS written by
  2. $! Martin P.J. Zinser
  3. $!
  4. $! In case of problems with the install you might contact me at
  5. $! zinser@zinser.no-ip.info(preferred) or
  6. $! martin.zinser@eurexchange.com (work)
  7. $!
  8. $! Make procedure history for Zlib
  9. $!
  10. $!------------------------------------------------------------------------------
  11. $! Version history
  12. $! 0.01 20060120 First version to receive a number
  13. $! 0.02 20061008 Adapt to new Makefile.in
  14. $! 0.03 20091224 Add support for large file check
  15. $! 0.04 20100110 Add new gzclose, gzlib, gzread, gzwrite
  16. $! 0.05 20100221 Exchange zlibdefs.h by zconf.h.in
  17. $! 0.06 20120111 Fix missing amiss_err, update zconf_h.in, fix new exmples
  18. $! subdir path, update module search in makefile.in
  19. $! 0.07 20120115 Triggered by work done by Alexey Chupahin completly redesigned
  20. $! shared image creation
  21. $! 0.08 20120219 Make it work on VAX again, pre-load missing symbols to shared
  22. $! image
  23. $! 0.09 20120305 SMS. P1 sets builder ("MMK", "MMS", " " (built-in)).
  24. $! "" -> automatic, preference: MMK, MMS, built-in.
  25. $!
  26. $ on error then goto err_exit
  27. $!
  28. $ true = 1
  29. $ false = 0
  30. $ tmpnam = "temp_" + f$getjpi("","pid")
  31. $ tt = tmpnam + ".txt"
  32. $ tc = tmpnam + ".c"
  33. $ th = tmpnam + ".h"
  34. $ define/nolog tconfig 'th'
  35. $ its_decc = false
  36. $ its_vaxc = false
  37. $ its_gnuc = false
  38. $ s_case = False
  39. $!
  40. $! Setup variables holding "config" information
  41. $!
  42. $ Make = "''p1'"
  43. $ name = "Zlib"
  44. $ version = "?.?.?"
  45. $ v_string = "ZLIB_VERSION"
  46. $ v_file = "zlib.h"
  47. $ ccopt = "/include = []"
  48. $ lopts = ""
  49. $ dnsrl = ""
  50. $ aconf_in_file = "zconf.h.in#zconf.h_in#zconf_h.in"
  51. $ conf_check_string = ""
  52. $ linkonly = false
  53. $ optfile = name + ".opt"
  54. $ mapfile = name + ".map"
  55. $ libdefs = ""
  56. $ vax = f$getsyi("HW_MODEL").lt.1024
  57. $ axp = f$getsyi("HW_MODEL").ge.1024 .and. f$getsyi("HW_MODEL").lt.4096
  58. $ ia64 = f$getsyi("HW_MODEL").ge.4096
  59. $!
  60. $! 2012-03-05 SMS.
  61. $! Why is this needed? And if it is needed, why not simply ".not. vax"?
  62. $!
  63. $!!! if axp .or. ia64 then set proc/parse=extended
  64. $!
  65. $ whoami = f$parse(f$environment("Procedure"),,,,"NO_CONCEAL")
  66. $ mydef = F$parse(whoami,,,"DEVICE")
  67. $ mydir = f$parse(whoami,,,"DIRECTORY") - "]["
  68. $ myproc = f$parse(whoami,,,"Name") + f$parse(whoami,,,"type")
  69. $!
  70. $! Check for MMK/MMS
  71. $!
  72. $ if (Make .eqs. "")
  73. $ then
  74. $ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS"
  75. $ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK"
  76. $ else
  77. $ Make = f$edit( Make, "trim")
  78. $ endif
  79. $!
  80. $ gosub find_version
  81. $!
  82. $ open/write topt tmp.opt
  83. $ open/write optf 'optfile'
  84. $!
  85. $ gosub check_opts
  86. $!
  87. $! Look for the compiler used
  88. $!
  89. $ gosub check_compiler
  90. $ close topt
  91. $ close optf
  92. $!
  93. $ if its_decc
  94. $ then
  95. $ ccopt = "/prefix=all" + ccopt
  96. $ if f$trnlnm("SYS") .eqs. ""
  97. $ then
  98. $ if axp
  99. $ then
  100. $ define sys sys$library:
  101. $ else
  102. $ ccopt = "/decc" + ccopt
  103. $ define sys decc$library_include:
  104. $ endif
  105. $ endif
  106. $!
  107. $! 2012-03-05 SMS.
  108. $! Why /NAMES = AS_IS? Why not simply ".not. vax"? And why not on VAX?
  109. $!
  110. $ if axp .or. ia64
  111. $ then
  112. $ ccopt = ccopt + "/name=as_is/opt=(inline=speed)"
  113. $ s_case = true
  114. $ endif
  115. $ endif
  116. $ if its_vaxc .or. its_gnuc
  117. $ then
  118. $ if f$trnlnm("SYS").eqs."" then define sys sys$library:
  119. $ endif
  120. $!
  121. $! Build a fake configure input header
  122. $!
  123. $ open/write conf_hin config.hin
  124. $ write conf_hin "#undef _LARGEFILE64_SOURCE"
  125. $ close conf_hin
  126. $!
  127. $!
  128. $ i = 0
  129. $FIND_ACONF:
  130. $ fname = f$element(i,"#",aconf_in_file)
  131. $ if fname .eqs. "#" then goto AMISS_ERR
  132. $ if f$search(fname) .eqs. ""
  133. $ then
  134. $ i = i + 1
  135. $ goto find_aconf
  136. $ endif
  137. $ open/read/err=aconf_err aconf_in 'fname'
  138. $ open/write aconf zconf.h
  139. $ACONF_LOOP:
  140. $ read/end_of_file=aconf_exit aconf_in line
  141. $ work = f$edit(line, "compress,trim")
  142. $ if f$extract(0,6,work) .nes. "#undef"
  143. $ then
  144. $ if f$extract(0,12,work) .nes. "#cmakedefine"
  145. $ then
  146. $ write aconf line
  147. $ endif
  148. $ else
  149. $ cdef = f$element(1," ",work)
  150. $ gosub check_config
  151. $ endif
  152. $ goto aconf_loop
  153. $ACONF_EXIT:
  154. $ write aconf ""
  155. $ write aconf "/* VMS specifics added by make_vms.com: */"
  156. $ write aconf "#define VMS 1"
  157. $ write aconf "#include <unistd.h>"
  158. $ write aconf "#include <unixio.h>"
  159. $ write aconf "#ifdef _LARGEFILE"
  160. $ write aconf "# define off64_t __off64_t"
  161. $ write aconf "# define fopen64 fopen"
  162. $ write aconf "# define fseeko64 fseeko"
  163. $ write aconf "# define lseek64 lseek"
  164. $ write aconf "# define ftello64 ftell"
  165. $ write aconf "#endif"
  166. $ write aconf "#if !defined( __VAX) && (__CRTL_VER >= 70312000)"
  167. $ write aconf "# define HAVE_VSNPRINTF"
  168. $ write aconf "#endif"
  169. $ close aconf_in
  170. $ close aconf
  171. $ if f$search("''th'") .nes. "" then delete 'th';*
  172. $! Build the thing plain or with mms
  173. $!
  174. $ write sys$output "Compiling Zlib sources ..."
  175. $ if make.eqs.""
  176. $ then
  177. $ if (f$search( "example.obj;*") .nes. "") then delete example.obj;*
  178. $ if (f$search( "minigzip.obj;*") .nes. "") then delete minigzip.obj;*
  179. $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
  180. adler32.c zlib.h zconf.h
  181. $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
  182. compress.c zlib.h zconf.h
  183. $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
  184. crc32.c zlib.h zconf.h
  185. $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
  186. deflate.c deflate.h zutil.h zlib.h zconf.h
  187. $ CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" -
  188. gzclose.c zutil.h zlib.h zconf.h
  189. $ CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" -
  190. gzlib.c zutil.h zlib.h zconf.h
  191. $ CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" -
  192. gzread.c zutil.h zlib.h zconf.h
  193. $ CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" -
  194. gzwrite.c zutil.h zlib.h zconf.h
  195. $ CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
  196. infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
  197. $ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
  198. inffast.c zutil.h zlib.h zconf.h inffast.h
  199. $ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" -
  200. inflate.c zutil.h zlib.h zconf.h infblock.h
  201. $ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" -
  202. inftrees.c zutil.h zlib.h zconf.h inftrees.h
  203. $ CALL MAKE trees.OBJ "CC ''CCOPT' trees" -
  204. trees.c deflate.h zutil.h zlib.h zconf.h
  205. $ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" -
  206. uncompr.c zlib.h zconf.h
  207. $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" -
  208. zutil.c zutil.h zlib.h zconf.h
  209. $ write sys$output "Building Zlib ..."
  210. $ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ
  211. $ write sys$output "Building example..."
  212. $ CALL MAKE example.OBJ "CC ''CCOPT' [.test]example" -
  213. [.test]example.c zlib.h zconf.h
  214. $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb
  215. $ write sys$output "Building minigzip..."
  216. $ CALL MAKE minigzip.OBJ "CC ''CCOPT' [.test]minigzip" -
  217. [.test]minigzip.c zlib.h zconf.h
  218. $ call make minigzip.exe -
  219. "LINK minigzip,libz.olb/lib" -
  220. minigzip.obj libz.olb
  221. $ else
  222. $ gosub crea_mms
  223. $ write sys$output "Make ''name' ''version' with ''Make' "
  224. $ 'make'
  225. $ endif
  226. $!
  227. $! Create shareable image
  228. $!
  229. $ gosub crea_olist
  230. $ write sys$output "Creating libzshr.exe"
  231. $ call map_2_shopt 'mapfile' 'optfile'
  232. $ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,'optfile'/opt
  233. $ write sys$output "Zlib build completed"
  234. $ delete/nolog tmp.opt;*
  235. $ exit
  236. $AMISS_ERR:
  237. $ write sys$output "No source for config.hin found."
  238. $ write sys$output "Tried any of ''aconf_in_file'"
  239. $ goto err_exit
  240. $CC_ERR:
  241. $ write sys$output "C compiler required to build ''name'"
  242. $ goto err_exit
  243. $ERR_EXIT:
  244. $ set message/facil/ident/sever/text
  245. $ close/nolog optf
  246. $ close/nolog topt
  247. $ close/nolog aconf_in
  248. $ close/nolog aconf
  249. $ close/nolog out
  250. $ close/nolog min
  251. $ close/nolog mod
  252. $ close/nolog h_in
  253. $ write sys$output "Exiting..."
  254. $ exit 2
  255. $!
  256. $!
  257. $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES
  258. $ V = 'F$Verify(0)
  259. $! P1 = What we are trying to make
  260. $! P2 = Command to make it
  261. $! P3 - P8 What it depends on
  262. $
  263. $ If F$Search(P1) .Eqs. "" Then Goto Makeit
  264. $ Time = F$CvTime(F$File(P1,"RDT"))
  265. $arg=3
  266. $Loop:
  267. $ Argument = P'arg
  268. $ If Argument .Eqs. "" Then Goto Exit
  269. $ El=0
  270. $Loop2:
  271. $ File = F$Element(El," ",Argument)
  272. $ If File .Eqs. " " Then Goto Endl
  273. $ AFile = ""
  274. $Loop3:
  275. $ OFile = AFile
  276. $ AFile = F$Search(File)
  277. $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
  278. $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
  279. $ Goto Loop3
  280. $NextEL:
  281. $ El = El + 1
  282. $ Goto Loop2
  283. $EndL:
  284. $ arg=arg+1
  285. $ If arg .Le. 8 Then Goto Loop
  286. $ Goto Exit
  287. $
  288. $Makeit:
  289. $ VV=F$VERIFY(0)
  290. $ write sys$output P2
  291. $ 'P2
  292. $ VV='F$Verify(VV)
  293. $Exit:
  294. $ If V Then Set Verify
  295. $ENDSUBROUTINE
  296. $!------------------------------------------------------------------------------
  297. $!
  298. $! Check command line options and set symbols accordingly
  299. $!
  300. $!------------------------------------------------------------------------------
  301. $! Version history
  302. $! 0.01 20041206 First version to receive a number
  303. $! 0.02 20060126 Add new "HELP" target
  304. $ CHECK_OPTS:
  305. $ i = 1
  306. $ OPT_LOOP:
  307. $ if i .lt. 9
  308. $ then
  309. $ cparm = f$edit(p'i',"upcase")
  310. $!
  311. $! Check if parameter actually contains something
  312. $!
  313. $ if f$edit(cparm,"trim") .nes. ""
  314. $ then
  315. $ if cparm .eqs. "DEBUG"
  316. $ then
  317. $ ccopt = ccopt + "/noopt/deb"
  318. $ lopts = lopts + "/deb"
  319. $ endif
  320. $ if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
  321. $ then
  322. $ start = f$locate("=",cparm) + 1
  323. $ len = f$length(cparm) - start
  324. $ ccopt = ccopt + f$extract(start,len,cparm)
  325. $ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
  326. then s_case = true
  327. $ endif
  328. $ if cparm .eqs. "LINK" then linkonly = true
  329. $ if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
  330. $ then
  331. $ start = f$locate("=",cparm) + 1
  332. $ len = f$length(cparm) - start
  333. $ lopts = lopts + f$extract(start,len,cparm)
  334. $ endif
  335. $ if f$locate("CC=",cparm) .lt. f$length(cparm)
  336. $ then
  337. $ start = f$locate("=",cparm) + 1
  338. $ len = f$length(cparm) - start
  339. $ cc_com = f$extract(start,len,cparm)
  340. if (cc_com .nes. "DECC") .and. -
  341. (cc_com .nes. "VAXC") .and. -
  342. (cc_com .nes. "GNUC")
  343. $ then
  344. $ write sys$output "Unsupported compiler choice ''cc_com' ignored"
  345. $ write sys$output "Use DECC, VAXC, or GNUC instead"
  346. $ else
  347. $ if cc_com .eqs. "DECC" then its_decc = true
  348. $ if cc_com .eqs. "VAXC" then its_vaxc = true
  349. $ if cc_com .eqs. "GNUC" then its_gnuc = true
  350. $ endif
  351. $ endif
  352. $ if f$locate("MAKE=",cparm) .lt. f$length(cparm)
  353. $ then
  354. $ start = f$locate("=",cparm) + 1
  355. $ len = f$length(cparm) - start
  356. $ mmks = f$extract(start,len,cparm)
  357. $ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
  358. $ then
  359. $ make = mmks
  360. $ else
  361. $ write sys$output "Unsupported make choice ''mmks' ignored"
  362. $ write sys$output "Use MMK or MMS instead"
  363. $ endif
  364. $ endif
  365. $ if cparm .eqs. "HELP" then gosub bhelp
  366. $ endif
  367. $ i = i + 1
  368. $ goto opt_loop
  369. $ endif
  370. $ return
  371. $!------------------------------------------------------------------------------
  372. $!
  373. $! Look for the compiler used
  374. $!
  375. $! Version history
  376. $! 0.01 20040223 First version to receive a number
  377. $! 0.02 20040229 Save/set value of decc$no_rooted_search_lists
  378. $! 0.03 20060202 Extend handling of GNU C
  379. $! 0.04 20090402 Compaq -> hp
  380. $CHECK_COMPILER:
  381. $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
  382. $ then
  383. $ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "")
  384. $ its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "")
  385. $ its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "")
  386. $ endif
  387. $!
  388. $! Exit if no compiler available
  389. $!
  390. $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
  391. $ then goto CC_ERR
  392. $ else
  393. $ if its_decc
  394. $ then
  395. $ write sys$output "CC compiler check ... hp C"
  396. $ if f$trnlnm("decc$no_rooted_search_lists") .nes. ""
  397. $ then
  398. $ dnrsl = f$trnlnm("decc$no_rooted_search_lists")
  399. $ endif
  400. $ define/nolog decc$no_rooted_search_lists 1
  401. $ else
  402. $ if its_vaxc then write sys$output "CC compiler check ... VAX C"
  403. $ if its_gnuc
  404. $ then
  405. $ write sys$output "CC compiler check ... GNU C"
  406. $ if f$trnlnm(topt) then write topt "gnu_cc:[000000]gcclib.olb/lib"
  407. $ if f$trnlnm(optf) then write optf "gnu_cc:[000000]gcclib.olb/lib"
  408. $ cc = "gcc"
  409. $ endif
  410. $ if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share"
  411. $ if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share"
  412. $ endif
  413. $ endif
  414. $ return
  415. $!------------------------------------------------------------------------------
  416. $!
  417. $! If MMS/MMK are available dump out the descrip.mms if required
  418. $!
  419. $CREA_MMS:
  420. $ write sys$output "Creating descrip.mms..."
  421. $ create descrip.mms
  422. $ open/append out descrip.mms
  423. $ copy sys$input: out
  424. $ deck
  425. # descrip.mms: MMS description file for building zlib on VMS
  426. # written by Martin P.J. Zinser
  427. # <zinser@zinser.no-ip.info or martin.zinser@eurexchange.com>
  428. OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzlib.obj\
  429. gzread.obj, gzwrite.obj, uncompr.obj, infback.obj\
  430. deflate.obj, trees.obj, zutil.obj, inflate.obj, \
  431. inftrees.obj, inffast.obj
  432. $ eod
  433. $ write out "CFLAGS=", ccopt
  434. $ write out "LOPTS=", lopts
  435. $ write out "all : example.exe minigzip.exe libz.olb"
  436. $ copy sys$input: out
  437. $ deck
  438. @ write sys$output " Example applications available"
  439. libz.olb : libz.olb($(OBJS))
  440. @ write sys$output " libz available"
  441. example.exe : example.obj libz.olb
  442. link $(LOPTS) example,libz.olb/lib
  443. minigzip.exe : minigzip.obj libz.olb
  444. link $(LOPTS) minigzip,libz.olb/lib
  445. clean :
  446. delete *.obj;*,libz.olb;*,*.opt;*,*.exe;*
  447. # Other dependencies.
  448. adler32.obj : adler32.c zutil.h zlib.h zconf.h
  449. compress.obj : compress.c zlib.h zconf.h
  450. crc32.obj : crc32.c zutil.h zlib.h zconf.h
  451. deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h
  452. example.obj : [.test]example.c zlib.h zconf.h
  453. gzclose.obj : gzclose.c zutil.h zlib.h zconf.h
  454. gzlib.obj : gzlib.c zutil.h zlib.h zconf.h
  455. gzread.obj : gzread.c zutil.h zlib.h zconf.h
  456. gzwrite.obj : gzwrite.c zutil.h zlib.h zconf.h
  457. inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h
  458. inflate.obj : inflate.c zutil.h zlib.h zconf.h
  459. inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h
  460. minigzip.obj : [.test]minigzip.c zlib.h zconf.h
  461. trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h
  462. uncompr.obj : uncompr.c zlib.h zconf.h
  463. zutil.obj : zutil.c zutil.h zlib.h zconf.h
  464. infback.obj : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
  465. $ eod
  466. $ close out
  467. $ return
  468. $!------------------------------------------------------------------------------
  469. $!
  470. $! Read list of core library sources from makefile.in and create options
  471. $! needed to build shareable image
  472. $!
  473. $CREA_OLIST:
  474. $ open/read min makefile.in
  475. $ open/write mod modules.opt
  476. $ src_check_list = "OBJZ =#OBJG ="
  477. $MRLOOP:
  478. $ read/end=mrdone min rec
  479. $ i = 0
  480. $SRC_CHECK_LOOP:
  481. $ src_check = f$element(i, "#", src_check_list)
  482. $ i = i+1
  483. $ if src_check .eqs. "#" then goto mrloop
  484. $ if (f$extract(0,6,rec) .nes. src_check) then goto src_check_loop
  485. $ rec = rec - src_check
  486. $ gosub extra_filnam
  487. $ if (f$element(1,"\",rec) .eqs. "\") then goto mrloop
  488. $MRSLOOP:
  489. $ read/end=mrdone min rec
  490. $ gosub extra_filnam
  491. $ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop
  492. $MRDONE:
  493. $ close min
  494. $ close mod
  495. $ return
  496. $!------------------------------------------------------------------------------
  497. $!
  498. $! Take record extracted in crea_olist and split it into single filenames
  499. $!
  500. $EXTRA_FILNAM:
  501. $ myrec = f$edit(rec - "\", "trim,compress")
  502. $ i = 0
  503. $FELOOP:
  504. $ srcfil = f$element(i," ", myrec)
  505. $ if (srcfil .nes. " ")
  506. $ then
  507. $ write mod f$parse(srcfil,,,"NAME"), ".obj"
  508. $ i = i + 1
  509. $ goto feloop
  510. $ endif
  511. $ return
  512. $!------------------------------------------------------------------------------
  513. $!
  514. $! Find current Zlib version number
  515. $!
  516. $FIND_VERSION:
  517. $ open/read h_in 'v_file'
  518. $hloop:
  519. $ read/end=hdone h_in rec
  520. $ rec = f$edit(rec,"TRIM")
  521. $ if (f$extract(0,1,rec) .nes. "#") then goto hloop
  522. $ rec = f$edit(rec - "#", "TRIM")
  523. $ if f$element(0," ",rec) .nes. "define" then goto hloop
  524. $ if f$element(1," ",rec) .eqs. v_string
  525. $ then
  526. $ version = 'f$element(2," ",rec)'
  527. $ goto hdone
  528. $ endif
  529. $ goto hloop
  530. $hdone:
  531. $ close h_in
  532. $ return
  533. $!------------------------------------------------------------------------------
  534. $!
  535. $CHECK_CONFIG:
  536. $!
  537. $ in_ldef = f$locate(cdef,libdefs)
  538. $ if (in_ldef .lt. f$length(libdefs))
  539. $ then
  540. $ write aconf "#define ''cdef' 1"
  541. $ libdefs = f$extract(0,in_ldef,libdefs) + -
  542. f$extract(in_ldef + f$length(cdef) + 1, -
  543. f$length(libdefs) - in_ldef - f$length(cdef) - 1, -
  544. libdefs)
  545. $ else
  546. $ if (f$type('cdef') .eqs. "INTEGER")
  547. $ then
  548. $ write aconf "#define ''cdef' ", 'cdef'
  549. $ else
  550. $ if (f$type('cdef') .eqs. "STRING")
  551. $ then
  552. $ write aconf "#define ''cdef' ", """", '''cdef'', """"
  553. $ else
  554. $ gosub check_cc_def
  555. $ endif
  556. $ endif
  557. $ endif
  558. $ return
  559. $!------------------------------------------------------------------------------
  560. $!
  561. $! Check if this is a define relating to the properties of the C/C++
  562. $! compiler
  563. $!
  564. $ CHECK_CC_DEF:
  565. $ if (cdef .eqs. "_LARGEFILE64_SOURCE")
  566. $ then
  567. $ copy sys$input: 'tc'
  568. $ deck
  569. #include "tconfig"
  570. #define _LARGEFILE
  571. #include <stdio.h>
  572. int main(){
  573. FILE *fp;
  574. fp = fopen("temp.txt","r");
  575. fseeko(fp,1,SEEK_SET);
  576. fclose(fp);
  577. }
  578. $ eod
  579. $ test_inv = false
  580. $ comm_h = false
  581. $ gosub cc_prop_check
  582. $ return
  583. $ endif
  584. $ write aconf "/* ", line, " */"
  585. $ return
  586. $!------------------------------------------------------------------------------
  587. $!
  588. $! Check for properties of C/C++ compiler
  589. $!
  590. $! Version history
  591. $! 0.01 20031020 First version to receive a number
  592. $! 0.02 20031022 Added logic for defines with value
  593. $! 0.03 20040309 Make sure local config file gets not deleted
  594. $! 0.04 20041230 Also write include for configure run
  595. $! 0.05 20050103 Add processing of "comment defines"
  596. $CC_PROP_CHECK:
  597. $ cc_prop = true
  598. $ is_need = false
  599. $ is_need = (f$extract(0,4,cdef) .eqs. "NEED") .or. (test_inv .eq. true)
  600. $ if f$search(th) .eqs. "" then create 'th'
  601. $ set message/nofac/noident/nosever/notext
  602. $ on error then continue
  603. $ cc 'tmpnam'
  604. $ if .not. ($status) then cc_prop = false
  605. $ on error then continue
  606. $! The headers might lie about the capabilities of the RTL
  607. $ link 'tmpnam',tmp.opt/opt
  608. $ if .not. ($status) then cc_prop = false
  609. $ set message/fac/ident/sever/text
  610. $ on error then goto err_exit
  611. $ delete/nolog 'tmpnam'.*;*/exclude='th'
  612. $ if (cc_prop .and. .not. is_need) .or. -
  613. (.not. cc_prop .and. is_need)
  614. $ then
  615. $ write sys$output "Checking for ''cdef'... yes"
  616. $ if f$type('cdef_val'_yes) .nes. ""
  617. $ then
  618. $ if f$type('cdef_val'_yes) .eqs. "INTEGER" -
  619. then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_yes)
  620. $ if f$type('cdef_val'_yes) .eqs. "STRING" -
  621. then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_yes)
  622. $ else
  623. $ call write_config f$fao("#define !AS 1",cdef)
  624. $ endif
  625. $ if (cdef .eqs. "HAVE_FSEEKO") .or. (cdef .eqs. "_LARGE_FILES") .or. -
  626. (cdef .eqs. "_LARGEFILE64_SOURCE") then -
  627. call write_config f$string("#define _LARGEFILE 1")
  628. $ else
  629. $ write sys$output "Checking for ''cdef'... no"
  630. $ if (comm_h)
  631. $ then
  632. call write_config f$fao("/* !AS */",line)
  633. $ else
  634. $ if f$type('cdef_val'_no) .nes. ""
  635. $ then
  636. $ if f$type('cdef_val'_no) .eqs. "INTEGER" -
  637. then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_no)
  638. $ if f$type('cdef_val'_no) .eqs. "STRING" -
  639. then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_no)
  640. $ else
  641. $ call write_config f$fao("#undef !AS",cdef)
  642. $ endif
  643. $ endif
  644. $ endif
  645. $ return
  646. $!------------------------------------------------------------------------------
  647. $!
  648. $! Check for properties of C/C++ compiler with multiple result values
  649. $!
  650. $! Version history
  651. $! 0.01 20040127 First version
  652. $! 0.02 20050103 Reconcile changes from cc_prop up to version 0.05
  653. $CC_MPROP_CHECK:
  654. $ cc_prop = true
  655. $ i = 1
  656. $ idel = 1
  657. $ MT_LOOP:
  658. $ if f$type(result_'i') .eqs. "STRING"
  659. $ then
  660. $ set message/nofac/noident/nosever/notext
  661. $ on error then continue
  662. $ cc 'tmpnam'_'i'
  663. $ if .not. ($status) then cc_prop = false
  664. $ on error then continue
  665. $! The headers might lie about the capabilities of the RTL
  666. $ link 'tmpnam'_'i',tmp.opt/opt
  667. $ if .not. ($status) then cc_prop = false
  668. $ set message/fac/ident/sever/text
  669. $ on error then goto err_exit
  670. $ delete/nolog 'tmpnam'_'i'.*;*
  671. $ if (cc_prop)
  672. $ then
  673. $ write sys$output "Checking for ''cdef'... ", mdef_'i'
  674. $ if f$type(mdef_'i') .eqs. "INTEGER" -
  675. then call write_config f$fao("#define !AS !UL",cdef,mdef_'i')
  676. $ if f$type('cdef_val'_yes) .eqs. "STRING" -
  677. then call write_config f$fao("#define !AS !AS",cdef,mdef_'i')
  678. $ goto msym_clean
  679. $ else
  680. $ i = i + 1
  681. $ goto mt_loop
  682. $ endif
  683. $ endif
  684. $ write sys$output "Checking for ''cdef'... no"
  685. $ call write_config f$fao("#undef !AS",cdef)
  686. $ MSYM_CLEAN:
  687. $ if (idel .le. msym_max)
  688. $ then
  689. $ delete/sym mdef_'idel'
  690. $ idel = idel + 1
  691. $ goto msym_clean
  692. $ endif
  693. $ return
  694. $!------------------------------------------------------------------------------
  695. $!
  696. $! Write configuration to both permanent and temporary config file
  697. $!
  698. $! Version history
  699. $! 0.01 20031029 First version to receive a number
  700. $!
  701. $WRITE_CONFIG: SUBROUTINE
  702. $ write aconf 'p1'
  703. $ open/append confh 'th'
  704. $ write confh 'p1'
  705. $ close confh
  706. $ENDSUBROUTINE
  707. $!------------------------------------------------------------------------------
  708. $!
  709. $! Analyze the project map file and create the symbol vector for a shareable
  710. $! image from it
  711. $!
  712. $! Version history
  713. $! 0.01 20120128 First version
  714. $! 0.02 20120226 Add pre-load logic
  715. $!
  716. $ MAP_2_SHOPT: Subroutine
  717. $!
  718. $ SAY := "WRITE_ SYS$OUTPUT"
  719. $!
  720. $ IF F$SEARCH("''P1'") .EQS. ""
  721. $ THEN
  722. $ SAY "MAP_2_SHOPT-E-NOSUCHFILE: Error, inputfile ''p1' not available"
  723. $ goto exit_m2s
  724. $ ENDIF
  725. $ IF "''P2'" .EQS. ""
  726. $ THEN
  727. $ SAY "MAP_2_SHOPT: Error, no output file provided"
  728. $ goto exit_m2s
  729. $ ENDIF
  730. $!
  731. $ module1 = "deflate#deflateEnd#deflateInit_#deflateParams#deflateSetDictionary"
  732. $ module2 = "gzclose#gzerror#gzgetc#gzgets#gzopen#gzprintf#gzputc#gzputs#gzread"
  733. $ module3 = "gzseek#gztell#inflate#inflateEnd#inflateInit_#inflateSetDictionary"
  734. $ module4 = "inflateSync#uncompress#zlibVersion#compress"
  735. $ open/read map 'p1
  736. $ if axp .or. ia64
  737. $ then
  738. $ open/write aopt a.opt
  739. $ open/write bopt b.opt
  740. $ write aopt " CASE_SENSITIVE=YES"
  741. $ write bopt "SYMBOL_VECTOR= (-"
  742. $ mod_sym_num = 1
  743. $ MOD_SYM_LOOP:
  744. $ if f$type(module'mod_sym_num') .nes. ""
  745. $ then
  746. $ mod_in = 0
  747. $ MOD_SYM_IN:
  748. $ shared_proc = f$element(mod_in, "#", module'mod_sym_num')
  749. $ if shared_proc .nes. "#"
  750. $ then
  751. $ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",-
  752. f$edit(shared_proc,"upcase"),shared_proc)
  753. $ write bopt f$fao("!AS=PROCEDURE,-",shared_proc)
  754. $ mod_in = mod_in + 1
  755. $ goto mod_sym_in
  756. $ endif
  757. $ mod_sym_num = mod_sym_num + 1
  758. $ goto mod_sym_loop
  759. $ endif
  760. $MAP_LOOP:
  761. $ read/end=map_end map line
  762. $ if (f$locate("{",line).lt. f$length(line)) .or. -
  763. (f$locate("global:", line) .lt. f$length(line))
  764. $ then
  765. $ proc = true
  766. $ goto map_loop
  767. $ endif
  768. $ if f$locate("}",line).lt. f$length(line) then proc = false
  769. $ if f$locate("local:", line) .lt. f$length(line) then proc = false
  770. $ if proc
  771. $ then
  772. $ shared_proc = f$edit(line,"collapse")
  773. $ chop_semi = f$locate(";", shared_proc)
  774. $ if chop_semi .lt. f$length(shared_proc) then -
  775. shared_proc = f$extract(0, chop_semi, shared_proc)
  776. $ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",-
  777. f$edit(shared_proc,"upcase"),shared_proc)
  778. $ write bopt f$fao("!AS=PROCEDURE,-",shared_proc)
  779. $ endif
  780. $ goto map_loop
  781. $MAP_END:
  782. $ close/nolog aopt
  783. $ close/nolog bopt
  784. $ open/append libopt 'p2'
  785. $ open/read aopt a.opt
  786. $ open/read bopt b.opt
  787. $ALOOP:
  788. $ read/end=aloop_end aopt line
  789. $ write libopt line
  790. $ goto aloop
  791. $ALOOP_END:
  792. $ close/nolog aopt
  793. $ sv = ""
  794. $BLOOP:
  795. $ read/end=bloop_end bopt svn
  796. $ if (svn.nes."")
  797. $ then
  798. $ if (sv.nes."") then write libopt sv
  799. $ sv = svn
  800. $ endif
  801. $ goto bloop
  802. $BLOOP_END:
  803. $ write libopt f$extract(0,f$length(sv)-2,sv), "-"
  804. $ write libopt ")"
  805. $ close/nolog bopt
  806. $ delete/nolog/noconf a.opt;*,b.opt;*
  807. $ else
  808. $ if vax
  809. $ then
  810. $ open/append libopt 'p2'
  811. $ mod_sym_num = 1
  812. $ VMOD_SYM_LOOP:
  813. $ if f$type(module'mod_sym_num') .nes. ""
  814. $ then
  815. $ mod_in = 0
  816. $ VMOD_SYM_IN:
  817. $ shared_proc = f$element(mod_in, "#", module'mod_sym_num')
  818. $ if shared_proc .nes. "#"
  819. $ then
  820. $ write libopt f$fao("UNIVERSAL=!AS",-
  821. f$edit(shared_proc,"upcase"))
  822. $ mod_in = mod_in + 1
  823. $ goto vmod_sym_in
  824. $ endif
  825. $ mod_sym_num = mod_sym_num + 1
  826. $ goto vmod_sym_loop
  827. $ endif
  828. $VMAP_LOOP:
  829. $ read/end=vmap_end map line
  830. $ if (f$locate("{",line).lt. f$length(line)) .or. -
  831. (f$locate("global:", line) .lt. f$length(line))
  832. $ then
  833. $ proc = true
  834. $ goto vmap_loop
  835. $ endif
  836. $ if f$locate("}",line).lt. f$length(line) then proc = false
  837. $ if f$locate("local:", line) .lt. f$length(line) then proc = false
  838. $ if proc
  839. $ then
  840. $ shared_proc = f$edit(line,"collapse")
  841. $ chop_semi = f$locate(";", shared_proc)
  842. $ if chop_semi .lt. f$length(shared_proc) then -
  843. shared_proc = f$extract(0, chop_semi, shared_proc)
  844. $ write libopt f$fao("UNIVERSAL=!AS",-
  845. f$edit(shared_proc,"upcase"))
  846. $ endif
  847. $ goto vmap_loop
  848. $VMAP_END:
  849. $ else
  850. $ write sys$output "Unknown Architecture (Not VAX, AXP, or IA64)"
  851. $ write sys$output "No options file created"
  852. $ endif
  853. $ endif
  854. $ EXIT_M2S:
  855. $ close/nolog map
  856. $ close/nolog libopt
  857. $ endsubroutine