]> git.lizzy.rs Git - zlib.git/blob - make_vms.com
zlib 1.2.3.5
[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 $! zinser@sysdev.deutsche-boerse.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 $!
15 $ on error then goto err_exit
16 $!
17 $!
18 $! Just some general constants...
19 $!
20 $ true  = 1
21 $ false = 0
22 $ tmpnam = "temp_" + f$getjpi("","pid")
23 $ its_decc = false
24 $ its_vaxc = false
25 $ its_gnuc = false
26 $ s_case   = False
27 $!
28 $! Setup variables holding "config" information
29 $!
30 $ Make     = ""
31 $ name     = "Zlib"
32 $ version  = "?.?.?"
33 $ v_string = "ZLIB_VERSION"
34 $ v_file   = "zlib.h"
35 $ ccopt    = ""
36 $ lopts    = ""
37 $ dnsrl   = ""
38 $ linkonly = false
39 $ optfile  = name + ".opt"
40 $ axp      = f$getsyi("HW_MODEL").ge.1024
41 $!
42 $! Check for MMK/MMS
43 $!
44 $ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS"
45 $ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK"
46 $!
47 $!
48 $ gosub find_version
49 $!
50 $ gosub check_opts
51 $!
52 $! Look for the compiler used
53 $!
54 $ gosub check_compiler
55 $ if its_decc
56 $ then
57 $   ccopt = "/prefix=all" + ccopt
58 $   if f$trnlnm("SYS") .eqs. ""
59 $   then
60 $     if axp
61 $     then
62 $       define sys sys$library:
63 $     else
64 $       ccopt = "/decc" + ccopt
65 $       define sys decc$library_include:
66 $     endif
67 $   endif
68 $ endif
69 $ if its_vaxc .or. its_gnuc
70 $ then
71 $    if f$trnlnm("SYS").eqs."" then define sys sys$library:
72 $ endif
73 $!
74 $! Build the thing plain or with mms
75 $!
76 $ write sys$output "Compiling Zlib sources ..."
77 $ if make.eqs.""
78 $  then
79 $   dele example.obj;*,minigzip.obj;*
80 $   CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
81                 adler32.c zlib.h zconf.h zlibdefs.h
82 $   CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
83                 compress.c zlib.h zconf.h zlibdefs.h
84 $   CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
85                 crc32.c zlib.h zconf.h zlibdefs.h
86 $   CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
87                 deflate.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
88 $   CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" -
89                 gzclose.c zlib.h zconf.h zlibdefs.h gzguts.h
90 $   CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" -
91                 gzio.c zutil.h zlib.h zconf.h zlibdefs.h
92 $   CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" -
93                 gzlib.c zlib.h zconf.h zlibdefs.h gzguts.h
94 $   CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" -
95                 gzread.c zlib.h zconf.h zlibdefs.h gzguts.h
96 $   CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" -
97                 gzwrite.c zlib.h zconf.h zlibdefs.h gzguts.h
98 $   CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
99                 infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
100 $   CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
101                 inffast.c zutil.h zlib.h zconf.h zlibdefs.h inffast.h
102 $   CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" -
103                 inflate.c zutil.h zlib.h zconf.h zlibdefs.h infblock.h
104 $   CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" -
105                 inftrees.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
106 $   CALL MAKE trees.OBJ "CC ''CCOPT' trees" -
107                 trees.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
108 $   CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" -
109                 uncompr.c zlib.h zconf.h zlibdefs.h
110 $   CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" -
111                 zutil.c zutil.h zlib.h zconf.h zlibdefs.h
112 $   write sys$output "Building Zlib ..."
113 $   CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ
114 $   write sys$output "Building example..."
115 $   CALL MAKE example.OBJ "CC ''CCOPT' example" -
116                 example.c zlib.h zconf.h zlibdefs.h
117 $   call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb
118 $   if f$search("x11vms:xvmsutils.olb") .nes. ""
119 $   then
120 $     write sys$output "Building minigzip..."
121 $     CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" -
122                 minigzip.c zlib.h zconf.h zlibdefs.h
123 $     call make minigzip.exe -
124                 "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" -
125                 minigzip.obj libz.olb
126 $   endif
127 $  else
128 $   gosub crea_mms
129 $   write sys$output "Make ''name' ''version' with ''Make' "
130 $   'make'
131 $  endif
132 $!
133 $! Alpha gets a shareable image
134 $!
135 $ If axp
136 $ Then
137 $   gosub crea_olist
138 $   write sys$output "Creating libzshr.exe"
139 $   call anal_obj_axp modules.opt _link.opt
140 $   if s_case
141 $   then
142 $      open/append optf modules.opt
143 $      write optf "case_sensitive=YES"
144 $      close optf
145 $   endif
146 $   LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,_link.opt/opt
147 $ endif
148 $ write sys$output "Zlib build completed"
149 $ exit
150 $CC_ERR:
151 $ write sys$output "C compiler required to build ''name'"
152 $ goto err_exit
153 $ERR_EXIT:
154 $ set message/facil/ident/sever/text
155 $ close/nolog optf
156 $ write sys$output "Exiting..."
157 $ exit 2
158 $!
159 $!
160 $MAKE: SUBROUTINE   !SUBROUTINE TO CHECK DEPENDENCIES
161 $ V = 'F$Verify(0)
162 $! P1 = What we are trying to make
163 $! P2 = Command to make it
164 $! P3 - P8  What it depends on
165 $
166 $ If F$Search(P1) .Eqs. "" Then Goto Makeit
167 $ Time = F$CvTime(F$File(P1,"RDT"))
168 $arg=3
169 $Loop:
170 $       Argument = P'arg
171 $       If Argument .Eqs. "" Then Goto Exit
172 $       El=0
173 $Loop2:
174 $       File = F$Element(El," ",Argument)
175 $       If File .Eqs. " " Then Goto Endl
176 $       AFile = ""
177 $Loop3:
178 $       OFile = AFile
179 $       AFile = F$Search(File)
180 $       If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
181 $       If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
182 $       Goto Loop3
183 $NextEL:
184 $       El = El + 1
185 $       Goto Loop2
186 $EndL:
187 $ arg=arg+1
188 $ If arg .Le. 8 Then Goto Loop
189 $ Goto Exit
190 $
191 $Makeit:
192 $ VV=F$VERIFY(0)
193 $ write sys$output P2
194 $ 'P2
195 $ VV='F$Verify(VV)
196 $Exit:
197 $ If V Then Set Verify
198 $ENDSUBROUTINE
199 $!------------------------------------------------------------------------------
200 $!
201 $! Check command line options and set symbols accordingly
202 $!
203 $ CHECK_OPTS:
204 $ i = 1
205 $ OPT_LOOP:
206 $ if i .lt. 9
207 $ then
208 $   cparm = f$edit(p'i',"upcase")
209 $   if cparm .eqs. "DEBUG"
210 $   then
211 $     ccopt = ccopt + "/noopt/deb"
212 $     lopts = lopts + "/deb"
213 $   endif
214 $   if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
215 $   then
216 $     start = f$locate("=",cparm) + 1
217 $     len   = f$length(cparm) - start
218 $     ccopt = ccopt + f$extract(start,len,cparm)
219 $     if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
220          then s_case = true
221 $   endif
222 $   if cparm .eqs. "LINK" then linkonly = true
223 $   if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
224 $   then
225 $     start = f$locate("=",cparm) + 1
226 $     len   = f$length(cparm) - start
227 $     lopts = lopts + f$extract(start,len,cparm)
228 $   endif
229 $   if f$locate("CC=",cparm) .lt. f$length(cparm)
230 $   then
231 $     start  = f$locate("=",cparm) + 1
232 $     len    = f$length(cparm) - start
233 $     cc_com = f$extract(start,len,cparm)
234       if (cc_com .nes. "DECC") .and. -
235          (cc_com .nes. "VAXC") .and. -
236          (cc_com .nes. "GNUC")
237 $     then
238 $       write sys$output "Unsupported compiler choice ''cc_com' ignored"
239 $       write sys$output "Use DECC, VAXC, or GNUC instead"
240 $     else
241 $       if cc_com .eqs. "DECC" then its_decc = true
242 $       if cc_com .eqs. "VAXC" then its_vaxc = true
243 $       if cc_com .eqs. "GNUC" then its_gnuc = true
244 $     endif
245 $   endif
246 $   if f$locate("MAKE=",cparm) .lt. f$length(cparm)
247 $   then
248 $     start  = f$locate("=",cparm) + 1
249 $     len    = f$length(cparm) - start
250 $     mmks = f$extract(start,len,cparm)
251 $     if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
252 $     then
253 $       make = mmks
254 $     else
255 $       write sys$output "Unsupported make choice ''mmks' ignored"
256 $       write sys$output "Use MMK or MMS instead"
257 $     endif
258 $   endif
259 $   i = i + 1
260 $   goto opt_loop
261 $ endif
262 $ return
263 $!------------------------------------------------------------------------------
264 $!
265 $! Look for the compiler used
266 $!
267 $! Version history
268 $! 0.01 20040223 First version to receive a number
269 $! 0.02 20040229 Save/set value of decc$no_rooted_search_lists
270 $CHECK_COMPILER:
271 $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
272 $ then
273 $   its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "")
274 $   its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "")
275 $   its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "")
276 $ endif
277 $!
278 $! Exit if no compiler available
279 $!
280 $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
281 $ then goto CC_ERR
282 $ else
283 $   if its_decc
284 $   then
285 $     write sys$output "CC compiler check ... Compaq C"
286 $     if f$trnlnm("decc$no_rooted_search_lists") .nes. ""
287 $     then
288 $       dnrsl = f$trnlnm("decc$no_rooted_search_lists")
289 $     endif
290 $     define decc$no_rooted_search_lists 1
291 $   else
292 $     if its_vaxc then write sys$output "CC compiler check ... VAX C"
293 $     if its_gnuc then write sys$output "CC compiler check ... GNU C"
294 $     if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share"
295 $     if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share"
296 $   endif
297 $ endif
298 $ return
299 $!------------------------------------------------------------------------------
300 $!
301 $! If MMS/MMK are available dump out the descrip.mms if required
302 $!
303 $CREA_MMS:
304 $ write sys$output "Creating descrip.mms..."
305 $ create descrip.mms
306 $ open/append out descrip.mms
307 $ copy sys$input: out
308 $ deck
309 # descrip.mms: MMS description file for building zlib on VMS
310 # written by Martin P.J. Zinser
311 # <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com>
312
313 OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj, infback.obj\
314        deflate.obj, trees.obj, zutil.obj, inflate.obj, \
315        inftrees.obj, inffast.obj
316
317 $ eod
318 $ write out "CFLAGS=", ccopt
319 $ write out "LOPTS=", lopts
320 $ copy sys$input: out
321 $ deck
322
323 all : example.exe minigzip.exe libz.olb
324         @ write sys$output " Example applications available"
325
326 libz.olb : libz.olb($(OBJS))
327         @ write sys$output " libz available"
328
329 example.exe : example.obj libz.olb
330               link $(LOPTS) example,libz.olb/lib
331
332 minigzip.exe : minigzip.obj libz.olb
333               link $(LOPTS) minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib
334
335 clean :
336         delete *.obj;*,libz.olb;*,*.opt;*,*.exe;*
337
338
339 # Other dependencies.
340 adler32.obj  : adler32.c zutil.h zlib.h zconf.h zlibdefs.h
341 compress.obj : compress.c zlib.h zconf.h zlibdefs.h
342 crc32.obj    : crc32.c zutil.h zlib.h zconf.h zlibdefs.h
343 deflate.obj  : deflate.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
344 example.obj  : example.c zlib.h zconf.h zlibdefs.h
345 gzio.obj     : gzio.c zutil.h zlib.h zconf.h zlibdefs.h
346 inffast.obj  : inffast.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inffast.h
347 inflate.obj  : inflate.c zutil.h zlib.h zconf.h zlibdefs.h
348 inftrees.obj : inftrees.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
349 minigzip.obj : minigzip.c zlib.h zconf.h zlibdefs.h
350 trees.obj    : trees.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
351 uncompr.obj  : uncompr.c zlib.h zconf.h zlibdefs.h
352 zutil.obj    : zutil.c zutil.h zlib.h zconf.h zlibdefs.h
353 infback.obj  : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
354 $ eod
355 $ close out
356 $ return
357 $!------------------------------------------------------------------------------
358 $!
359 $! Read list of core library sources from makefile.in and create options
360 $! needed to build shareable image
361 $!
362 $CREA_OLIST:
363 $ open/read min makefile.in
364 $ open/write mod modules.opt
365 $ src_check = "OBJC ="
366 $MRLOOP:
367 $ read/end=mrdone min rec
368 $ if (f$extract(0,6,rec) .nes. src_check) then goto mrloop
369 $ rec = rec - src_check
370 $ gosub extra_filnam
371 $ if (f$element(1,"\",rec) .eqs. "\") then goto mrdone
372 $MRSLOOP:
373 $ read/end=mrdone min rec
374 $ gosub extra_filnam
375 $ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop
376 $MRDONE:
377 $ close min
378 $ close mod
379 $ return
380 $!------------------------------------------------------------------------------
381 $!
382 $! Take record extracted in crea_olist and split it into single filenames
383 $!
384 $EXTRA_FILNAM:
385 $ myrec = f$edit(rec - "\", "trim,compress")
386 $ i = 0
387 $FELOOP:
388 $ srcfil = f$element(i," ", myrec)
389 $ if (srcfil .nes. " ")
390 $ then
391 $   write mod f$parse(srcfil,,,"NAME"), ".obj"
392 $   i = i + 1
393 $   goto feloop
394 $ endif
395 $ return
396 $!------------------------------------------------------------------------------
397 $!
398 $! Find current Zlib version number
399 $!
400 $FIND_VERSION:
401 $ open/read h_in 'v_file'
402 $hloop:
403 $ read/end=hdone h_in rec
404 $ rec = f$edit(rec,"TRIM")
405 $ if (f$extract(0,1,rec) .nes. "#") then goto hloop
406 $ rec = f$edit(rec - "#", "TRIM")
407 $ if f$element(0," ",rec) .nes. "define" then goto hloop
408 $ if f$element(1," ",rec) .eqs. v_string
409 $ then
410 $   version = 'f$element(2," ",rec)'
411 $   goto hdone
412 $ endif
413 $ goto hloop
414 $hdone:
415 $ close h_in
416 $ return
417 $!------------------------------------------------------------------------------
418 $!
419 $! Analyze Object files for OpenVMS AXP to extract Procedure and Data 
420 $! information to build a symbol vector for a shareable image
421 $! All the "brains" of this logic was suggested by Hartmut Becker
422 $! (Hartmut.Becker@compaq.com). All the bugs were introduced by me
423 $! (zinser@zinser.no-ip.info), so if you do have problem reports please do not
424 $! bother Hartmut/HP, but get in touch with me
425 $!
426 $! Version history
427 $! 0.01 20040406 Skip over shareable images in option file
428 $! 0.02 20041109 Fix option file for shareable images with case_sensitive=YES
429 $! 0.03 20050107 Skip over Identification labels in option file
430 $! 0.04 20060117 Add uppercase alias to code compiled with /name=as_is
431 $!
432 $ ANAL_OBJ_AXP: Subroutine   
433 $ V = 'F$Verify(0)
434 $ SAY := "WRITE_ SYS$OUTPUT"
435
436 $ IF F$SEARCH("''P1'") .EQS. ""
437 $ THEN
438 $    SAY "ANAL_OBJ_AXP-E-NOSUCHFILE:  Error, inputfile ''p1' not available"
439 $    goto exit_aa
440 $ ENDIF
441 $ IF "''P2'" .EQS. ""
442 $ THEN
443 $    SAY "ANAL_OBJ_AXP:  Error, no output file provided"
444 $    goto exit_aa
445 $ ENDIF
446 $
447 $ open/read in 'p1
448 $ create a.tmp
449 $ open/append atmp a.tmp
450 $ loop:
451 $ read/end=end_loop in line
452 $ if f$locate("/SHARE",f$edit(line,"upcase")) .lt. f$length(line)
453 $ then
454 $   write sys$output "ANAL_SKP_SHR-i-skipshare, ''line'"
455 $   goto loop
456 $ endif
457 $ if f$locate("IDENTIFICATION=",f$edit(line,"upcase")) .lt. f$length(line)
458 $ then
459 $   write sys$output "ANAL_OBJ_AXP-i-ident: Identification ", -
460                      f$element(1,"=",line)
461 $   goto loop
462 $ endif
463 $ f= f$search(line)
464 $ if f .eqs. ""
465 $ then
466 $       write sys$output "ANAL_OBJ_AXP-w-nosuchfile, ''line'"
467 $       goto loop
468 $ endif
469 $ define/user sys$output nl:
470 $ define/user sys$error nl:
471 $ anal/obj/gsd 'f /out=x.tmp
472 $ open/read xtmp x.tmp
473 $ XLOOP:
474 $ read/end=end_xloop xtmp xline
475 $ xline = f$edit(xline,"compress")
476 $ write atmp xline
477 $ goto xloop
478 $ END_XLOOP:
479 $ close xtmp
480 $ goto loop
481 $ end_loop:
482 $ close in
483 $ close atmp
484 $ if f$search("a.tmp") .eqs. "" -
485         then $ exit
486 $ ! all global definitions
487 $ search a.tmp "symbol:","EGSY$V_DEF 1","EGSY$V_NORM 1"/out=b.tmp
488 $ ! all procedures
489 $ search b.tmp "EGSY$V_NORM 1"/wind=(0,1) /out=c.tmp
490 $ search c.tmp "symbol:"/out=d.tmp
491 $ define/user sys$output nl:
492 $ edito/edt/command=sys$input d.tmp
493 sub/symbol: "/symbol_vector=(/whole
494 sub/"/=PROCEDURE)/whole
495 exit
496 $ ! all data
497 $ search b.tmp "EGSY$V_DEF 1"/wind=(0,1) /out=e.tmp
498 $ search e.tmp "symbol:"/out=f.tmp
499 $ define/user sys$output nl:
500 $ edito/edt/command=sys$input f.tmp
501 sub/symbol: "/symbol_vector=(/whole
502 sub/"/=DATA)/whole
503 exit
504 $ sort/nodupl d.tmp,f.tmp g.tmp
505 $ open/read raw_vector g.tmp
506 $ open/write case_vector 'p2'
507 $ RAWLOOP:
508 $ read/end=end_rawloop raw_vector raw_element
509 $ write case_vector raw_element
510 $ if f$locate("=PROCEDURE)",raw_element) .lt. f$length(raw_element)
511 $ then
512 $     name = f$element(1,"=",raw_element) - "("
513 $     if f$edit(name,"UPCASE") .nes. name then -
514           write case_vector f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)", - 
515                                   f$edit(name,"UPCASE"), name) 
516 $ endif
517 $ if f$locate("=DATA)",raw_element) .lt. f$length(raw_element)
518 $ then
519 $     name = f$element(1,"=",raw_element) - "("
520 $     if f$edit(name,"UPCASE") .nes. name then -
521           write case_vector f$fao(" symbol_vector=(!AS/!AS=DATA)", - 
522                                   f$edit(name,"UPCASE"), name) 
523 $ endif
524 $ goto rawloop
525 $ END_RAWLOOP:
526 $ close raw_vector
527 $ close case_vector
528 $ delete a.tmp;*,b.tmp;*,c.tmp;*,d.tmp;*,e.tmp;*,f.tmp;*,g.tmp;*
529 $ if f$search("x.tmp") .nes. "" -
530         then $ delete x.tmp;*
531 $!
532 $ EXIT_AA:
533 $ if V then set verify
534 $ endsubroutine 
535 $!------------------------------------------------------------------------------