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