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